org.xwiki.platform
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/content/parsers/DocumentParser.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/content/parsers/DocumentParser.java
index 499ae8fb7..45d04e10b 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/content/parsers/DocumentParser.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/content/parsers/DocumentParser.java
@@ -28,7 +28,6 @@
/**
* Parse document source content as typed by the user.
- *
*
* Note: This is a very basic parser which currently only parses wiki links. It should probably
* not be developed further. Instead we should migrate to a proper parser such as
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/content/parsers/LinkParser.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/content/parsers/LinkParser.java
index 8cc355798..46edc518a 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/content/parsers/LinkParser.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/content/parsers/LinkParser.java
@@ -88,7 +88,6 @@ public Link parse(String contentToParse) throws ContentParserException {
/**
* Find out the alias part of the full link.
- *
*
* Note: As it's possible to specify a target we need a way to differentiate the following
* 2 links:
@@ -131,7 +130,6 @@ protected void parseAlias(StringBuffer content, Link link) {
/**
* Find out the target part of the full link.
- *
*
* Note: The target element must start with an underscore ("_"). See
* {@link #parseAlias(StringBuffer, Link)} for more details as to why.
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/content/parsers/RenamePageReplaceLinkHandler.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/content/parsers/RenamePageReplaceLinkHandler.java
index fdba5beca..6b4d718c2 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/content/parsers/RenamePageReplaceLinkHandler.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/content/parsers/RenamePageReplaceLinkHandler.java
@@ -30,7 +30,6 @@ public class RenamePageReplaceLinkHandler implements ReplaceLinkHandler {
/**
* {@inheritDoc}
- *
*
* Two links are equal if they point to the same document and within the same location
* in that document.
@@ -74,7 +73,6 @@ public boolean compare(Link linkToLookFor, Link linkToReplace) {
/**
* {@inheritDoc}
- *
*
* Keep the query string, alias and target in the link to replace if they are not
* specified in the new link.
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/notify/DocObjectChangedRule.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/notify/DocObjectChangedRule.java
index 5cd964b0f..b0e2b890a 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/notify/DocObjectChangedRule.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/notify/DocObjectChangedRule.java
@@ -56,7 +56,8 @@ public boolean hasEqualsObjectsFromClass(XWikiDocument newdoc, XWikiDocument old
}
for (int i = 0; i < vobj1.size(); i++) {
if (((vobj1.get(i) != null) || (vobj2.get(i) != null))) {
- if ((vobj1.get(i) == null) || (vobj2.get(i) == null) || !vobj1.get(i).equals(vobj2.get(i))) {
+ if ((vobj1.get(i) == null) || (vobj2.get(i) == null)
+ || !vobj1.get(i).equals(vobj2.get(i))) {
return false;
}
}
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/objects/BaseStringProperty.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/objects/BaseStringProperty.java
index b971ddc87..17d3d40ab 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/objects/BaseStringProperty.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/objects/BaseStringProperty.java
@@ -23,7 +23,6 @@
/**
* Base string XProperty which all types of string XProperties extend.
- *
* $Id$
*/
public class BaseStringProperty extends BaseProperty {
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/objects/ElementComparator.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/objects/ElementComparator.java
index c0a0083a4..df2adfd15 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/objects/ElementComparator.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/objects/ElementComparator.java
@@ -27,7 +27,6 @@
/**
* Compare and sort instances of ElementInterface by name.
- *
*/
public class ElementComparator implements Comparator {
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/fileupload/FileUploadPlugin.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/fileupload/FileUploadPlugin.java
index d38f1069a..468a1bc57 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/fileupload/FileUploadPlugin.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/fileupload/FileUploadPlugin.java
@@ -110,7 +110,6 @@ public class FileUploadPlugin extends XWikiDefaultPlugin implements XWikiPluginI
* the plugin classname (used in logs for example)
* @param context
* the XWiki Context
- *
* @see XWikiDefaultPlugin#XWikiDefaultPlugin(String,String,com.xpn.xwiki.XWikiContext)
*/
public FileUploadPlugin(String name, String className, XWikiContext context) {
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/fileupload/FileUploadPluginApi.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/fileupload/FileUploadPluginApi.java
index 082b68f26..5fd9b39bc 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/fileupload/FileUploadPluginApi.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/fileupload/FileUploadPluginApi.java
@@ -31,7 +31,6 @@
/**
* Plugin that offers access to uploaded files. The uploaded files are automatically parsed and
* preserved as a list of {@link org.apache.commons.fileupload.FileItem}s.
- *
* This is the wrapper accessible from in-document scripts.
*
* @version $Id$
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/ldap/XWikiLDAPConnection.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/ldap/XWikiLDAPConnection.java
index fe068ba30..f6d49d4f6 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/ldap/XWikiLDAPConnection.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/ldap/XWikiLDAPConnection.java
@@ -394,7 +394,6 @@ protected void ldapToXWikiAttribute(List searchAttribu
/**
* Fully escape DN value (the part after the =).
- *
*
* For example, for the dn value "Acme, Inc", the escapeLDAPDNValue method
* returns "Acme\, Inc".
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/packaging/DocumentInfoAPI.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/packaging/DocumentInfoAPI.java
index 5c8d59f81..fb1c4533b 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/packaging/DocumentInfoAPI.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/packaging/DocumentInfoAPI.java
@@ -58,7 +58,6 @@ public String getFullName() {
/**
* @return the language of the described document
- *
* @since 2.2M1
*/
public String getLanguage() {
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/packaging/PackageAPI.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/packaging/PackageAPI.java
index 5897dd3a1..6416f91ee 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/packaging/PackageAPI.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/packaging/PackageAPI.java
@@ -217,12 +217,10 @@ public String export() throws IOException, XWikiException {
*
* @param data
* the file to create the package from, as a byte array.
- *
* @return true if the package creation succeeded, false otherwise. If the package creation
* failed,
* the error message is placed in the velocity context under the import_error
* key,
- *
* @since 2.2M1
*/
public boolean importPackageFromByteArray(byte data[]) {
@@ -288,7 +286,6 @@ public String toXml() {
/**
* @return a representation of this package under the JSON format
- *
* @since 2.2M1
*/
public JSONObject toJSON() {
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/zipexplorer/ZipExplorerPlugin.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/zipexplorer/ZipExplorerPlugin.java
index 77136b02b..69fc69d52 100755
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/zipexplorer/ZipExplorerPlugin.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/zipexplorer/ZipExplorerPlugin.java
@@ -71,7 +71,6 @@ public class ZipExplorerPlugin extends XWikiDefaultPlugin {
* the plugin classname (used in logs for example)
* @param context
* the XWiki Context
- *
* @see XWikiDefaultPlugin#XWikiDefaultPlugin(String,String,com.xpn.xwiki.XWikiContext)
*/
public ZipExplorerPlugin(String name, String className, XWikiContext context) {
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/zipexplorer/ZipExplorerPluginAPI.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/zipexplorer/ZipExplorerPluginAPI.java
index 60de188b1..890ebbd00 100755
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/zipexplorer/ZipExplorerPluginAPI.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/plugin/zipexplorer/ZipExplorerPluginAPI.java
@@ -107,7 +107,6 @@ public List getFileList(Document document, String attachmentName) {
* { id = "Directory/", value = "Directory", parent = ""}
* { id = "Directory/File.txt", value = "File.txt", parent = "Directory/"}
* { id = "File2.txt", value = "File2.txt", parent = ""}
- *
*
*
* @param document
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/XWikiHibernateBaseStore.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/XWikiHibernateBaseStore.java
index d0cf6d7a3..01d74d22e 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/XWikiHibernateBaseStore.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/XWikiHibernateBaseStore.java
@@ -101,7 +101,6 @@ public synchronized void initHibernate() throws HibernateException {
*
* @param context
* @return
- *
* @deprecated since 6.0 instead use {@link #getSession()}
*/
@Deprecated
@@ -126,7 +125,6 @@ public Session getSession() {
*
* @param session
* @param context
- *
* @deprecated since 6.0 instead use {@link #setSession(Session)}
*/
@Deprecated
@@ -152,7 +150,6 @@ public void setSession(Session session) {
*
* @param context
* @return
- *
* @deprecated since 6.0 instead use {@link #getTransaction()}
*/
@Deprecated
@@ -172,7 +169,6 @@ public Transaction getTransaction() {
*
* @param transaction
* @param context
- *
* @deprecated since 6.0 instead use {@link #setTransaction(Transaction)}
*/
@Deprecated
@@ -196,7 +192,6 @@ public void setTransaction(Transaction transaction) {
*
* @param context
* @throws HibernateException
- *
* @deprecated since 6.0 instead use {@link #updateSchema(String)}
*/
@Deprecated
@@ -220,7 +215,6 @@ public void updateSchema(WikiReference wikiRef) throws HibernateException {
* @param force
* defines wether or not to force the update despite the xwiki.cfg settings
* @throws HibernateException
- *
* @deprecated since 6.0 instead use {@link #updateSchema(String, boolean)}
*/
@Deprecated
@@ -268,7 +262,6 @@ public synchronized void updateSchema(WikiReference wikiRef, boolean force)
* @param context
* the XWiki context.
* @return the database/schema name.
- *
* @deprecated since 6.0 instead use {@link #getSchemaFromWikiName(String)}
*/
@Deprecated
@@ -312,7 +305,6 @@ public String getSchemaFromWikiName(WikiReference wikiRef) {
* the XWiki context.
* @return the database/schema name.
* @since XWiki Core 1.1.2, XWiki Core 1.2M2
- *
* @deprecated since 6.0 instead use {@link #getSchemaFromWikiName(String)}
*/
@Deprecated
@@ -329,7 +321,6 @@ protected String getSchemaFromWikiName(XWikiContext context) {
* @param context
* @return
* @throws HibernateException
- *
* @deprecated since 6.0 instead use {@link #getSchemaUpdateScript(Configuration, String)}
*/
@Deprecated
@@ -420,7 +411,6 @@ private void updateSchema(String[] createSQL, WikiReference wikiRef) {
*
* @param context
* @throws HibernateException
- *
* @deprecated since 6.0 instead use {@link #checkHibernate(String)}
*/
@Deprecated
@@ -432,7 +422,6 @@ public void checkHibernate(XWikiContext context) throws HibernateException {
* Initializes hibernate and calls updateSchema if necessary
*
* @throws HibernateException
- *
* @deprecated noop, bootstrap ensures hibernate is initialized
*/
@Deprecated(since = "6.5")
@@ -447,7 +436,6 @@ public void checkHibernate() throws HibernateException {
* @param context
* the XWiki context.
* @return true if multi-wiki, false otherwise.
- *
* @deprecated since 6.0 instead use xwikiCfg.isVirtualMode()
*/
@Deprecated
@@ -461,7 +449,6 @@ protected boolean isVirtual(XWikiContext context) {
* @param session
* @param context
* @throws XWikiException
- *
* @deprecated since 6.0 instead use {@link #setDatabase(Session, String)}
*/
@Deprecated
@@ -522,7 +509,6 @@ private String getCurrentSchema(Connection connection) {
* @param context
* the XWiki context to get database engine identifier
* @return the escaped version
- *
* @deprecated since 6.0 instead use {@link #escapeSchema(String)}
*/
@Deprecated
@@ -546,7 +532,6 @@ protected String escapeSchema(String schema) {
/**
* Begins a transaction for the current database
- *
*/
public boolean beginTransaction() throws HibernateException, XWikiException {
try {
@@ -564,7 +549,6 @@ public boolean beginTransaction() throws HibernateException, XWikiException {
* @param context
* @return
* @throws XWikiException
- *
* @Deprecated since 6.0 instead use {@link #beginTransaction(String)}
*/
@Deprecated
@@ -577,7 +561,6 @@ public boolean beginTransaction(XWikiContext context) throws XWikiException {
*
* @throws HibernateException
* @throws XWikiException
- *
*/
public boolean beginTransaction(@Nullable WikiReference wikiRef)
throws HibernateException, WikiMissingException, XWikiException {
@@ -591,7 +574,6 @@ public boolean beginTransaction(@Nullable WikiReference wikiRef)
* @param context
* @return
* @throws XWikiException
- *
* @Deprecated since 6.0 instead use {@link #beginTransaction(String)}
*/
@Deprecated
@@ -608,7 +590,6 @@ public boolean beginTransaction(boolean withTransaction, XWikiContext context)
* @param context
* @return
* @throws XWikiException
- *
* @Deprecated since 6.0 instead use {@link #beginTransaction(SessionFactory, String)}
*/
@Deprecated
@@ -625,7 +606,6 @@ public boolean beginTransaction(SessionFactory sfactory, boolean withTransaction
* @return
* @throws HibernateException
* @throws XWikiException
- *
* @Deprecated since 6.0 instead use {@link #beginTransaction(SessionFactory, String)}
*/
@Deprecated
@@ -645,7 +625,6 @@ public boolean beginTransaction(SessionFactory sfactory, XWikiContext context)
*
* @throws HibernateException
* @throws XWikiException
- *
*/
public boolean beginTransaction(
@Nullable SessionFactory sfactory,
@@ -676,7 +655,6 @@ public boolean beginTransaction(
* @param context
* @param commit
* should we commit or not
- *
* @Deprecated since 6.0 instead use {@link #endTransaction(boolean)}
*/
@Deprecated
@@ -691,7 +669,6 @@ public void endTransaction(XWikiContext context, boolean commit, boolean withTra
* @param commit
* should we commit or not
* @throws HibernateException
- *
* @Deprecated since 6.0 instead use {@link #endTransaction(boolean)}
*/
@Deprecated
@@ -852,7 +829,6 @@ public interface HibernateCallback {
* - callback to execute
* @throws XWikiException
* if any error
- *
* @Deprecated since 6.0 instead use {@link #execute(String, boolean, boolean, HibernateCallback)}
*/
@Deprecated
@@ -919,7 +895,6 @@ public T execute(WikiReference wikiRef, boolean bTransaction, boolean doComm
* if any error
* @see #execute(XWikiContext, boolean, boolean,
* com.xpn.xwiki.store.XWikiHibernateBaseStore.HibernateCallback)
- *
* @Deprecated since 6.0 instead use {@link #executeRead(String, boolean, HibernateCallback)}
*/
@Deprecated
@@ -959,7 +934,6 @@ public T executeRead(WikiReference wikiRef, boolean bTransaction, HibernateC
* if any error
* @see #execute(XWikiContext, boolean, boolean,
* com.xpn.xwiki.store.XWikiHibernateBaseStore.HibernateCallback)
- *
* @Deprecated since 6.0 instead use {@link #executeWrite(String, boolean, HibernateCallback)}
*/
@Deprecated
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/XWikiStoreInterface.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/XWikiStoreInterface.java
index 511ce704b..482308fa9 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/XWikiStoreInterface.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/XWikiStoreInterface.java
@@ -557,7 +557,6 @@ void saveLinks(XWikiDocument doc, XWikiContext context, boolean bTransaction)
* @return a list of XWikiDocument.
* @throws XWikiException
* in case of error while performing the query.
- *
* @deprecated since 6.0, instead use {@link QueryExecutor}
*/
@Deprecated
@@ -588,7 +587,6 @@ void saveLinks(XWikiDocument doc, XWikiContext context, boolean bTransaction)
* @throws XWikiException
* in case of error while performing the query.
* @since XWiki Core 1.1.2, XWiki Core 1.2M2
- *
* @deprecated since 6.0, instead use {@link QueryExecutor}
*/
@Deprecated
@@ -613,7 +611,6 @@ List search(String sql, int nb, int start, List> parameterValues, XWiki
* @return a list of XWikiDocument.
* @throws XWikiException
* in case of error while performing the query.
- *
* @deprecated since 6.0, instead use {@link QueryExecutor}
*/
@Deprecated
@@ -649,7 +646,6 @@ List search(String sql, int nb, int start, Object[][] whereParams, XWikiC
* @throws XWikiException
* in case of error while performing the query.
* @since XWiki Core 1.1.2, XWiki Core 1.2M2
- *
* @deprecated since 6.0, instead use {@link QueryExecutor}
*/
@Deprecated
@@ -683,7 +679,6 @@ List search(String sql, int nb, int start, Object[][] whereParams, List
* the ref to the wiki
* @throws XWikiException
* error when creating new wiki.
- *
*/
void createWiki(@NotNull WikiReference wikiRef) throws XWikiException;
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R4359XWIKI1459Migrator.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R4359XWIKI1459Migrator.java
index 0a7c6a9f6..653b59be5 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R4359XWIKI1459Migrator.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R4359XWIKI1459Migrator.java
@@ -99,7 +99,7 @@ public void migrate(XWikiHibernateMigrationManager manager, final XWikiContext c
}
Transaction originalTransaction = ((XWikiHibernateVersioningStore) context.getWiki()
.getVersioningStore())
- .getTransaction(context);
+ .getTransaction(context);
((XWikiHibernateVersioningStore) context.getWiki().getVersioningStore())
.setSession(null, context);
((XWikiHibernateVersioningStore) context.getWiki().getVersioningStore())
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R6079XWIKI1878Migrator.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R6079XWIKI1878Migrator.java
index 360805df5..e7f62ebd2 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R6079XWIKI1878Migrator.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R6079XWIKI1878Migrator.java
@@ -38,7 +38,6 @@
* Migration for XWIKI1878: Fix xwikircs table isdiff data not matching RCS state of some revisions
* (when the state
* says "full" the isdiff column in the database should be false).
- *
* Note: This migrator should only be executed if the R4359XWIKI1459 one has already been executed
* (i.e. if the
* database is in version < 4360). This is because this current migrator is because of a bug in
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R6405XWIKI1933Migrator.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R6405XWIKI1933Migrator.java
index 4ce234749..d9e0a0979 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R6405XWIKI1933Migrator.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R6405XWIKI1933Migrator.java
@@ -25,7 +25,6 @@
/**
* Migration for XWIKI1933: Editing users fails.
- *
* Note: This migrator should only be executed if the R4340XWIKI833 one has already been executed
* during a previous migration (i.e. if the database is in version >= 4340). This is because this
* current migrator is because the old migrator was only executed in the main wiki, and there was
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/util/XWikiStubContextProvider.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/util/XWikiStubContextProvider.java
index ae85a2cd6..fc14a1d59 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/util/XWikiStubContextProvider.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/util/XWikiStubContextProvider.java
@@ -11,7 +11,6 @@
* Tool to create a stub XWikiContext. We call it a stub because it doesn't contain actual request
* or response data. It's created from scratch on every call to avoid deep cloning or memory
* poisoning via uncloned context content.
- *
*/
@ComponentRole
public interface XWikiStubContextProvider {
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/web/SkinAction.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/web/SkinAction.java
index 699d3b11e..684149bdc 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/web/SkinAction.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/web/SkinAction.java
@@ -134,7 +134,8 @@ public String render(String path, XWikiContext context) throws XWikiException, I
// skin document.
// Try in the resources directory.
if (((!doc.getName().equals(defaultbaseskin) && !baseskin.equals(defaultbaseskin))
- && renderFileFromFilesystem(getSkinFilePath(filename, defaultbaseskin), context)) || renderFileFromFilesystem(getResourceFilePath(filename), context)) {
+ && renderFileFromFilesystem(getSkinFilePath(filename, defaultbaseskin), context))
+ || renderFileFromFilesystem(getResourceFilePath(filename), context)) {
found = true;
break;
}
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/web/Utils.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/web/Utils.java
index fad6fbc59..e87044796 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/web/Utils.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/web/Utils.java
@@ -795,7 +795,6 @@ public static Boolean isAjaxRequest(XWikiContext context) {
* @param hint
* a value to differentiate different component implementations for the same role
* @return the component's instance
- *
* @deprecated instead use {@link #getComponent(Class, String)}
*/
@Deprecated
@@ -814,7 +813,6 @@ public static Object getComponent(String role, String hint) {
* @param role
* the class (aka role) that the component implements
* @return the component's instance
- *
* @deprecated instead use {@link #getComponent(Class)}
*/
@Deprecated
diff --git a/celements-xwiki-core/src/main/java/com/xpn/xwiki/web/XWikiRequestProcessor.java b/celements-xwiki-core/src/main/java/com/xpn/xwiki/web/XWikiRequestProcessor.java
index 12d0bd410..29879f22a 100644
--- a/celements-xwiki-core/src/main/java/com/xpn/xwiki/web/XWikiRequestProcessor.java
+++ b/celements-xwiki-core/src/main/java/com/xpn/xwiki/web/XWikiRequestProcessor.java
@@ -30,7 +30,6 @@
import org.apache.commons.logging.LogFactory;
/**
- *
* @version $Id$
*/
public class XWikiRequestProcessor extends org.apache.struts.action.RequestProcessor {
diff --git a/celements-xwiki-core/src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java b/celements-xwiki-core/src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java
index 54d9caa49..705007a49 100644
--- a/celements-xwiki-core/src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java
+++ b/celements-xwiki-core/src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java
@@ -206,7 +206,7 @@ public void testGetDisplayWhenTitleExists() {
this.document.setTitle("Title");
expect(this.mockXWikiRenderingEngine.interpretText(EasyMock.eq("Title"),
EasyMock.isA(XWikiDocument.class), EasyMock.isA(XWikiContext.class))).andReturn("Title")
- .once();
+ .once();
replayDefaults();
assertEquals("Title", this.document.getDisplayTitle(getContext()));
verifyDefaults();
@@ -216,7 +216,7 @@ public void testGetDisplayWhenNoTitleButSectionExists() {
this.document.setContent("Some content\n1 Title");
expect(this.mockXWikiRenderingEngine.interpretText(EasyMock.eq("Title"),
EasyMock.isA(XWikiDocument.class), EasyMock.isA(XWikiContext.class))).andReturn("Title")
- .once();
+ .once();
replayDefaults();
assertEquals("Title", this.document.getDisplayTitle(getContext()));
verifyDefaults();
@@ -230,8 +230,8 @@ public void testGetDisplayTitleWhenVelocityError() {
this.document.setTitle("some content that generate a velocity error");
expect(this.mockXWikiRenderingEngine.interpretText(EasyMock.isA(String.class),
EasyMock.isA(XWikiDocument.class), EasyMock.isA(XWikiContext.class)))
- .andReturn("... blah blah ...
+
+
+
+
+ 4.0.0
+
+ com.celements
+ base-pom
+ 7.0-SNAPSHOT
+
+ celements-xwiki-rendering-api
+ 7.0-SNAPSHOT
+
+
+ com.celements
+ celements-commons
+ 7.0-SNAPSHOT
+ provided
+
+
+ com.celements
+ celements-component
+ 7.0-SNAPSHOT
+ provided
+
+
+ com.celements
+ celements-reference
+ 7.0-SNAPSHOT
+ provided
+
+
+ com.celements
+ celements-config-source-api
+ 7.0-SNAPSHOT
+ provided
+
+
+ com.celements
+ celements-config-source
+ 7.0-SNAPSHOT
+ provided
+
+
+ com.celements
+ celements-observation
+ 7.0-SNAPSHOT
+ provided
+
+
+ com.celements
+ celements-xwiki-velocity
+ 7.0-SNAPSHOT
+ provided
+
+
+ com.celements
+ celements-servlet
+ 7.0-SNAPSHOT
+ provided
+
+
+ javax.servlet
+ javax.servlet-api
+ provided
+
+
+ struts
+ struts
+
+
+
+
+ org.springframework
+ spring-context
+ provided
+
+
+ org.springframework
+ spring-web
+ provided
+
+
+
+
+ commons-configuration
+ commons-configuration
+
+
+ commons-lang
+ commons-lang
+ provided
+
+
+
+
+ org.xwiki.platform
+ xwiki-core-properties
+ provided
+
+
+ org.xwiki.platform
+ xwiki-core-bridge
+ provided
+
+
+ org.xwiki.platform
+ xwiki-core-xml
+ provided
+
+
+ org.dom4j
+ dom4j
+
+
+
+
+ xerces
+ xercesImpl
+ provided
+
+
+
+
+ com.celements
+ celements-base-tests
+ 7.0-SNAPSHOT
+ test
+
+
+
+ org.easymock
+ easymock
+ test
+
+
+
+
+ org.xwiki.platform
+ xwiki-core-shared-tests
+ test
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+ test-jar
+
+ test-jar
+
+
+
+ **/scaffolding/**.class
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+
+ org/xwiki/rendering/syntax/Syntax.java,
+ org/xwiki/rendering/syntax/SyntaxType.java,
+ org/xwiki/rendering/renderer/printer/XHTMLWikiPrinter.java,
+ org/xwiki/rendering/renderer/printer/XMLWikiPrinter.java,
+ org/xwiki/rendering/renderer/printer/VoidWikiPrinter.java,
+ org/xwiki/rendering/renderer/printer/LookaheadWikiPrinter.java,
+ org/xwiki/rendering/renderer/printer/WrappingWikiPrinter.java,
+ org/xwiki/rendering/listener/chaining/LookaheadChainingListener.java,
+ org/xwiki/rendering/listener/chaining/TextOnNewLineStateChainingListener.java,
+ org/xwiki/rendering/listener/chaining/EventType.java,
+ org/xwiki/rendering/listener/chaining/EmptyBlockChainingListener.java,
+ org/xwiki/rendering/listener/chaining/BlockStateChainingListener.java,
+ org/xwiki/rendering/listener/chaining/GroupStateChainingListener.java,
+ org/xwiki/rendering/internal/renderer/xwiki20/XWikiSyntaxMacroRenderer.java,
+ org/xwiki/rendering/internal/renderer/xwiki20/XWikiSyntaxChainingRenderer.java,
+ org/xwiki/rendering/internal/renderer/xwiki20/XWikiSyntaxEscapeHandler.java,
+ org/xwiki/rendering/internal/renderer/xwiki20/XWikiSyntaxImageRenderer.java,
+ org/xwiki/rendering/internal/renderer/xwiki20/reference/XWikiSyntaxResourceRenderer.java,
+ org/xwiki/rendering/internal/renderer/plain/PlainTextRenderer.java,
+ org/xwiki/rendering/internal/renderer/plain/PlainTextChainingRenderer.java,
+ org/xwiki/rendering/internal/renderer/printer/XHTMLWriter.java,
+ org/xwiki/rendering/internal/renderer/printer/XWikiSyntaxEscapeWikiPrinter.java,
+ org/xwiki/rendering/internal/renderer/printer/WikiWriter.java,
+ org/xwiki/rendering/internal/renderer/xhtml/AnnotatedXHTMLChainingRenderer.java,
+ org/xwiki/rendering/internal/renderer/xhtml/link/DefaultXHTMLLinkRenderer.java,
+ org/xwiki/rendering/internal/renderer/xhtml/AnnotatedXHTMLBlockRenderer.java,
+ org/xwiki/rendering/internal/renderer/xhtml/XHTMLChainingRenderer.java,
+ org/xwiki/rendering/internal/renderer/xhtml/XHTMLMacroRenderer.java,
+ org/xwiki/rendering/internal/renderer/xhtml/XHTMLBlockRenderer.java,
+ org/xwiki/rendering/internal/renderer/xhtml/image/DefaultXHTMLImageRenderer.java,
+ org/xwiki/rendering/internal/renderer/xhtml/image/AnnotatedXHTMLImageRenderer.java,
+ org/xwiki/rendering/internal/renderer/event/EventsChainingRenderer.java,
+ org/xwiki/rendering/internal/renderer/event/EventRendererFactory.java,
+ org/xwiki/rendering/internal/renderer/event/EventBlockRenderer.java,
+ org/xwiki/rendering/internal/parser/XDOMGeneratorListener.java
+
+
+
+
+
+
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/AbstractBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/AbstractBlock.java
new file mode 100644
index 000000000..28b29b5f1
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/AbstractBlock.java
@@ -0,0 +1,544 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.security.InvalidParameterException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
+/**
+ * Implementation for Block operations. All blocks should extend this class. Supports the notion of
+ * generic parameters
+ * which can be added to a block (see {@link #getParameter(String)} for more details.
+ *
+ * @version $Id$
+ * @since 1.5M2
+ */
+public abstract class AbstractBlock implements Block {
+
+ /**
+ * Store parameters, see {@link #getParameter(String)} for more explanations on what parameters
+ * are.
+ */
+ private Map
parameters = new LinkedHashMap();
+
+ /**
+ * The Blocks this Block contains.
+ */
+ private List childrenBlocks = new ArrayList();
+
+ /**
+ * The Block containing this Block.
+ */
+ private Block parentBlock;
+
+ /**
+ * The next Sibling Block or null if no next sibling exists.
+ */
+ private Block nextSiblingBlock;
+
+ /**
+ * The previous Sibling Block or null if no previous sibling exists.
+ */
+ private Block previousSiblingBlock;
+
+ /**
+ * Empty constructor to construct an empty block.
+ */
+ public AbstractBlock() {
+ // Nothing to do
+ }
+
+ /**
+ * Construct a block with parameters.
+ *
+ * @param parameters
+ * the parameters to set
+ */
+ public AbstractBlock(Map parameters) {
+ this.parameters.putAll(parameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#addChild(org.xwiki.rendering.block.Block)
+ */
+ public void addChild(Block blockToAdd) {
+ insertChildAfter(blockToAdd, null);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#addChildren(java.util.List)
+ */
+ public void addChildren(List extends Block> blocksToAdd) {
+ for (Block blockToAdd : blocksToAdd) {
+ addChild(blockToAdd);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Block#setNextSiblingBlock(Block)
+ * @since 2.6RC1
+ */
+ public void setNextSiblingBlock(Block nextSiblingBlock) {
+ this.nextSiblingBlock = nextSiblingBlock;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Block#setPreviousSiblingBlock(Block)
+ * @since 2.6RC1
+ */
+ public void setPreviousSiblingBlock(Block previousSiblingBlock) {
+ this.previousSiblingBlock = previousSiblingBlock;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#insertChildBefore(org.xwiki.rendering.block.Block,
+ * org.xwiki.rendering.block.Block)
+ */
+ public void insertChildBefore(Block blockToInsert, Block nextBlock) {
+ blockToInsert.setParent(this);
+
+ if (nextBlock == null) {
+ // Last block becomes last but one
+ if (!this.childrenBlocks.isEmpty()) {
+ Block lastBlock = this.childrenBlocks.get(this.childrenBlocks.size() - 1);
+ blockToInsert.setPreviousSiblingBlock(lastBlock);
+ lastBlock.setNextSiblingBlock(blockToInsert);
+ } else {
+ blockToInsert.setPreviousSiblingBlock(null);
+ }
+ blockToInsert.setNextSiblingBlock(null);
+ this.childrenBlocks.add(blockToInsert);
+ } else {
+ // If there's a previous block to nextBlock then get it to set its next sibling
+ Block previousBlock = nextBlock.getPreviousSibling();
+ if (previousBlock != null) {
+ previousBlock.setNextSiblingBlock(blockToInsert);
+ blockToInsert.setPreviousSiblingBlock(previousBlock);
+ } else {
+ blockToInsert.setPreviousSiblingBlock(null);
+ }
+ blockToInsert.setNextSiblingBlock(nextBlock);
+ nextBlock.setPreviousSiblingBlock(blockToInsert);
+ this.childrenBlocks.add(indexOfChild(nextBlock), blockToInsert);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#insertChildAfter(org.xwiki.rendering.block.Block,
+ * org.xwiki.rendering.block.Block)
+ */
+ public void insertChildAfter(Block blockToInsert, Block previousBlock) {
+ if (previousBlock == null) {
+ insertChildBefore(blockToInsert, null);
+ } else {
+ // If there's a next block to previousBlock then get it to set its previous sibling
+ Block nextBlock = previousBlock.getNextSibling();
+ if (nextBlock != null) {
+ nextBlock.setPreviousSiblingBlock(blockToInsert);
+ blockToInsert.setNextSiblingBlock(nextBlock);
+ } else {
+ blockToInsert.setNextSiblingBlock(null);
+ }
+ blockToInsert.setPreviousSiblingBlock(previousBlock);
+ previousBlock.setNextSiblingBlock(blockToInsert);
+ this.childrenBlocks.add(indexOfChild(previousBlock) + 1, blockToInsert);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#replaceChild(Block, Block)
+ */
+ public void replaceChild(Block newBlock, Block oldBlock) {
+ replaceChild(Collections.singletonList(newBlock), oldBlock);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#replaceChild(List, Block)
+ */
+ public void replaceChild(List newBlocks, Block oldBlock) {
+ int position = indexOfChild(oldBlock);
+
+ if (position == -1) {
+ throw new InvalidParameterException("Provided Block to replace is not a child");
+ }
+
+ List blocks = getChildren();
+
+ // Remove old child
+ blocks.remove(position);
+ oldBlock.setParent(null);
+
+ // Insert new children
+ Block previousBlock = oldBlock.getPreviousSibling();
+ if (newBlocks.isEmpty()) {
+ previousBlock.setNextSiblingBlock(oldBlock.getNextSibling());
+ }
+ Block lastBlock = null;
+ for (Block block : newBlocks) {
+ block.setParent(this);
+ block.setPreviousSiblingBlock(previousBlock);
+ if (previousBlock != null) {
+ previousBlock.setNextSiblingBlock(block);
+ }
+ previousBlock = block;
+ lastBlock = block;
+ }
+ Block nextBlock = oldBlock.getNextSibling();
+ if (nextBlock != null) {
+ nextBlock.setPreviousSiblingBlock(lastBlock);
+ }
+ if (lastBlock != null) {
+ lastBlock.setNextSiblingBlock(nextBlock);
+ }
+
+ blocks.addAll(position, newBlocks);
+
+ oldBlock.setNextSiblingBlock(null);
+ oldBlock.setPreviousSiblingBlock(null);
+ }
+
+ /**
+ * Get the position of the provided block in the list of children.
+ *
+ * Can't use {@link List#indexOf(Object)} since it's using {@link Object#equals(Object)}
+ * internally which is not
+ * what we want since two WordBlock with the same text or two spaces are equals for example but we
+ * want to be able
+ * to target one specific Block.
+ *
+ * @param block
+ * the block
+ * @return the position of the block, -1 if the block can't be found
+ */
+ private int indexOfChild(Block block) {
+ return indexOfBlock(block, getChildren());
+ }
+
+ /**
+ * Get the position of the provided block in the provided list of blocks.
+ *
+ * Can't use {@link List#indexOf(Object)} since it's using {@link Object#equals(Object)}
+ * internally which is not
+ * what we want since two WordBlock with the same text or two spaces are equals for example but we
+ * want to be able
+ * to target one specific Block.
+ *
+ * @param block
+ * the block for which to find the position
+ * @param blocks
+ * the list of blocks in which to look for the passed block
+ * @return the position of the block, -1 if the block can't be found
+ */
+ private int indexOfBlock(Block block, List blocks) {
+ int position = 0;
+
+ for (Block child : blocks) {
+ if (child == block) {
+ return position;
+ }
+ ++position;
+ }
+
+ return -1;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#getChildren()
+ */
+ public List getChildren() {
+ return this.childrenBlocks;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#getParent()
+ */
+ public Block getParent() {
+ return this.parentBlock;
+ }
+
+ /**
+ * @return all parameters
+ */
+ public Map getParameters() {
+ return Collections.unmodifiableMap(this.parameters);
+ }
+
+ /**
+ * A Parameter is a generic key/value which can be used to add metadata to a block. What is done
+ * with the metadata
+ * depends on the Renderer's implementations. For example the XHTML Renderer adds them as Element
+ * attributes.
+ *
+ * @param name
+ * the name of the parameter to return
+ * @return the parameter or null if the parameter doesn't exist
+ */
+ public String getParameter(String name) {
+ return this.parameters.get(name);
+ }
+
+ /**
+ * Set a parameter on the current block. See {@link #getParameter(String)} for more details.
+ *
+ * @param name
+ * the parameter's name
+ * @param value
+ * the parameter's value
+ */
+ public void setParameter(String name, String value) {
+ this.parameters.put(name, value);
+ }
+
+ /**
+ * Set several parameters at once.
+ *
+ * @param parameters
+ * the parameters to set
+ * @see #getParameter(String)
+ * @since 1.7M2
+ */
+ public void setParameters(Map parameters) {
+ this.parameters.putAll(parameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#setParent(org.xwiki.rendering.block.Block)
+ */
+ public void setParent(Block parentBlock) {
+ this.parentBlock = parentBlock;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#getRoot()
+ */
+ public Block getRoot() {
+ Block block = this;
+
+ while (block.getParent() != null) {
+ block = block.getParent();
+ }
+
+ return block;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#getChildrenByType(java.lang.Class, boolean)
+ */
+ public List getChildrenByType(Class blockClass, boolean recurse) {
+ List typedBlocks = new ArrayList();
+ for (Block block : getChildren()) {
+ if (blockClass.isAssignableFrom(block.getClass())) {
+ typedBlocks.add(blockClass.cast(block));
+ }
+ if (recurse && !block.getChildren().isEmpty()) {
+ typedBlocks.addAll(block.getChildrenByType(blockClass, true));
+ }
+ }
+
+ return typedBlocks;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#getPreviousBlockByType(java.lang.Class, boolean)
+ */
+ public T getPreviousBlockByType(Class blockClass, boolean recurse) {
+ if (getParent() == null) {
+ return null;
+ }
+
+ int index = indexOfBlock(this, getParent().getChildren());
+
+ // test previous brothers
+ List blocks = getParent().getChildren();
+ for (int i = index - 1; i >= 0; --i) {
+ Block previousBlock = blocks.get(i);
+ if (blockClass.isAssignableFrom(previousBlock.getClass())) {
+ return blockClass.cast(previousBlock);
+ }
+ }
+
+ // test parent
+ if (blockClass.isAssignableFrom(getParent().getClass())) {
+ return blockClass.cast(getParent());
+ }
+
+ // recurse
+ return recurse ? getParent().getPreviousBlockByType(blockClass, true) : null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#getParentBlockByType(java.lang.Class)
+ */
+ public T getParentBlockByType(Class blockClass) {
+ Block parent = getParent();
+
+ if (parent == null || blockClass.isAssignableFrom(parent.getClass())) {
+ return blockClass.cast(parent);
+ }
+
+ return parent.getParentBlockByType(blockClass);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Block#getNextSibling()
+ * @since 2.6RC1
+ */
+ public Block getNextSibling() {
+ return this.nextSiblingBlock;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Block#getPreviousSibling()
+ * @since 2.6RC1
+ */
+ public Block getPreviousSibling() {
+ return this.previousSiblingBlock;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#removeBlock(Block)
+ * @since 2.6RC1
+ */
+ public void removeBlock(Block childBlockToRemove) {
+ getChildren().remove(childBlockToRemove);
+ if (childBlockToRemove != null) {
+ Block previousBlock = childBlockToRemove.getPreviousSibling();
+ if (previousBlock != null) {
+ previousBlock.setNextSiblingBlock(childBlockToRemove.getNextSibling());
+ }
+ Block nextBlock = childBlockToRemove.getNextSibling();
+ if (nextBlock != null) {
+ nextBlock.setPreviousSiblingBlock(previousBlock);
+ }
+ childBlockToRemove.setNextSiblingBlock(null);
+ childBlockToRemove.setPreviousSiblingBlock(null);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see EqualsBuilder#reflectionEquals(Object, Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ return EqualsBuilder.reflectionEquals(this, obj);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see HashCodeBuilder#reflectionHashCode(Object)
+ */
+ @Override
+ public int hashCode() {
+ return HashCodeBuilder.reflectionHashCode(this);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#clone()
+ */
+ @Override
+ public Block clone() {
+ return clone(null);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#clone(org.xwiki.rendering.block.BlockFilter)
+ * @since 1.8RC2
+ */
+ public Block clone(BlockFilter blockFilter) {
+ Block block;
+ try {
+ block = (AbstractBlock) super.clone();
+ } catch (CloneNotSupportedException e) {
+ // Should never happen
+ throw new RuntimeException("Failed to clone object", e);
+ }
+
+ ((AbstractBlock) block).parameters = new LinkedHashMap(this.parameters);
+
+ ((AbstractBlock) block).childrenBlocks = new ArrayList(this.childrenBlocks.size());
+ for (Block childBlock : this.childrenBlocks) {
+ if (blockFilter != null) {
+ Block clonedChildBlocks = childBlock.clone(blockFilter);
+
+ List filteredBlocks = blockFilter.filter(clonedChildBlocks);
+
+ if (filteredBlocks.size() == 0) {
+ filteredBlocks = clonedChildBlocks.getChildren();
+ }
+
+ block.addChildren(filteredBlocks);
+ } else {
+ block.addChild(childBlock.clone());
+ }
+ }
+
+ return block;
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/AbstractFatherBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/AbstractFatherBlock.java
new file mode 100644
index 000000000..6d37344c6
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/AbstractFatherBlock.java
@@ -0,0 +1,73 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Default implementation for {@link FatherBlock}.
+ *
+ * @version $Id$
+ * @since 1.5M2
+ */
+public abstract class AbstractFatherBlock extends AbstractBlock implements FatherBlock {
+
+ /**
+ * Constructs a block with children blocks.
+ *
+ * @param childrenBlocks
+ * the list of children blocks of the block to construct
+ */
+ public AbstractFatherBlock(List childrenBlocks) {
+ this(childrenBlocks, Collections.emptyMap());
+ }
+
+ /**
+ * Construct a block with children blocks and parameters.
+ *
+ * @param childrenBlocks
+ * the list of children blocks of the block to construct
+ * @param parameters
+ * the parameters to set
+ */
+ public AbstractFatherBlock(List childrenBlocks, Map parameters) {
+ super(parameters);
+ addChildren(childrenBlocks);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractBlock#traverse(org.xwiki.rendering.listener.Listener)
+ */
+ public void traverse(Listener listener) {
+ before(listener);
+
+ for (Block block : getChildren()) {
+ block.traverse(listener);
+ }
+
+ after(listener);
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/Block.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/Block.java
new file mode 100644
index 000000000..9b61cf9d6
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/Block.java
@@ -0,0 +1,249 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.List;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents an element of a XWiki Document's content. For example there are Blocks for Paragraphs,
+ * Bold parts,
+ * Sections, Links, etc. A block has a parent and can have children too for Blocks which are wrapper
+ * around other blocks
+ * (e.g. Paragraph blocks, List blocks, Bold blocks).
+ *
+ * @version $Id$
+ * @since 1.5M2
+ */
+public interface Block extends Cloneable {
+
+ /**
+ * Let the block send {@link Listener} events corresponding to its content. For example a
+ * Paragraph block will send
+ * the {@link org.xwiki.rendering.listener.Listener#beginParagraph} and
+ * {@link org.xwiki.rendering.listener.Listener#endParagraph} events when this method is called.
+ *
+ * @param listener
+ * the listener to which to send the events to.
+ */
+ void traverse(Listener listener);
+
+ /**
+ * Helper method to add a single child block to the end of the children list of the current block.
+ * For adding
+ * several blocks at once use {@link #addChildren(java.util.List)}.
+ *
+ * @param blockToAdd
+ * the child block to add
+ */
+ void addChild(Block blockToAdd);
+
+ /**
+ * Adds several children blocks to the end of the children list of the current block. For example
+ * a bold sentence is
+ * made up of a Bold block to which the different words making up the text have been added to.
+ *
+ * @param blocksToAdd
+ * the children blocks to add
+ */
+ void addChildren(List extends Block> blocksToAdd);
+
+ /**
+ * Helper method to add a single child block to the current block before the provided existing
+ * child block. For
+ * adding several blocks at once use {@link #addChildren(java.util.List)}.
+ *
+ * @param blockToInsert
+ * the child block to add
+ * @param nextBlock
+ * the child block that will be just after the added block
+ * @since 1.6M1
+ */
+ void insertChildBefore(Block blockToInsert, Block nextBlock);
+
+ /**
+ * Helper method to add a single child block to the current block after the provided existing
+ * child block. For
+ * adding several blocks at once use {@link #addChildren(java.util.List)}.
+ *
+ * @param blockToInsert
+ * the child block to add
+ * @param previousBlock
+ * the child block that will be just before the added block
+ * @since 1.6M1
+ */
+ void insertChildAfter(Block blockToInsert, Block previousBlock);
+
+ /**
+ * Replaces an existing children block with the passed new block. Also sets the new block's parent
+ * to be the current
+ * block.
+ *
+ * @param newBlock
+ * the new block to replace the old block with
+ * @param oldBlock
+ * the block to replace with the new block
+ */
+ void replaceChild(Block newBlock, Block oldBlock);
+
+ /**
+ * Replaces an existing children block with the passed new blocks. Also sets the new block's
+ * parents to be the
+ * current block.
+ *
+ * @param newBlocks
+ * the new blocks to replace the old block with
+ * @param oldBlock
+ * the block to replace with the new blocks
+ */
+ void replaceChild(List newBlocks, Block oldBlock);
+
+ /**
+ * Get the parent block. All blocks have a parent and the top level parent is the {@link XDOM}
+ * object.
+ *
+ * @return the parent block
+ */
+ Block getParent();
+
+ /**
+ * Sets the parent block.
+ *
+ * @param parentBlock
+ * the parent block
+ */
+ void setParent(Block parentBlock);
+
+ /**
+ * Gets all children blocks.
+ *
+ * @return the children blocks
+ * @see #addChildren(java.util.List)
+ */
+ List getChildren();
+
+ /**
+ * Gets the top level Block. If the current block is the top level Block, it return itself.
+ *
+ * @return the top level Block
+ */
+ Block getRoot();
+
+ /**
+ * Gets all the Blocks in the tree which are of the passed Block class.
+ *
+ * @param
+ * the class of the Blocks to return
+ * @param blockClass
+ * the block class to look for
+ * @param recurse
+ * if true also search recursively children
+ * @return all the matching blocks
+ * @since 1.6M1
+ */
+ List getChildrenByType(Class blockClass, boolean recurse);
+
+ /**
+ * Look upward to find a block which inherit or is provided type.
+ *
+ * The difference with {@link #getParentBlockByType(Class)} is that this one look also at previous
+ * block in the same
+ * parent when {@link #getParentBlockByType(Class)} only look at parents.
+ *
+ * @param
+ * the class of the Blocks to return
+ * @param blockClass
+ * the block class to look for
+ * @param recurse
+ * if true also search in parents levels
+ * @return the found block, null if nothing is found
+ * @since 1.6M1
+ */
+ T getPreviousBlockByType(Class blockClass, boolean recurse);
+
+ /**
+ * Recursively look at parents to find a block which inherits or is provided type.
+ *
+ * The difference with {@link #getPreviousBlockByType(Class, boolean)} is that this one only look
+ * at parent when
+ * {@link #getPreviousBlockByType(Class, boolean)} look at previous block in the same parent.
+ *
+ * @param
+ * the class of the Blocks to return
+ * @param blockClass
+ * the block class to look for
+ * @return the found block, null if nothing is found
+ * @since 1.9.1
+ */
+ T getParentBlockByType(Class blockClass);
+
+ /**
+ * Removes a Block.
+ *
+ * @param childBlockToRemove
+ * the child block to remove
+ * @since 2.6RC1
+ */
+ void removeBlock(Block childBlockToRemove);
+
+ /**
+ * @return the next sibling block or null if there's no next sibling
+ * @since 2.6RC1
+ */
+ Block getNextSibling();
+
+ /**
+ * @param nextSiblingBlock
+ * see {@link #getNextSibling()}
+ * @since 2.6RC1
+ */
+ void setNextSiblingBlock(Block nextSiblingBlock);
+
+ /**
+ * @return the previous sibling block or null if there's no previous sibling
+ * @since 2.6RC1
+ */
+ Block getPreviousSibling();
+
+ /**
+ * @param previousSiblingBlock
+ * see {@link #getPreviousSibling()} ()}
+ * @since 2.6RC1
+ */
+ void setPreviousSiblingBlock(Block previousSiblingBlock);
+
+ /**
+ * Return a copy of the block with filtered children.
+ *
+ * @param blockFilter
+ * the Block filter.
+ * @return the filtered Block.
+ * @since 1.8RC2
+ */
+ Block clone(BlockFilter blockFilter);
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Object#clone()
+ */
+ Block clone();
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/BlockFilter.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/BlockFilter.java
new file mode 100644
index 000000000..73289c4e0
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/BlockFilter.java
@@ -0,0 +1,50 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.List;
+
+/**
+ * Filter provided block into one or more block.
+ *
+ * The block filter is generally called for each block in a block list and is asked to return a
+ * filtered version of the
+ * provided block. This means:
+ *
+ * - an empty list if the block as to be removed
+ * - the block itself in a list if the filter does not have anything particular to filter on
+ * it
+ * - or even a list of new block to replace the provided block
+ *
+ *
+ * @version $Id$
+ * @since 1.8RC2
+ */
+public interface BlockFilter {
+
+ /**
+ * Filter provided block into zero or more block.
+ *
+ * @param block
+ * the block to filter.
+ * @return should never be null. The filtered blocks or empty list.
+ */
+ List filter(Block block);
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/BulletedListBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/BulletedListBlock.java
new file mode 100644
index 000000000..317cca90d
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/BulletedListBlock.java
@@ -0,0 +1,77 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.List;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.ListType;
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents a Bulleted list.
+ *
+ * @version $Id$
+ * @since 1.5M2
+ */
+public class BulletedListBlock extends AbstractFatherBlock implements ListBLock {
+
+ /**
+ * Construct a Bulleted List Block with no parameters.
+ *
+ * @param childrenBlocks
+ * the blocks making the list
+ */
+ public BulletedListBlock(List childrenBlocks) {
+ super(childrenBlocks);
+ }
+
+ /**
+ * Construct a Bulleted List Block with parameters.
+ *
+ * @param childrenBlocks
+ * the blocks making the list
+ * @param parameters
+ * see {@link org.xwiki.rendering.block.AbstractBlock#getParameter(String)} for more
+ * details on
+ * parameters
+ */
+ public BulletedListBlock(List childrenBlocks, Map parameters) {
+ super(childrenBlocks, parameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractFatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginList(ListType.BULLETED, getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractFatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endList(ListType.BULLETED, getParameters());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/DefinitionDescriptionBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/DefinitionDescriptionBlock.java
new file mode 100644
index 000000000..9ad3be305
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/DefinitionDescriptionBlock.java
@@ -0,0 +1,61 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import org.xwiki.rendering.listener.Listener;
+
+import java.util.List;
+
+/**
+ * Represents a definition description. For exampe in HTML this is the equivalent of <dd>.
+ *
+ * @version $Id$
+ * @since 1.6M2
+ */
+public class DefinitionDescriptionBlock extends AbstractFatherBlock {
+
+ /**
+ * Construct a Definition Description block.
+ *
+ * @param childrenBlocks
+ * the blocks making the description
+ */
+ public DefinitionDescriptionBlock(List childrenBlocks) {
+ super(childrenBlocks);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractFatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginDefinitionDescription();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractFatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endDefinitionDescription();
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/DefinitionListBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/DefinitionListBlock.java
new file mode 100644
index 000000000..1f629c8df
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/DefinitionListBlock.java
@@ -0,0 +1,76 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import org.xwiki.rendering.listener.Listener;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents a definition list. For example in HTML this is the equivalent of <dl>.
+ *
+ * @version $Id$
+ * @since 1.6M2
+ */
+public class DefinitionListBlock extends AbstractFatherBlock implements ListBLock {
+
+ /**
+ * Construct a Definition List block with no parameters.
+ *
+ * @param childrenBlocks
+ * the blocks making the Definition list
+ */
+ public DefinitionListBlock(List childrenBlocks) {
+ super(childrenBlocks);
+ }
+
+ /**
+ * Construct a Definition List Block with parameters.
+ *
+ * @param childrenBlocks
+ * the blocks making the Definition list
+ * @param parameters
+ * see {@link org.xwiki.rendering.block.AbstractBlock#getParameter(String)} for more
+ * details on
+ * parameters
+ */
+ public DefinitionListBlock(List childrenBlocks, Map parameters) {
+ super(childrenBlocks, parameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractFatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginDefinitionList(getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractFatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endDefinitionList(getParameters());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/DefinitionTermBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/DefinitionTermBlock.java
new file mode 100644
index 000000000..878cd228e
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/DefinitionTermBlock.java
@@ -0,0 +1,61 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import org.xwiki.rendering.listener.Listener;
+
+import java.util.List;
+
+/**
+ * Represents a definition description. For exampe in HTML this is the equivalent of <dt>.
+ *
+ * @version $Id$
+ * @since 1.6M2
+ */
+public class DefinitionTermBlock extends AbstractFatherBlock {
+
+ /**
+ * Construct a Definition Term block.
+ *
+ * @param childrenBlocks
+ * the blocks making the Definition Term
+ */
+ public DefinitionTermBlock(List childrenBlocks) {
+ super(childrenBlocks);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractFatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginDefinitionTerm();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractFatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endDefinitionTerm();
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/EmptyLinesBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/EmptyLinesBlock.java
new file mode 100644
index 000000000..c2adedc9e
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/EmptyLinesBlock.java
@@ -0,0 +1,70 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents an empty line between 2 standalone Blocks. A standalone block is block that is not
+ * included in another
+ * block. Standalone blocks are Paragraph, Standalone Macro, Lists, Table, etc.
+ *
+ * @version $Id$
+ * @since 1.6M2
+ */
+public class EmptyLinesBlock extends AbstractBlock {
+
+ /**
+ * Number of empty lines between 2 standalone Blocks.
+ */
+ private int count;
+
+ /**
+ * @param count
+ * the number of empty lines between 2 standalone Blocks
+ */
+ public EmptyLinesBlock(int count) {
+ setEmptyLinesCount(count);
+ }
+
+ /**
+ * @return the number of empty lines between 2 standalone Blocks
+ */
+ public int getEmptyLinesCount() {
+ return this.count;
+ }
+
+ /**
+ * @param count
+ * the number of empty lines between 2 standalone Blocks
+ */
+ public void setEmptyLinesCount(int count) {
+ this.count = count;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractBlock#traverse(Listener)
+ */
+ public void traverse(Listener listener) {
+ listener.onEmptyLines(getEmptyLinesCount());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/FatherBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/FatherBlock.java
new file mode 100644
index 000000000..a7335ac17
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/FatherBlock.java
@@ -0,0 +1,58 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * A type of {@link Block} that has children Blocks. For example the Paragraph Block, the Bold
+ * Block, the List Block,
+ * etc.
+ *
+ * @version $Id$
+ * @since 1.5M2
+ */
+public interface FatherBlock extends Block {
+
+ /**
+ * Send {@link org.xwiki.rendering.listener.Listener} events corresponding to the start of the
+ * father block. For
+ * example for a Bold block, this allows an XHTML Listener (aka a Renderer) to output
+ * <b>.
+ *
+ * @param listener
+ * the listener that will receive the events sent by the father block before the children
+ * blocks have
+ * emitted their own events.
+ */
+ void before(Listener listener);
+
+ /**
+ * Send {@link Listener} events corresponding to the end of the father block. For example for a
+ * Bold block, this
+ * allows an XHTML Listener (aka a Renderer) to output </b>.
+ *
+ * @param listener
+ * the listener that will receive the events sent by the father block after the children
+ * blocks have
+ * emitted their own events.
+ */
+ void after(Listener listener);
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/FormatBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/FormatBlock.java
new file mode 100644
index 000000000..b4552667c
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/FormatBlock.java
@@ -0,0 +1,89 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Format;
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents a text formatting block (bold, italic, etc).
+ *
+ * @version $Id$
+ * @since 1.6M1
+ */
+public class FormatBlock extends AbstractFatherBlock {
+
+ /**
+ * The formatting to apply to the children blocks.
+ */
+ private Format format;
+
+ /**
+ * @param childrenBlocks
+ * the nested children blocks
+ * @param format
+ * the formatting to apply to the children blocks
+ */
+ public FormatBlock(List childrenBlocks, Format format) {
+ this(childrenBlocks, format, Collections.emptyMap());
+ }
+
+ /**
+ * @param childrenBlocks
+ * the nested children blocks
+ * @param format
+ * the formatting to apply to the children blocks
+ * @param parameters
+ * the custom parameters
+ */
+ public FormatBlock(List childrenBlocks, Format format, Map parameters) {
+ super(childrenBlocks, parameters);
+ this.format = format;
+ }
+
+ /**
+ * @return the formatting to apply to the children blocks
+ */
+ public Format getFormat() {
+ return this.format;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractFatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginFormat(getFormat(), getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractFatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endFormat(getFormat(), getParameters());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/GroupBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/GroupBlock.java
new file mode 100644
index 000000000..0e1a1b7ee
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/GroupBlock.java
@@ -0,0 +1,92 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents a grouping of blocks.
+ *
+ * @version $Id$
+ * @since 1.8.3
+ */
+public class GroupBlock extends AbstractFatherBlock {
+
+ /**
+ * Create an empty group block with no children. This is useful when the user wants to call
+ * {@link #addChild(Block)}
+ * manually for adding children one by one after the block is constructed.
+ */
+ public GroupBlock() {
+ this(Collections.emptyList());
+ }
+
+ /**
+ * Create an empty group block with no children. This is useful when the user wants to call
+ * {@link #addChild(Block)}
+ * manually for adding children one by one after the block is constructed.
+ *
+ * @param parameters
+ * the parameters of the group
+ */
+ public GroupBlock(Map parameters) {
+ this(Collections.emptyList(), parameters);
+ }
+
+ /**
+ * @param blocks
+ * the children blocks of the group
+ */
+ public GroupBlock(List blocks) {
+ super(blocks);
+ }
+
+ /**
+ * @param blocks
+ * the children blocks of the group
+ * @param parameters
+ * the parameters of the group
+ */
+ public GroupBlock(List blocks, Map parameters) {
+ super(blocks, parameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginGroup(getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endGroup(getParameters());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/HeaderBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/HeaderBlock.java
new file mode 100644
index 000000000..f5f645765
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/HeaderBlock.java
@@ -0,0 +1,139 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.List;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Listener;
+import org.xwiki.rendering.listener.HeaderLevel;
+
+/**
+ * @version $Id$
+ * @since 1.5M2
+ */
+public class HeaderBlock extends AbstractFatherBlock {
+
+ /**
+ * The level of the header.
+ */
+ private HeaderLevel level;
+
+ /**
+ * The id of the header.
+ */
+ private String id;
+
+ /**
+ * @param childBlocks
+ * the children of the header.
+ * @param level
+ * the level of the header
+ */
+ public HeaderBlock(List childBlocks, HeaderLevel level) {
+ super(childBlocks);
+
+ this.level = level;
+ }
+
+ /**
+ * @param childBlocks
+ * the children of the header.
+ * @param level
+ * the level of the header
+ * @param parameters
+ * the parameters of the header
+ */
+ public HeaderBlock(List childBlocks, HeaderLevel level, Map parameters) {
+ super(childBlocks, parameters);
+
+ this.level = level;
+ }
+
+ /**
+ * @param childBlocks
+ * the children of the header.
+ * @param level
+ * the level of the header
+ * @param id
+ * the id of the header.
+ */
+ public HeaderBlock(List childBlocks, HeaderLevel level, String id) {
+ this(childBlocks, level);
+
+ this.id = id;
+ }
+
+ /**
+ * @param childBlocks
+ * the children of the header.
+ * @param level
+ * the level of the header
+ * @param parameters
+ * the parameters of the header
+ * @param id
+ * the id of the header.
+ */
+ public HeaderBlock(List childBlocks, HeaderLevel level, Map parameters,
+ String id) {
+ this(childBlocks, level, parameters);
+
+ this.id = id;
+ }
+
+ /**
+ * @return the level of the header
+ */
+ public HeaderLevel getLevel() {
+ return this.level;
+ }
+
+ /**
+ * @return the id of the header.
+ */
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * @return the {@link SectionBlock} corresponding to this header
+ */
+ public SectionBlock getSection() {
+ return (SectionBlock) getParent();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginHeader(getLevel(), getId(), getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endHeader(getLevel(), getId(), getParameters());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/HorizontalLineBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/HorizontalLineBlock.java
new file mode 100644
index 000000000..a71e8004a
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/HorizontalLineBlock.java
@@ -0,0 +1,61 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents a Horizontal line.
+ *
+ * @version $Id$
+ * @since 1.6M1
+ */
+public class HorizontalLineBlock extends AbstractBlock {
+
+ /**
+ * Construct a Horizontal Line Block with no parameters.
+ */
+ public HorizontalLineBlock() {
+ super();
+ }
+
+ /**
+ * Construct a Horizontal Line Block with parameters.
+ *
+ * @param parameters
+ * see {@link org.xwiki.rendering.block.AbstractBlock#getParameter(String)} for more
+ * details on
+ * parameters
+ */
+ public HorizontalLineBlock(Map parameters) {
+ super(parameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractBlock#traverse(org.xwiki.rendering.listener.Listener)
+ */
+ public void traverse(Listener listener) {
+ listener.onHorizontalLine(getParameters());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/IdBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/IdBlock.java
new file mode 100644
index 000000000..11a11d766
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/IdBlock.java
@@ -0,0 +1,63 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * A reference/location in a page. In HTML for example this is called an Anchor. It allows pointing
+ * to that location,
+ * for example in links.
+ *
+ * @version $Id$
+ * @since 1.6M1
+ * @see Listener#onId(String)
+ */
+public class IdBlock extends AbstractBlock {
+
+ /**
+ * The unique name for the reference/location.
+ */
+ private String name;
+
+ /**
+ * @param name
+ * the unique name for the reference/location.
+ */
+ public IdBlock(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the reference/location name
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractBlock#traverse(org.xwiki.rendering.listener.Listener)
+ */
+ public void traverse(Listener listener) {
+ listener.onId(getName());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/ImageBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/ImageBlock.java
new file mode 100644
index 000000000..4cce9af65
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/ImageBlock.java
@@ -0,0 +1,116 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Listener;
+import org.xwiki.rendering.listener.reference.ResourceReference;
+
+/**
+ * Represents an image.
+ *
+ * @version $Id$
+ * @since 1.7M2
+ */
+public class ImageBlock extends AbstractBlock {
+
+ /**
+ * A reference to the image target. See
+ * {@link org.xwiki.rendering.listener.reference.ResourceReference} for more
+ * details.
+ */
+ private ResourceReference reference;
+
+ /**
+ * If true then the image is defined as a free standing URI directly in the text.
+ */
+ private boolean isFreeStandingURI;
+
+ /**
+ * @param reference
+ * the image reference
+ * @param isFreeStandingURI
+ * indicate if the image syntax is simple a full descriptive syntax (detail depending of
+ * the syntax)
+ * @since 2.5RC1
+ */
+ public ImageBlock(ResourceReference reference, boolean isFreeStandingURI) {
+ this(reference, isFreeStandingURI, Collections.emptyMap());
+ }
+
+ /**
+ * @param reference
+ * the image reference
+ * @param isFreeStandingURI
+ * indicate if the image syntax is simple a full descriptive syntax (detail depending of
+ * the syntax)
+ * @param parameters
+ * the custom parameters
+ * @since 2.5RC1
+ */
+ public ImageBlock(ResourceReference reference, boolean isFreeStandingURI,
+ Map parameters) {
+ super(parameters);
+
+ this.reference = reference;
+ this.isFreeStandingURI = isFreeStandingURI;
+ }
+
+ /**
+ * @return the reference to the image
+ * @see org.xwiki.rendering.listener.reference.ResourceReference
+ * @since 2.5RC1
+ */
+ public ResourceReference getReference() {
+ return this.reference;
+ }
+
+ /**
+ * @return true if the image is defined as a free standing URI directly in the text, false
+ * otherwise
+ */
+ public boolean isFreeStandingURI() {
+ return this.isFreeStandingURI;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#traverse(org.xwiki.rendering.listener.Listener)
+ */
+ public void traverse(Listener listener) {
+ listener.onImage(getReference(), isFreeStandingURI(), getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractBlock#clone(org.xwiki.rendering.block.BlockFilter)
+ * @since 1.8RC2
+ */
+ @Override
+ public ImageBlock clone(BlockFilter blockFilter) {
+ ImageBlock clone = (ImageBlock) super.clone(blockFilter);
+ clone.reference = getReference().clone();
+ return clone;
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/LinkBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/LinkBlock.java
new file mode 100644
index 000000000..d1ed1885c
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/LinkBlock.java
@@ -0,0 +1,128 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Listener;
+import org.xwiki.rendering.listener.reference.ResourceReference;
+
+/**
+ * Represents a Link element in a page.
+ *
+ * @version $Id$
+ * @since 1.5M2
+ */
+public class LinkBlock extends AbstractFatherBlock {
+
+ /**
+ * A reference to the link target. See
+ * {@link org.xwiki.rendering.listener.reference.ResourceReference} for more
+ * details.
+ */
+ private ResourceReference reference;
+
+ /**
+ * If true then the link is a free standing URI directly in the text.
+ */
+ private boolean isFreeStandingURI;
+
+ /**
+ * @param childrenBlocks
+ * the nested children blocks
+ * @param reference
+ * the reference to the target resource to link to
+ * @param isFreeStandingURI
+ * if true then the link is a free standing URI directly in the text
+ * @since 2.5RC1
+ */
+ public LinkBlock(List childrenBlocks, ResourceReference reference,
+ boolean isFreeStandingURI) {
+ this(childrenBlocks, reference, isFreeStandingURI, Collections.emptyMap());
+ }
+
+ /**
+ * @param childrenBlocks
+ * the nested children blocks
+ * @param reference
+ * the reference to the target resource to link to
+ * @param isFreeStandingURI
+ * if true then the link is a free standing URI directly in the text
+ * @param parameters
+ * the parameters to set
+ * @since 2.5RC1
+ */
+ public LinkBlock(List childrenBlocks, ResourceReference reference,
+ boolean isFreeStandingURI,
+ Map parameters) {
+ super(childrenBlocks, parameters);
+ this.reference = reference;
+ this.isFreeStandingURI = isFreeStandingURI;
+ }
+
+ /**
+ * @return the reference to the target to link to
+ * @see org.xwiki.rendering.listener.reference.ResourceReference
+ * @since 2.5RC1
+ */
+ public ResourceReference getReference() {
+ return this.reference;
+ }
+
+ /**
+ * @return true if the link is a free standing URI directly in the text, false otherwise
+ */
+ public boolean isFreeStandingURI() {
+ return this.isFreeStandingURI;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractFatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginLink(getReference(), isFreeStandingURI(), getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractFatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endLink(getReference(), isFreeStandingURI(), getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractBlock#clone(org.xwiki.rendering.block.BlockFilter)
+ * @since 1.8RC2
+ */
+ @Override
+ public LinkBlock clone(BlockFilter blockFilter) {
+ LinkBlock clone = (LinkBlock) super.clone(blockFilter);
+ clone.reference = getReference().clone();
+ return clone;
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/ListBLock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/ListBLock.java
new file mode 100644
index 000000000..45fd88828
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/ListBLock.java
@@ -0,0 +1,30 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+/**
+ * Represents any type of Lists (numbered list, bulleted list, etc).
+ *
+ * @version $Id$
+ * @since 1.5M2
+ */
+public interface ListBLock extends Block {
+ // This is currently only a tagging interface and thus it has no methods.
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/ListItemBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/ListItemBlock.java
new file mode 100644
index 000000000..7b8bdbde4
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/ListItemBlock.java
@@ -0,0 +1,61 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.List;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents a List item element in a page.
+ *
+ * @version $Id$
+ * @since 1.5M2
+ */
+public class ListItemBlock extends AbstractFatherBlock {
+
+ /**
+ * Constructs a list item Block.
+ *
+ * @param childrenBlocks
+ * the blocks representing the list item content
+ */
+ public ListItemBlock(List childrenBlocks) {
+ super(childrenBlocks);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractFatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginListItem();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractFatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endListItem();
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/MacroBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/MacroBlock.java
new file mode 100644
index 000000000..59e07642c
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/MacroBlock.java
@@ -0,0 +1,128 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents a Macro (standalone or inline) defined in a page.
+ *
+ * Note: You can get macro parameters using {@link #getParameters()} for example. Macro block is
+ * reusing Block standard
+ * custom parameters API since macro by definition already have parameters and don't need also block
+ * parameters. So in
+ * this case MacroBlock parameters and Block parameters are the same thing.
+ *
+ * @version $Id$
+ * @since 1.8M2
+ */
+public class MacroBlock extends AbstractBlock {
+
+ /**
+ * @see #getId
+ */
+ private String id;
+
+ /**
+ * The macro content for macro that have content. Otherwise it's null.
+ */
+ private String content;
+
+ /**
+ * The macro is located in a inline content (like paragraph, etc.).
+ */
+ private boolean isInline;
+
+ /**
+ * @param id
+ * the id of the macro
+ * @param parameters
+ * the parameters of the macro
+ * @param isInline
+ * indicate if the macro is located in a inline content (like paragraph, etc.)
+ */
+ public MacroBlock(String id, Map parameters, boolean isInline) {
+ this(id, parameters, null, isInline);
+ }
+
+ /**
+ * @param id
+ * the id of the macro
+ * @param parameters
+ * the parameters of the macro
+ * @param content
+ * the content of the macro. Null if the macro does not have content
+ * @param isInline
+ * indicate if the macro is located in a inline content (like paragraph, etc.)
+ */
+ public MacroBlock(String id, Map parameters, String content, boolean isInline) {
+ super(parameters);
+
+ this.id = id;
+ this.content = content;
+ this.isInline = isInline;
+ }
+
+ /**
+ * @return the macro id (eg "toc" for the TOC Macro).
+ * @since 2.0M3
+ */
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * @return the macro content.
+ */
+ public String getContent() {
+ return this.content;
+ }
+
+ /**
+ * @return if true the macro is located in a inline content (like paragraph, etc.).
+ */
+ public boolean isInline() {
+ return this.isInline;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractBlock#traverse(org.xwiki.rendering.listener.Listener)
+ */
+ public void traverse(Listener listener) {
+ // Don't do anything here since we want the Macro Transformer component to take in charge
+ // Macro execution. This is because Macro execution is a complex process that involves:
+ // * computing the order in which the macros should be evaluated. For example the TOC macro
+ // should evaluate last since other macros can contribute headers/sections blocks.
+ // * some macros need to modify blocks in the XDOM object
+ // * macro execution is a multi-pass process
+ // In essence the Macro Transformer will replace all MacroBlock blocks with other Blocks
+ // generated from the execution of the Macros when XDOM.traverse() is called there
+ // won't be any MacroBlock.traverse() method called at all.
+
+ // Note: We're calling the event to let other listener downstream decide what to do with it.
+ // In practice as described above this method will never get called when the whole rendering
+ // process is executed. This does get called during our unit tests though.
+ listener.onMacro(getId(), getParameters(), getContent(), isInline());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/MacroMarkerBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/MacroMarkerBlock.java
new file mode 100644
index 000000000..6bbe586d3
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/MacroMarkerBlock.java
@@ -0,0 +1,139 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.List;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * A special block that Macro Blocks generate when they are executed so that it's possible to
+ * reconstruct the initial
+ * syntax even after Macros have been executed. For example this is important in a WYSWIYG editor
+ * where you want to show
+ * the Macro's rendered result and also let users modify the macro content.
+ *
+ * @version $Id$
+ * @since 1.5M2
+ */
+public class MacroMarkerBlock extends AbstractFatherBlock {
+
+ /**
+ * The macro name that we are preserving.
+ */
+ private String id;
+
+ /**
+ * The macro content that we are preserving.
+ */
+ private String content;
+
+ /**
+ * The macro is located in a inline content (like paragraph, etc.).
+ */
+ private boolean isInline;
+
+ /**
+ * @param id
+ * the name of the macro
+ * @param parameters
+ * the parameters of the macro
+ * @param childBlocks
+ * the list of children blocks generated by the macro
+ * @param isInline
+ * indicate if the macro is located in a inline content (like paragraph, etc.)
+ */
+ public MacroMarkerBlock(String id, Map parameters, List childBlocks,
+ boolean isInline) {
+ this(id, parameters, null, childBlocks, isInline);
+ }
+
+ /**
+ * @param id
+ * the name of the macro
+ * @param parameters
+ * the parameters of the macro
+ * @param content
+ * the content of the macro. Null if the macro does not have content
+ * @param childBlocks
+ * the list of children blocks generated by the macro
+ * @param isInline
+ * indicate if the macro is located in a inline content (like paragraph, etc.)
+ */
+ public MacroMarkerBlock(String id, Map parameters, String content,
+ List childBlocks,
+ boolean isInline) {
+ super(childBlocks, parameters);
+
+ this.id = id;
+ this.content = content;
+ this.isInline = isInline;
+ }
+
+ /**
+ * @return the macro name.
+ * @deprecated since 2.4M1 use {@link #getId()} instead
+ */
+ @Deprecated
+ public String getName() {
+ return getId();
+ }
+
+ /**
+ * @return the macro identifier.
+ * @since 2.4M1
+ */
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * @return the macro content.
+ */
+ public String getContent() {
+ return this.content;
+ }
+
+ /**
+ * @return if true the macro is located in a inline content (like paragraph, etc.).
+ */
+ public boolean isInline() {
+ return this.isInline;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractFatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginMacroMarker(getName(), getParameters(), getContent(), isInline());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractFatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endMacroMarker(getName(), getParameters(), getContent(), isInline());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/NewLineBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/NewLineBlock.java
new file mode 100644
index 000000000..f826f88d0
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/NewLineBlock.java
@@ -0,0 +1,55 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents a new line or line break (it's up to the Renderers to decide if it should be outputted
+ * as a new line or as
+ * a line break in the given syntax).
+ *
+ * @version $Id$
+ * @since 1.5M2
+ */
+public final class NewLineBlock extends AbstractBlock {
+
+ /**
+ * A new line block. Note that we don't make NewLineBlock a singleton since that would cause
+ * problems when using
+ * Block APIs to manipulate a tree of blocks (for example to find the position of a new line block
+ * in a list using
+ * {@link java.util.List#indexOf(Object)} wich would always return the first new line block).
+ *
+ * @since 2.6RC1
+ */
+ public NewLineBlock() {
+ // We need to keep this constructor to override the ones in AbstractBlock
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractBlock#traverse(org.xwiki.rendering.listener.Listener)
+ */
+ public void traverse(Listener listener) {
+ listener.onNewLine();
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/NumberedListBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/NumberedListBlock.java
new file mode 100644
index 000000000..04d954363
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/NumberedListBlock.java
@@ -0,0 +1,77 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.List;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.ListType;
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents a numbered List.
+ *
+ * @version $Id$
+ * @since 1.5M2
+ */
+public class NumberedListBlock extends AbstractFatherBlock implements ListBLock {
+
+ /**
+ * Construct a Numbered List Block with no parameters.
+ *
+ * @param childrenBlocks
+ * the blocks making the list
+ */
+ public NumberedListBlock(List childrenBlocks) {
+ super(childrenBlocks);
+ }
+
+ /**
+ * Construct a Numbered List Block with parameters.
+ *
+ * @param childrenBlocks
+ * the blocks making the list
+ * @param parameters
+ * see {@link org.xwiki.rendering.block.AbstractBlock#getParameter(String)} for more
+ * details on
+ * parameters
+ */
+ public NumberedListBlock(List childrenBlocks, Map parameters) {
+ super(childrenBlocks, parameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractFatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginList(ListType.NUMBERED, getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractFatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endList(ListType.NUMBERED, getParameters());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/ParagraphBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/ParagraphBlock.java
new file mode 100644
index 000000000..b40eaa611
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/ParagraphBlock.java
@@ -0,0 +1,68 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.List;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * @version $Id$
+ * @since 1.5M2
+ */
+public class ParagraphBlock extends AbstractFatherBlock {
+
+ /**
+ * @param blocks
+ * the children blocks of the paragraph
+ */
+ public ParagraphBlock(List blocks) {
+ super(blocks);
+ }
+
+ /**
+ * @param blocks
+ * the children blocks of the paragraph
+ * @param parameters
+ * the parameters of the paragraph
+ */
+ public ParagraphBlock(List blocks, Map parameters) {
+ super(blocks, parameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginParagraph(getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endParagraph(getParameters());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/PlainTextBlockFilter.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/PlainTextBlockFilter.java
new file mode 100644
index 000000000..852eebc41
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/PlainTextBlockFilter.java
@@ -0,0 +1,110 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.io.StringReader;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.xwiki.rendering.listener.reference.ResourceReference;
+import org.xwiki.rendering.listener.reference.ResourceType;
+import org.xwiki.rendering.parser.ParseException;
+import org.xwiki.rendering.parser.Parser;
+import org.xwiki.rendering.renderer.reference.link.LinkLabelGenerator;
+
+/**
+ * Used to filter plain text blocks.
+ *
+ * @version $Id$
+ * @since 1.9M1
+ */
+public class PlainTextBlockFilter implements BlockFilter {
+
+ /**
+ * The set of valid Block classes as toc item content.
+ */
+ private static final Set> VALID_PLAINTEXT_BLOCKS = new HashSet>() {
+
+ {
+ add(WordBlock.class);
+ add(SpaceBlock.class);
+ add(SpecialSymbolBlock.class);
+ add(NewLineBlock.class);
+ }
+ };
+
+ /**
+ * A parser that knows how to parse plain text; this is used to transform link labels into plain
+ * text.
+ */
+ private Parser plainTextParser;
+
+ /**
+ * Generate link label.
+ */
+ private LinkLabelGenerator linkLabelGenerator;
+
+ /**
+ * @param plainTextParser
+ * a plain text parser used to transform link labels into plain text
+ * @param linkLabelGenerator
+ * generate link label.
+ * @since 2.0M3
+ */
+ public PlainTextBlockFilter(Parser plainTextParser, LinkLabelGenerator linkLabelGenerator) {
+ this.plainTextParser = plainTextParser;
+ this.linkLabelGenerator = linkLabelGenerator;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.BlockFilter#filter(org.xwiki.rendering.block.Block)
+ */
+ public List filter(Block block) {
+ if (VALID_PLAINTEXT_BLOCKS.contains(block.getClass())) {
+ return Collections.singletonList(block);
+ } else if (block.getClass() == LinkBlock.class && block.getChildren().size() == 0) {
+ ResourceReference reference = ((LinkBlock) block).getReference();
+
+ try {
+ String label;
+
+ if (reference.getType().equals(ResourceType.DOCUMENT)) {
+ label = this.linkLabelGenerator.generate(reference);
+ } else {
+ label = reference.getReference();
+ }
+
+ return this.plainTextParser.parse(new StringReader(label)).getChildren().get(0)
+ .getChildren();
+ } catch (ParseException e) {
+ // This shouldn't happen since the parser cannot throw an exception since the source is a
+ // memory
+ // String.
+ throw new RuntimeException("Failed to parse link label as plain text", e);
+ }
+ } else {
+ return Collections.emptyList();
+ }
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/QuotationBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/QuotationBlock.java
new file mode 100644
index 000000000..b6111659d
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/QuotationBlock.java
@@ -0,0 +1,71 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents a quotation. There are one or several quotation lines inside a quotation block.
+ *
+ * @version $Id$
+ * @since 1.6M2
+ */
+public class QuotationBlock extends AbstractFatherBlock {
+
+ /**
+ * @param blocks
+ * the children of the quotation
+ */
+ public QuotationBlock(List blocks) {
+ super(blocks, Collections.emptyMap());
+ }
+
+ /**
+ * @param blocks
+ * the children of the quotation
+ * @param parameters
+ * the parameters of the quotation
+ */
+ public QuotationBlock(List blocks, Map parameters) {
+ super(blocks, parameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginQuotation(getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endQuotation(getParameters());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/QuotationLineBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/QuotationLineBlock.java
new file mode 100644
index 000000000..df20ff420
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/QuotationLineBlock.java
@@ -0,0 +1,59 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.List;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents a quotation line. There can be several quotation lines in a quotation block.
+ *
+ * @version $Id$
+ * @since 1.6M2
+ */
+public class QuotationLineBlock extends AbstractFatherBlock {
+
+ /**
+ * @param blocks
+ * the children of the quotation line
+ */
+ public QuotationLineBlock(List blocks) {
+ super(blocks);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginQuotationLine();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endQuotationLine();
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/RawBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/RawBlock.java
new file mode 100644
index 000000000..f94f7cad8
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/RawBlock.java
@@ -0,0 +1,80 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import org.xwiki.rendering.listener.Listener;
+import org.xwiki.rendering.syntax.Syntax;
+
+/**
+ * Represents some raw content that shouldn't be parsed or modified and that should be injected as
+ * is in any output. The
+ * content depends on a syntax and listeners decide if they can handle that syntax or not. For
+ * example if it's in
+ * "xhtml/1.0" syntax then the XHTML Renderer can insert it directly in the XHTML output.
+ *
+ * @version $Id$
+ * @since 1.8.3
+ */
+public class RawBlock extends AbstractBlock {
+
+ /**
+ * @see #getRawContent()
+ */
+ private String rawContent;
+
+ /**
+ * @see #getSyntax()
+ */
+ private Syntax syntax;
+
+ /**
+ * @param rawContent
+ * the content to inject as is into the listener (it won't be modified)
+ * @param syntax
+ * the syntax in which the content is written
+ */
+ public RawBlock(String rawContent, Syntax syntax) {
+ this.rawContent = rawContent;
+ this.syntax = syntax;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractBlock#traverse(Listener)
+ */
+ public void traverse(Listener listener) {
+ listener.onRawText(getRawContent(), getSyntax());
+ }
+
+ /**
+ * @return the content to inject as is into the listener (it won't be modified)
+ */
+ public String getRawContent() {
+ return this.rawContent;
+ }
+
+ /**
+ * @return the syntax in which the content is written
+ */
+ public Syntax getSyntax() {
+ return this.syntax;
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/SectionBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/SectionBlock.java
new file mode 100644
index 000000000..20f1346a3
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/SectionBlock.java
@@ -0,0 +1,86 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.List;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * @version $Id$
+ * @since 1.5M2
+ */
+public class SectionBlock extends AbstractFatherBlock {
+
+ /**
+ * @param childBlocks
+ * the children of the section
+ */
+ public SectionBlock(List childBlocks) {
+ super(childBlocks);
+ }
+
+ /**
+ * @param childBlocks
+ * the children of the section
+ * @param parameters
+ * the parameters of the section
+ */
+ public SectionBlock(List childBlocks, Map parameters) {
+ super(childBlocks, parameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginSection(getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endSection(getParameters());
+ }
+
+ /**
+ * @return the title block of the section.
+ */
+ public HeaderBlock getHeaderBlock() {
+ HeaderBlock headerBlock = null;
+
+ List children = getChildren();
+
+ if (children.size() > 0) {
+ Block firstChild = children.get(0);
+ if (firstChild instanceof HeaderBlock) {
+ headerBlock = (HeaderBlock) firstChild;
+ }
+ }
+
+ return headerBlock;
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/SpaceBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/SpaceBlock.java
new file mode 100644
index 000000000..051bde552
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/SpaceBlock.java
@@ -0,0 +1,63 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents a space.
+ *
+ * @version $Id$
+ * @since 1.5M2
+ */
+public final class SpaceBlock extends AbstractBlock {
+
+ /**
+ * A space block. Note that we don't make SpaceBlock a singleton since that would cause problems
+ * when using Block
+ * APIs to manipulate a tree of blocks (for example to find the position of a space block in a
+ * list using
+ * {@link java.util.List#indexOf(Object)} wich would always return the first space block).
+ *
+ * @since 2.6RC1
+ */
+ public SpaceBlock() {
+ // We need to keep this constructor to override the ones in AbstractBlock
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#traverse(org.xwiki.rendering.listener.Listener)
+ */
+ public void traverse(Listener listener) {
+ listener.onSpace();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractBlock#clone()
+ */
+ @Override
+ public Block clone() {
+ return this;
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/SpecialSymbolBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/SpecialSymbolBlock.java
new file mode 100644
index 000000000..128b53d2d
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/SpecialSymbolBlock.java
@@ -0,0 +1,71 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represent a non-alphanumeric and non-space symbol (>, ]...).
+ *
+ * @version $Id$
+ * @since 1.5M2
+ */
+public class SpecialSymbolBlock extends AbstractBlock {
+
+ /**
+ * The symbol.
+ */
+ private char symbol;
+
+ /**
+ * @param symbol
+ * the symbol
+ */
+ public SpecialSymbolBlock(char symbol) {
+ this.symbol = symbol;
+ }
+
+ /**
+ * @return the symbol
+ */
+ public char getSymbol() {
+ return this.symbol;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.Block#traverse(org.xwiki.rendering.listener.Listener)
+ */
+ public void traverse(Listener listener) {
+ listener.onSpecialSymbol(getSymbol());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ * @since 1.8RC2
+ */
+ @Override
+ public String toString() {
+ return String.valueOf(getSymbol());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/TableBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/TableBlock.java
new file mode 100644
index 000000000..ef09b7653
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/TableBlock.java
@@ -0,0 +1,63 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.List;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents a table.
+ *
+ * @version $Id$
+ * @since 1.6M2
+ */
+public class TableBlock extends AbstractFatherBlock {
+
+ /**
+ * @param list
+ * the list of children blocks of the table block (generally a list of
+ * {@link TableRowBlock}).
+ * @param parameters
+ * the parameters of the table.
+ */
+ public TableBlock(List list, Map parameters) {
+ super(list, parameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginTable(getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endTable(getParameters());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/TableCellBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/TableCellBlock.java
new file mode 100644
index 000000000..9526c05e6
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/TableCellBlock.java
@@ -0,0 +1,62 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.List;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents a cell of a table.
+ *
+ * @version $Id$
+ * @since 1.6M2
+ */
+public class TableCellBlock extends AbstractFatherBlock {
+
+ /**
+ * @param list
+ * the list of children blocks of the table head cell block.
+ * @param parameters
+ * the parameters of the table row.
+ */
+ public TableCellBlock(List list, Map parameters) {
+ super(list, parameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginTableCell(getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endTableCell(getParameters());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/TableHeadCellBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/TableHeadCellBlock.java
new file mode 100644
index 000000000..62bbe628a
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/TableHeadCellBlock.java
@@ -0,0 +1,64 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.List;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents a head of a row or column of a table.
+ *
+ * @version $Id$
+ * @since 1.6M2
+ */
+public class TableHeadCellBlock extends TableCellBlock {
+
+ /**
+ * @param list
+ * the list of children blocks of the table cell block.
+ * @param parameters
+ * the parameters of the table head cell.
+ */
+ public TableHeadCellBlock(List list, Map parameters) {
+ super(list, parameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.TableCellBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ @Override
+ public void before(Listener listener) {
+ listener.beginTableHeadCell(getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.TableCellBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ @Override
+ public void after(Listener listener) {
+ listener.endTableHeadCell(getParameters());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/TableRowBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/TableRowBlock.java
new file mode 100644
index 000000000..c7ac7b99f
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/TableRowBlock.java
@@ -0,0 +1,63 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.List;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents the row of a table. Contains {@link TableCellBlock} objects.
+ *
+ * @version $Id$
+ * @since 1.6M2
+ */
+public class TableRowBlock extends AbstractFatherBlock {
+
+ /**
+ * @param list
+ * the list of children blocks of the table row block (generally a list of
+ * {@link TableCellBlock}).
+ * @param parameters
+ * the parameters of the table row.
+ */
+ public TableRowBlock(List list, Map parameters) {
+ super(list, parameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginTableRow(getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.FatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endTableRow(getParameters());
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/VerbatimBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/VerbatimBlock.java
new file mode 100644
index 000000000..c0fcde9d2
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/VerbatimBlock.java
@@ -0,0 +1,103 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import java.util.Map;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * A Verbatim block.
+ *
+ * @version $Id$
+ * @since 1.8M2
+ */
+public class VerbatimBlock extends AbstractBlock {
+
+ /**
+ * The string to protect from rendering.
+ */
+ private String protectedString;
+
+ /**
+ * If true the macro is located in a inline content (like paragraph, etc.).
+ */
+ private boolean isInline;
+
+ /**
+ * @param protectedString
+ * the string to protect from rendering.
+ * @param isInline
+ * if true the macro is located in a inline content (like paragraph, etc.).
+ */
+ public VerbatimBlock(String protectedString, boolean isInline) {
+ this.protectedString = protectedString;
+ this.isInline = isInline;
+ }
+
+ /**
+ * @param protectedString
+ * the string to protect from rendering.
+ * @param parameters
+ * the custom parameters
+ * @param isInline
+ * if true the macro is located in a inline content (like paragraph, etc.).
+ */
+ public VerbatimBlock(String protectedString, Map parameters, boolean isInline) {
+ super(parameters);
+
+ this.protectedString = protectedString;
+ this.isInline = isInline;
+ }
+
+ /**
+ * @return the string to protect from rendering
+ */
+ public String getProtectedString() {
+ return this.protectedString;
+ }
+
+ /**
+ * @return if true the macro is located in a inline content (like paragraph, etc.).
+ */
+ public boolean isInline() {
+ return this.isInline;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractBlock#traverse(org.xwiki.rendering.listener.Listener)
+ */
+ public void traverse(Listener listener) {
+ listener.onVerbatim(getProtectedString(), isInline(), getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ * @since 1.8RC2
+ */
+ @Override
+ public String toString() {
+ return getProtectedString();
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/WordBlock.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/WordBlock.java
new file mode 100644
index 000000000..f4baf4454
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/WordBlock.java
@@ -0,0 +1,73 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import org.xwiki.rendering.listener.Listener;
+
+/**
+ * Represents a word.
+ *
+ * @version $Id$
+ * @since 1.5M2
+ */
+public class WordBlock extends AbstractBlock {
+
+ /**
+ * @see #getWord()
+ */
+ private String word;
+
+ /**
+ * @param word
+ * the word wrapped by this block. Note that this is supposed to be a single word and
+ * space or special
+ * symbols should be represented by other blocks
+ */
+ public WordBlock(String word) {
+ this.word = word;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractBlock#traverse(Listener)
+ */
+ public void traverse(Listener listener) {
+ listener.onWord(getWord());
+ }
+
+ /**
+ * @return the word wrapped by this block
+ */
+ public String getWord() {
+ return this.word;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ * @since 1.8RC2
+ */
+ @Override
+ public String toString() {
+ return getWord();
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/XDOM.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/XDOM.java
new file mode 100644
index 000000000..b4a89712e
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/XDOM.java
@@ -0,0 +1,132 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.block;
+
+import org.xwiki.rendering.listener.Listener;
+import org.xwiki.rendering.util.IdGenerator;
+
+import java.util.List;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Contains the full tree of {@link Block} that represent a XWiki Document's content.
+ *
+ * @version $Id$
+ * @since 1.5M2
+ */
+public class XDOM extends AbstractFatherBlock {
+
+ /**
+ * Constructs an empty XDOM. Useful for example when calling a macro that doesn't use the XDOM
+ * parameter passed to
+ * it.
+ */
+ public static final XDOM EMPTY = new XDOM(Collections.emptyList());
+
+ /**
+ * Stateful id generator for this document. We store it in the XDOM because it is the only object
+ * which remains the
+ * same between parsing, transformation and rendering, and we need to generate ids during parsing
+ * and during
+ * transformation.
+ */
+ private IdGenerator idGenerator;
+
+ /**
+ * @param childBlocks
+ * the list of children blocks of the block to construct
+ * @param parameters
+ * the parameters to set
+ * @see AbstractFatherBlock#AbstractFatherBlock(List)
+ */
+ public XDOM(List childBlocks, Map parameters) {
+ super(childBlocks, parameters);
+
+ this.idGenerator = new IdGenerator();
+ }
+
+ /**
+ * @param childBlocks
+ * the list of children blocks of the block to construct
+ * @see AbstractFatherBlock#AbstractFatherBlock(List)
+ */
+ public XDOM(List childBlocks) {
+ super(childBlocks);
+
+ this.idGenerator = new IdGenerator();
+ }
+
+ /**
+ * @param childBlocks
+ * the list of children blocks of the block to construct
+ * @param idGenerator
+ * a sateful id generator for this document
+ */
+ public XDOM(List childBlocks, IdGenerator idGenerator) {
+ super(childBlocks);
+
+ this.idGenerator = idGenerator;
+ }
+
+ /**
+ * @return a stateful id generator for the whole document.
+ */
+ public IdGenerator getIdGenerator() {
+ return this.idGenerator;
+ }
+
+ /**
+ * @param idGenerator
+ * a stateful id generator for the whole document.
+ * @since 2.1M1
+ */
+ public void setIdGenerator(IdGenerator idGenerator) {
+ this.idGenerator = idGenerator;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractFatherBlock#before(org.xwiki.rendering.listener.Listener)
+ */
+ public void before(Listener listener) {
+ listener.beginDocument(getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractFatherBlock#after(org.xwiki.rendering.listener.Listener)
+ */
+ public void after(Listener listener) {
+ listener.endDocument(getParameters());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.AbstractBlock#clone()
+ */
+ @Override
+ public XDOM clone() {
+ return (XDOM) super.clone();
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/configuration/RenderingConfiguration.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/configuration/RenderingConfiguration.java
new file mode 100644
index 000000000..ce64c1753
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/configuration/RenderingConfiguration.java
@@ -0,0 +1,77 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.configuration;
+
+import org.xwiki.component.annotation.ComponentRole;
+import org.xwiki.rendering.transformation.Transformation;
+
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Configuration properties for the Rendering module.
+ *
+ * You can override the default values for each of the configuration properties below by defining
+ * them in XWiki's global
+ * configuration file using a prefix of "rendering" followed by the property name. For example:
+ * rendering.linkLabelFormat = %s.%p
+ *
+ * @version $Id$
+ * @since 1.6M1
+ */
+@ComponentRole
+public interface RenderingConfiguration {
+
+ /**
+ * A link label format is the format used to decide how to display links that have no label. By
+ * default the page
+ * name is displayed. However it's possible to customize it using the following tokens:
+ *
+ * - %w: wiki name
+ * - %s: space name
+ * - %p: page name
+ * - %P: page name with spaces between camel case words, i.e. "My Page" if the
+ * page name is
+ * "MyPage"
+ * - %t: page title
+ *
+ * Note that if the page title is empty or not defined then it defaults to %p. This is also the
+ * case if the title
+ * cannot be retrieved for the document. The default is "%p". Some examples: "%s.%p", "%w:%s.%p".
+ *
+ * @return the format to use to display link labels when the user hasn't specified a label
+ */
+ String getLinkLabelFormat();
+
+ /**
+ * @return the list of InterWiki definitions. Each InterWiki definition is made of an alias and a
+ * base URL.
+ * @see org.xwiki.rendering.listener.reference.InterWikiResourceReference
+ */
+ Properties getInterWikiDefinitions();
+
+ /**
+ * @return the list of transformations to execute when rendering document content, ordered by
+ * transformation
+ * priority (highest priority first)
+ * @since 2.6RC1
+ */
+ List getTransformations();
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/converter/ConversionException.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/converter/ConversionException.java
new file mode 100644
index 000000000..a4fec547d
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/converter/ConversionException.java
@@ -0,0 +1,60 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.converter;
+
+/**
+ * Encapsulate a conversion error.
+ *
+ * @version $Id$
+ * @since 2.0M3
+ */
+public class ConversionException extends Exception {
+
+ /**
+ * Class ID for serialization.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct a new ParseException with the specified detail message.
+ *
+ * @param message
+ * The detailed message. This can later be retrieved by the Throwable.getMessage()
+ * method.
+ */
+ public ConversionException(String message) {
+ super(message);
+ }
+
+ /**
+ * Construct a new ParseException with the specified detail message and cause.
+ *
+ * @param message
+ * The detailed message. This can later be retrieved by the Throwable.getMessage()
+ * method.
+ * @param throwable
+ * the cause. This can be retrieved later by the Throwable.getCause() method. (A null
+ * value is permitted,
+ * and indicates that the cause is nonexistent or unknown.)
+ */
+ public ConversionException(String message, Throwable throwable) {
+ super(message, throwable);
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/converter/Converter.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/converter/Converter.java
new file mode 100644
index 000000000..c023971ca
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/converter/Converter.java
@@ -0,0 +1,53 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.converter;
+
+import java.io.Reader;
+import org.xwiki.component.annotation.ComponentRole;
+import org.xwiki.rendering.syntax.Syntax;
+import org.xwiki.rendering.renderer.printer.WikiPrinter;
+
+/**
+ * Convert source content in a given Syntax to another Syntax.
+ *
+ * @version $Id$
+ * @since 2.0M3
+ */
+@ComponentRole
+public interface Converter {
+
+ /**
+ * Converts content from a Syntax to another and execute all registered Macro Transformations on
+ * the parsed content.
+ *
+ * @param source
+ * the content to be converted
+ * @param sourceSyntax
+ * the Syntax in which the content is represented
+ * @param targetSyntax
+ * the Syntax to which to convert to
+ * @param printer
+ * the printer that will receive the result of the conversion
+ * @throws ConversionException
+ * in case of a conversion error (invalid Syntax, etc)
+ */
+ void convert(Reader source, Syntax sourceSyntax, Syntax targetSyntax, WikiPrinter printer)
+ throws ConversionException;
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/block/ProtectedBlockFilter.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/block/ProtectedBlockFilter.java
new file mode 100644
index 000000000..1bd743982
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/block/ProtectedBlockFilter.java
@@ -0,0 +1,117 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.block;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xwiki.rendering.block.Block;
+import org.xwiki.rendering.block.BlockFilter;
+import org.xwiki.rendering.block.MacroMarkerBlock;
+
+/**
+ * Used to manipulate Blocks but by filtering out protected blocks.
+ *
+ * Note: This API is a work in progress and currently a protected block is a code macro marker
+ * block. In the future we
+ * need to make this more generic and since we also need to review Transformations to make them more
+ * performant this
+ * class may go away which is why it's currently located in an internal package.
+ *
+ *
+ * @version $Id$
+ * @since 2.6
+ */
+public class ProtectedBlockFilter implements BlockFilter {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.block.BlockFilter#filter(org.xwiki.rendering.block.Block)
+ */
+ public List filter(Block block) {
+ List blocks = new ArrayList();
+ if (!isProtectedBlock(block)) {
+ blocks.add(block);
+ }
+ return blocks;
+ }
+
+ /**
+ * @param blocks
+ * the blocks to filter
+ * @return the filtered blocks
+ */
+ public List filter(List blocks) {
+ List filteredBlocks = new ArrayList();
+ for (Block block : blocks) {
+ filteredBlocks.addAll(filter(block));
+ }
+ return filteredBlocks;
+ }
+
+ /**
+ * @param block
+ * the block to filter out
+ * @return the next sibling that is not a protected block or null if not found
+ */
+ public Block getNextSibling(Block block) {
+ Block sibling = block.getNextSibling();
+ while (sibling != null && isProtectedBlock(sibling)) {
+ sibling = sibling.getNextSibling();
+ }
+ return sibling;
+ }
+
+ /**
+ * @param block
+ * the block to filter out
+ * @param blockClass
+ * the type of Blocks to look for
+ * @param recurse
+ * if true also search recursively children
+ * @param
+ * the class of the Blocks to return
+ * @return the filtered blocks matching the passed Block class
+ */
+ public List getChildrenByType(Block block, Class blockClass,
+ boolean recurse) {
+ List typedBlocks = new ArrayList();
+ for (Block child : filter(block.getChildren())) {
+ if (blockClass.isAssignableFrom(child.getClass())) {
+ typedBlocks.add(blockClass.cast(child));
+ }
+ if (recurse && !child.getChildren().isEmpty()) {
+ typedBlocks.addAll(getChildrenByType(child, blockClass, true));
+ }
+ }
+
+ return typedBlocks;
+ }
+
+ /**
+ * @param block
+ * the block to test
+ * @return true if the passed block is a protected block or false otherwise
+ */
+ private boolean isProtectedBlock(Block block) {
+ return (block instanceof MacroMarkerBlock) && ((MacroMarkerBlock) block).getId().equals("code");
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/configuration/DefaultRenderingConfiguration.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/configuration/DefaultRenderingConfiguration.java
new file mode 100644
index 000000000..717e9a7af
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/configuration/DefaultRenderingConfiguration.java
@@ -0,0 +1,127 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.configuration;
+
+import org.xwiki.component.annotation.Component;
+import org.xwiki.component.annotation.Requirement;
+import org.xwiki.component.phase.Initializable;
+import org.xwiki.component.phase.InitializationException;
+import org.xwiki.rendering.configuration.RenderingConfiguration;
+import org.xwiki.rendering.transformation.Transformation;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Basic default implementation to be used when using the XWiki Rendering system standalone.
+ *
+ * @version $Id$
+ * @since 2.0M1
+ */
+@Component
+public class DefaultRenderingConfiguration implements RenderingConfiguration, Initializable {
+
+ /**
+ * Holds the list of transformations to apply, sorted by priority in {@link #initialize()}.
+ */
+ @Requirement
+ private List transformations = new ArrayList();
+
+ /**
+ * @see #getLinkLabelFormat()
+ */
+ private String linkLabelFormat = "%p";
+
+ /**
+ * @see #getInterWikiDefinitions()
+ */
+ private Properties interWikiDefinitions = new Properties();
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Initializable#initialize()
+ */
+ public void initialize() throws InitializationException {
+ // Sort transformations by priority.
+ Collections.sort(this.transformations);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.configuration.RenderingConfiguration#getLinkLabelFormat()
+ */
+ public String getLinkLabelFormat() {
+ return this.linkLabelFormat;
+ }
+
+ /**
+ * @param linkLabelFormat
+ * the format used to decide how to display links that have no label
+ */
+ public void setLinkLabelFormat(String linkLabelFormat) {
+ // This method is useful for those using the XWiki Rendering in standalone mode since it allows
+ // the rendering
+ // to work even without a configuration store.
+ this.linkLabelFormat = linkLabelFormat;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.configuration.RenderingConfiguration#getInterWikiDefinitions()
+ */
+ public Properties getInterWikiDefinitions() {
+ return this.interWikiDefinitions;
+ }
+
+ /**
+ * @param interWikiAlias
+ * see {@link org.xwiki.rendering.listener.reference.InterWikiResourceReference}
+ * @param interWikiURL
+ * see {@link org.xwiki.rendering.listener.reference.InterWikiResourceReference}
+ */
+ public void addInterWikiDefinition(String interWikiAlias, String interWikiURL) {
+ // This method is useful for those using the XWiki Rendering in standalone mode since it allows
+ // the rendering
+ // to work even without a configuration store.
+ this.interWikiDefinitions.setProperty(interWikiAlias, interWikiURL);
+ }
+
+ /**
+ * @param transformations
+ * the explicit list of transformations to execute (overrides the default list)
+ */
+ public void setTransformations(List transformations) {
+ this.transformations = transformations;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.configuration.RenderingConfiguration#getTransformations()
+ */
+ public List getTransformations() {
+ return this.transformations;
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/converter/DefaultConverter.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/converter/DefaultConverter.java
new file mode 100644
index 000000000..e60fec698
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/converter/DefaultConverter.java
@@ -0,0 +1,78 @@
+package org.xwiki.rendering.internal.converter;
+
+import java.io.Reader;
+import org.xwiki.component.annotation.Component;
+import org.xwiki.component.annotation.Requirement;
+import org.xwiki.component.manager.ComponentLookupException;
+import org.xwiki.component.manager.ComponentManager;
+import org.xwiki.rendering.block.XDOM;
+import org.xwiki.rendering.converter.ConversionException;
+import org.xwiki.rendering.converter.Converter;
+import org.xwiki.rendering.parser.ParseException;
+import org.xwiki.rendering.parser.Parser;
+import org.xwiki.rendering.syntax.Syntax;
+import org.xwiki.rendering.renderer.BlockRenderer;
+import org.xwiki.rendering.renderer.printer.WikiPrinter;
+import org.xwiki.rendering.transformation.TransformationContext;
+import org.xwiki.rendering.transformation.TransformationException;
+import org.xwiki.rendering.transformation.TransformationManager;
+
+/**
+ * Default implementation for {@link Converter}.
+ *
+ * @version $Id$
+ */
+@Component
+public class DefaultConverter implements Converter {
+
+ /**
+ * Used to lookup parser and renderer.
+ */
+ @Requirement
+ private ComponentManager componentManager;
+
+ /**
+ * Used to execute transformations.
+ */
+ @Requirement
+ private TransformationManager transformationManager;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.converter.Converter#convert(java.io.Reader,
+ * org.xwiki.rendering.syntax.Syntax,
+ * org.xwiki.rendering.syntax.Syntax, org.xwiki.rendering.renderer.printer.WikiPrinter)
+ */
+ public void convert(Reader source, Syntax sourceSyntax, Syntax targetSyntax, WikiPrinter printer)
+ throws ConversionException {
+ // Step 1: Find the parser and generate a XDOM
+ XDOM xdom;
+ try {
+ Parser parser = this.componentManager.lookup(Parser.class, sourceSyntax.toIdString());
+ xdom = parser.parse(source);
+ } catch (ComponentLookupException e) {
+ throw new ConversionException("Failed to locate Parser for syntax [" + sourceSyntax + "]", e);
+ } catch (ParseException e) {
+ throw new ConversionException("Failed to parse input source", e);
+ }
+
+ // Step 2: Run transformations
+ try {
+ TransformationContext context = new TransformationContext(xdom, sourceSyntax);
+ this.transformationManager.performTransformations(xdom, context);
+ } catch (TransformationException e) {
+ throw new ConversionException("Failed to execute some transformations", e);
+ }
+
+ // Step 3: Locate the Renderer and render the content in the passed printer
+ BlockRenderer renderer;
+ try {
+ renderer = this.componentManager.lookup(BlockRenderer.class, targetSyntax.toIdString());
+ } catch (ComponentLookupException e) {
+ throw new ConversionException("Failed to locate Renderer for syntax [" + targetSyntax + "]",
+ e);
+ }
+ renderer.render(xdom, printer);
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/AbstractBlockParser.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/AbstractBlockParser.java
new file mode 100644
index 000000000..37318c70e
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/AbstractBlockParser.java
@@ -0,0 +1,73 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.parser;
+
+import java.io.Reader;
+
+import org.xwiki.component.annotation.Requirement;
+import org.xwiki.component.manager.ComponentLookupException;
+import org.xwiki.component.manager.ComponentManager;
+import org.xwiki.rendering.block.XDOM;
+import org.xwiki.rendering.parser.ParseException;
+import org.xwiki.rendering.parser.Parser;
+import org.xwiki.rendering.parser.StreamParser;
+
+/**
+ * Common code for {@link Parser} implementation that produce a {@link XDOM} from
+ * {@link StreamParser}.
+ *
+ * @version $Id$
+ * @since 2.1M1
+ */
+public abstract class AbstractBlockParser implements Parser {
+
+ /**
+ * Used to lookup the {@link StreamParser} for the syntax.
+ */
+ @Requirement
+ private ComponentManager componentManager;
+
+ /**
+ * @return the {@link StreamParser} to use to parser the input content
+ */
+ protected StreamParser getStreamParser() {
+ StreamParser streamParser;
+ try {
+ streamParser = this.componentManager.lookup(StreamParser.class, getSyntax().toIdString());
+ } catch (ComponentLookupException e) {
+ throw new RuntimeException("Failed to create [" + getSyntax().toString() + "] renderer", e);
+ }
+
+ return streamParser;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.parser.Parser#parse(java.io.Reader)
+ */
+ public XDOM parse(Reader source) throws ParseException {
+ XDOMGeneratorListener listener = new XDOMGeneratorListener();
+
+ getStreamParser().parse(source, listener);
+
+ return listener.getXDOM();
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/PlainTextBlockParser.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/PlainTextBlockParser.java
new file mode 100644
index 000000000..d1d138e6e
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/PlainTextBlockParser.java
@@ -0,0 +1,42 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.parser;
+
+import org.xwiki.component.annotation.Component;
+import org.xwiki.rendering.syntax.Syntax;
+
+/**
+ * Plain Text Parser to convert a text source into a XDOM object.
+ *
+ * @version $Id$
+ * @since 2.1M1
+ */
+@Component("plain/1.0")
+public class PlainTextBlockParser extends AbstractBlockParser {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.parser.Parser#getSyntax()
+ */
+ public Syntax getSyntax() {
+ return Syntax.PLAIN_1_0;
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/PlainTextStreamParser.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/PlainTextStreamParser.java
new file mode 100644
index 000000000..28396d72d
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/PlainTextStreamParser.java
@@ -0,0 +1,129 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.parser;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.regex.Pattern;
+
+import org.xwiki.component.annotation.Component;
+import org.xwiki.rendering.listener.Listener;
+import org.xwiki.rendering.parser.ParseException;
+import org.xwiki.rendering.parser.StreamParser;
+import org.xwiki.rendering.syntax.Syntax;
+
+/**
+ * Plain Text Parser to convert a text source into a events.
+ *
+ * @version $Id$
+ * @since 2.1M1
+ */
+@Component("plain/1.0")
+public class PlainTextStreamParser implements StreamParser {
+
+ /**
+ * The characters which are considered as "special" symbols for
+ * {@link org.xwiki.rendering.block.SpecialSymbolBlock}
+ * .
+ */
+ public static final Pattern SPECIALSYMBOL_PATTERN = Pattern
+ .compile("[!\"#$%&'()*+,-./:;<=>?@\\[\\]^_`{|}~]");
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.parser.Parser#getSyntax()
+ */
+ public Syntax getSyntax() {
+ return Syntax.PLAIN_1_0;
+ }
+
+ /**
+ * Read a single char from an Reader source.
+ *
+ * @param source
+ * the input to read from
+ * @return the char read
+ * @throws ParseException
+ * in case of reading error
+ */
+ private int readChar(Reader source) throws ParseException {
+ int c;
+
+ try {
+ c = source.read();
+ } catch (IOException e) {
+ throw new ParseException("Failed to read input source", e);
+ }
+
+ return c;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.parser.StreamParser#parse(java.io.Reader,
+ * org.xwiki.rendering.listener.Listener)
+ */
+ public void parse(Reader source, Listener listener) throws ParseException {
+ StringBuffer word = new StringBuffer();
+ BufferedReader bufferedSource = new BufferedReader(source);
+ int charAsInt;
+
+ listener.beginParagraph(Listener.EMPTY_PARAMETERS);
+
+ while ((charAsInt = readChar(bufferedSource)) != -1) {
+ char c = (char) charAsInt;
+ if (c == '\n') {
+ if (word.length() > 0) {
+ listener.onWord(word.toString());
+ }
+ listener.onNewLine();
+
+ word.setLength(0);
+ } else if (c == '\r') {
+ // Do nothing, skip it
+ } else if (c == ' ') {
+ if (word.length() > 0) {
+ listener.onWord(word.toString());
+ }
+ listener.onSpace();
+
+ word.setLength(0);
+ } else if (SPECIALSYMBOL_PATTERN.matcher(String.valueOf(c)).matches()) {
+ if (word.length() > 0) {
+ listener.onWord(word.toString());
+ }
+ listener.onSpecialSymbol(c);
+
+ word.setLength(0);
+ } else {
+ word.append(c);
+ }
+ }
+
+ if (word.length() > 0) {
+ listener.onWord(word.toString());
+ }
+
+ listener.endParagraph(Listener.EMPTY_PARAMETERS);
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/XDOMGeneratorListener.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/XDOMGeneratorListener.java
new file mode 100644
index 000000000..5fccef087
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/XDOMGeneratorListener.java
@@ -0,0 +1,579 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.parser;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+
+import org.xwiki.rendering.block.AbstractBlock;
+import org.xwiki.rendering.block.Block;
+import org.xwiki.rendering.block.BulletedListBlock;
+import org.xwiki.rendering.block.DefinitionDescriptionBlock;
+import org.xwiki.rendering.block.DefinitionListBlock;
+import org.xwiki.rendering.block.DefinitionTermBlock;
+import org.xwiki.rendering.block.EmptyLinesBlock;
+import org.xwiki.rendering.block.FormatBlock;
+import org.xwiki.rendering.block.GroupBlock;
+import org.xwiki.rendering.block.HeaderBlock;
+import org.xwiki.rendering.block.HorizontalLineBlock;
+import org.xwiki.rendering.block.IdBlock;
+import org.xwiki.rendering.block.ImageBlock;
+import org.xwiki.rendering.block.LinkBlock;
+import org.xwiki.rendering.block.ListItemBlock;
+import org.xwiki.rendering.block.MacroBlock;
+import org.xwiki.rendering.block.MacroMarkerBlock;
+import org.xwiki.rendering.block.NewLineBlock;
+import org.xwiki.rendering.block.NumberedListBlock;
+import org.xwiki.rendering.block.ParagraphBlock;
+import org.xwiki.rendering.block.QuotationBlock;
+import org.xwiki.rendering.block.QuotationLineBlock;
+import org.xwiki.rendering.block.RawBlock;
+import org.xwiki.rendering.block.SectionBlock;
+import org.xwiki.rendering.block.SpaceBlock;
+import org.xwiki.rendering.block.SpecialSymbolBlock;
+import org.xwiki.rendering.block.TableBlock;
+import org.xwiki.rendering.block.TableCellBlock;
+import org.xwiki.rendering.block.TableHeadCellBlock;
+import org.xwiki.rendering.block.TableRowBlock;
+import org.xwiki.rendering.block.VerbatimBlock;
+import org.xwiki.rendering.block.WordBlock;
+import org.xwiki.rendering.block.XDOM;
+import org.xwiki.rendering.listener.Format;
+import org.xwiki.rendering.listener.HeaderLevel;
+import org.xwiki.rendering.listener.reference.ResourceReference;
+import org.xwiki.rendering.listener.ListType;
+import org.xwiki.rendering.listener.Listener;
+import org.xwiki.rendering.syntax.Syntax;
+
+/**
+ * Produce a {@link XDOM} based on events.
+ *
+ * @version $Id$
+ * @since 2.1M1
+ */
+public class XDOMGeneratorListener implements Listener {
+
+ private Stack stack = new Stack();
+
+ private final MarkerBlock marker = new MarkerBlock();
+
+ private static class MarkerBlock extends AbstractBlock {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractBlock#traverse(Listener)
+ */
+ public void traverse(Listener listener) {
+ // Nothing to do since this block is only used as a marker.
+ }
+ }
+
+ public XDOM getXDOM() {
+ return new XDOM(generateListFromStack());
+ }
+
+ private List generateListFromStack() {
+ List blocks = new ArrayList();
+ while (!this.stack.empty()) {
+ if (this.stack.peek() != this.marker) {
+ blocks.add(this.stack.pop());
+ } else {
+ this.stack.pop();
+ break;
+ }
+ }
+ Collections.reverse(blocks);
+ return blocks;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginDefinitionDescription()
+ */
+ public void beginDefinitionDescription() {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginDefinitionList(java.util.Map)
+ */
+ public void beginDefinitionList(Map parameters) {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginDefinitionTerm()
+ */
+ public void beginDefinitionTerm() {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginDocument(java.util.Map)
+ */
+ public void beginDocument(Map parameters) {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginFormat(org.xwiki.rendering.listener.Format,
+ * java.util.Map)
+ */
+ public void beginFormat(Format format, Map parameters) {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginGroup(java.util.Map)
+ */
+ public void beginGroup(Map parameters) {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginHeader(org.xwiki.rendering.listener.HeaderLevel,
+ * java.lang.String, java.util.Map)
+ */
+ public void beginHeader(HeaderLevel level, String id, Map parameters) {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginList(org.xwiki.rendering.listener.ListType,
+ * java.util.Map)
+ */
+ public void beginList(ListType listType, Map parameters) {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginListItem()
+ */
+ public void beginListItem() {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginMacroMarker(java.lang.String, java.util.Map,
+ * java.lang.String,
+ * boolean)
+ */
+ public void beginMacroMarker(String name, Map macroParameters, String content,
+ boolean isInline) {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginParagraph(java.util.Map)
+ */
+ public void beginParagraph(Map parameters) {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginQuotation(java.util.Map)
+ */
+ public void beginQuotation(Map parameters) {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginQuotationLine()
+ */
+ public void beginQuotationLine() {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginSection(java.util.Map)
+ */
+ public void beginSection(Map parameters) {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginTable(java.util.Map)
+ */
+ public void beginTable(Map parameters) {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginTableCell(java.util.Map)
+ */
+ public void beginTableCell(Map parameters) {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginTableHeadCell(java.util.Map)
+ */
+ public void beginTableHeadCell(Map parameters) {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginTableRow(java.util.Map)
+ */
+ public void beginTableRow(Map parameters) {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.LinkListener#beginLink(org.xwiki.rendering.listener.reference.ResourceReference
+ * , boolean, java.util.Map)
+ */
+ public void beginLink(ResourceReference reference, boolean isFreeStandingURI,
+ Map parameters) {
+ this.stack.push(this.marker);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endDefinitionDescription()
+ */
+ public void endDefinitionDescription() {
+ this.stack.push(new DefinitionDescriptionBlock(generateListFromStack()));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endDefinitionList(java.util.Map)
+ */
+ public void endDefinitionList(Map parameters) {
+ this.stack.push(new DefinitionListBlock(generateListFromStack(), parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endDefinitionTerm()
+ */
+ public void endDefinitionTerm() {
+ this.stack.push(new DefinitionTermBlock(generateListFromStack()));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endDocument(java.util.Map)
+ */
+ public void endDocument(Map parameters) {
+ // Do nothing. This is supposed to append only once for the hole document
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endFormat(org.xwiki.rendering.listener.Format,
+ * java.util.Map)
+ */
+ public void endFormat(Format format, Map parameters) {
+ this.stack.push(new FormatBlock(generateListFromStack(), format, parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endGroup(java.util.Map)
+ */
+ public void endGroup(Map parameters) {
+ this.stack.push(new GroupBlock(generateListFromStack(), parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endHeader(org.xwiki.rendering.listener.HeaderLevel,
+ * java.lang.String,
+ * java.util.Map)
+ */
+ public void endHeader(HeaderLevel level, String id, Map parameters) {
+ this.stack.push(new HeaderBlock(generateListFromStack(), level, parameters, id));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endList(org.xwiki.rendering.listener.ListType,
+ * java.util.Map)
+ */
+ public void endList(ListType listType, Map parameters) {
+ if (listType == ListType.BULLETED) {
+ this.stack.push(new BulletedListBlock(generateListFromStack(), parameters));
+ } else {
+ this.stack.push(new NumberedListBlock(generateListFromStack(), parameters));
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endListItem()
+ */
+ public void endListItem() {
+ this.stack.push(new ListItemBlock(generateListFromStack()));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endMacroMarker(java.lang.String, java.util.Map,
+ * java.lang.String,
+ * boolean)
+ */
+ public void endMacroMarker(String name, Map macroParameters, String content,
+ boolean isInline) {
+ this.stack.push(
+ new MacroMarkerBlock(name, macroParameters, content, generateListFromStack(), isInline));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endParagraph(java.util.Map)
+ */
+ public void endParagraph(Map parameters) {
+ this.stack.push(new ParagraphBlock(generateListFromStack(), parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endQuotation(java.util.Map)
+ */
+ public void endQuotation(Map parameters) {
+ this.stack.push(new QuotationBlock(generateListFromStack(), parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endQuotationLine()
+ */
+ public void endQuotationLine() {
+ this.stack.push(new QuotationLineBlock(generateListFromStack()));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endSection(java.util.Map)
+ */
+ public void endSection(Map parameters) {
+ this.stack.push(new SectionBlock(generateListFromStack(), parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endTable(java.util.Map)
+ */
+ public void endTable(Map parameters) {
+ this.stack.push(new TableBlock(generateListFromStack(), parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endTableCell(java.util.Map)
+ */
+ public void endTableCell(Map parameters) {
+ this.stack.push(new TableCellBlock(generateListFromStack(), parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endTableHeadCell(java.util.Map)
+ */
+ public void endTableHeadCell(Map parameters) {
+ this.stack.push(new TableHeadCellBlock(generateListFromStack(), parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#endTableRow(java.util.Map)
+ */
+ public void endTableRow(Map parameters) {
+ this.stack.push(new TableRowBlock(generateListFromStack(), parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.LinkListener#endLink(org.xwiki.rendering.listener.reference.ResourceReference
+ * ,
+ * boolean, java.util.Map)
+ */
+ public void endLink(ResourceReference reference, boolean isFreeStandingURI,
+ Map parameters) {
+ this.stack
+ .push(new LinkBlock(generateListFromStack(), reference, isFreeStandingURI, parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#onEmptyLines(int)
+ */
+ public void onEmptyLines(int count) {
+ this.stack.push(new EmptyLinesBlock(count));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#onHorizontalLine(java.util.Map)
+ */
+ public void onHorizontalLine(Map parameters) {
+ this.stack.push(new HorizontalLineBlock(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#onId(java.lang.String)
+ */
+ public void onId(String name) {
+ this.stack.push(new IdBlock(name));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#onMacro(java.lang.String, java.util.Map,
+ * java.lang.String, boolean)
+ */
+ public void onMacro(String id, Map macroParameters, String content,
+ boolean isInline) {
+ this.stack.push(new MacroBlock(id, macroParameters, content, isInline));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#onNewLine()
+ */
+ public void onNewLine() {
+ this.stack.push(new NewLineBlock());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#onRawText(java.lang.String,
+ * org.xwiki.rendering.syntax.Syntax)
+ */
+ public void onRawText(String rawContent, Syntax syntax) {
+ this.stack.push(new RawBlock(rawContent, syntax));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#onSpace()
+ */
+ public void onSpace() {
+ this.stack.push(new SpaceBlock());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#onSpecialSymbol(char)
+ */
+ public void onSpecialSymbol(char symbol) {
+ this.stack.push(new SpecialSymbolBlock(symbol));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#onVerbatim(java.lang.String, boolean, java.util.Map)
+ */
+ public void onVerbatim(String protectedString, boolean isInline, Map parameters) {
+ this.stack.push(new VerbatimBlock(protectedString, parameters, isInline));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#onWord(java.lang.String)
+ */
+ public void onWord(String word) {
+ this.stack.push(new WordBlock(word));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.ImageListener#onImage(org.xwiki.rendering.listener.reference.ResourceReference
+ * , boolean, java.util.Map)
+ */
+ public void onImage(ResourceReference reference, boolean isFreeStandingURI,
+ Map parameters) {
+ this.stack.push(new ImageBlock(reference, isFreeStandingURI, parameters));
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/AbstractBlockRenderer.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/AbstractBlockRenderer.java
new file mode 100644
index 000000000..bf698e30b
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/AbstractBlockRenderer.java
@@ -0,0 +1,65 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.renderer;
+
+import java.util.Collection;
+import java.util.Collections;
+import org.xwiki.rendering.block.Block;
+import org.xwiki.rendering.renderer.BlockRenderer;
+import org.xwiki.rendering.renderer.PrintRendererFactory;
+import org.xwiki.rendering.renderer.printer.WikiPrinter;
+import org.xwiki.rendering.renderer.PrintRenderer;
+
+/**
+ * Common code for BlockRender implementation that uses Print Renderer Factory.
+ *
+ * @version $Id$
+ * @since 2.0M3
+ */
+public abstract class AbstractBlockRenderer implements BlockRenderer {
+
+ /**
+ * @return provide the factory to use to create a new {@link PrintRenderer}.
+ */
+ protected abstract PrintRendererFactory getPrintRendererFactory();
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see BlockRenderer#render(org.xwiki.rendering.block.Block,
+ * org.xwiki.rendering.renderer.printer.WikiPrinter)
+ */
+ public void render(Block block, WikiPrinter printer) {
+ render(Collections.singletonList(block), printer);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see BlockRenderer#render(java.util.Collection,
+ * org.xwiki.rendering.renderer.printer.WikiPrinter)
+ */
+ public void render(Collection blocks, WikiPrinter printer) {
+ PrintRenderer renderer = getPrintRendererFactory().createRenderer(printer);
+ for (Block block : blocks) {
+ block.traverse(renderer);
+ }
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/AbstractPrintRendererFactory.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/AbstractPrintRendererFactory.java
new file mode 100644
index 000000000..37d4b5566
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/AbstractPrintRendererFactory.java
@@ -0,0 +1,62 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.renderer;
+
+import org.xwiki.component.annotation.Requirement;
+import org.xwiki.component.manager.ComponentLookupException;
+import org.xwiki.component.manager.ComponentManager;
+import org.xwiki.rendering.renderer.PrintRenderer;
+import org.xwiki.rendering.renderer.PrintRendererFactory;
+import org.xwiki.rendering.renderer.printer.WikiPrinter;
+
+/**
+ * Common code for {@link org.xwiki.rendering.renderer.PrintRendererFactory}, implements the logic
+ * to lookup and call
+ * the matching Print Renderer.
+ *
+ * @version $Id$
+ * @since 2.0M3
+ */
+public abstract class AbstractPrintRendererFactory implements PrintRendererFactory {
+
+ /**
+ * Used to lookup the {@link PrintRenderer}.
+ */
+ @Requirement
+ private ComponentManager componentManager;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see PrintRendererFactory#createRenderer(org.xwiki.rendering.renderer.printer.WikiPrinter)
+ */
+ public PrintRenderer createRenderer(WikiPrinter printer) {
+ PrintRenderer renderer;
+ try {
+ renderer = this.componentManager.lookup(PrintRenderer.class, getSyntax().toIdString());
+ } catch (ComponentLookupException e) {
+ throw new RuntimeException("Failed to create [" + getSyntax().toString() + "] renderer", e);
+ }
+
+ renderer.setPrinter(printer);
+
+ return renderer;
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/DefaultAttachmentURILabelGenerator.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/DefaultAttachmentURILabelGenerator.java
new file mode 100644
index 000000000..d5260a675
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/DefaultAttachmentURILabelGenerator.java
@@ -0,0 +1,44 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.renderer;
+
+import org.xwiki.component.annotation.Component;
+import org.xwiki.rendering.listener.reference.ResourceReference;
+import org.xwiki.rendering.renderer.reference.link.URILabelGenerator;
+
+/**
+ * Generate link labels for ATTACH URIs.
+ *
+ * @version $Id: DefaultAttachmentURILabelGenerator.java 31386 2010-09-27 09:42:32Z vmassol $
+ * @since 2.5RC1
+ */
+@Component("attach")
+public class DefaultAttachmentURILabelGenerator implements URILabelGenerator {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.reference.link.URILabelGenerator#generateLabel(
+ * org.xwiki.rendering.listener.reference.ResourceReference)
+ */
+ public String generateLabel(ResourceReference reference) {
+ return reference.getReference();
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/DefaultLinkLabelGenerator.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/DefaultLinkLabelGenerator.java
new file mode 100644
index 000000000..a9b0359f6
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/DefaultLinkLabelGenerator.java
@@ -0,0 +1,46 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.renderer;
+
+import org.xwiki.component.annotation.Component;
+import org.xwiki.rendering.listener.reference.ResourceReference;
+import org.xwiki.rendering.renderer.reference.link.LinkLabelGenerator;
+
+/**
+ * Basic default implementation to be used when the XWiki Rendering is used standalone, outside of
+ * XWiki.
+ *
+ * @version $Id$
+ * @since 2.0M1
+ */
+@Component
+public class DefaultLinkLabelGenerator implements LinkLabelGenerator {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.reference.link.LinkLabelGenerator#generate(
+ * org.xwiki.rendering.listener.reference.ResourceReference)
+ * @since 2.5RC1
+ */
+ public String generate(ResourceReference reference) {
+ return reference.getReference();
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/MailtoURILabelGenerator.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/MailtoURILabelGenerator.java
new file mode 100644
index 000000000..953b7ea30
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/MailtoURILabelGenerator.java
@@ -0,0 +1,46 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.renderer;
+
+import org.apache.commons.lang.StringUtils;
+import org.xwiki.component.annotation.Component;
+import org.xwiki.rendering.listener.reference.ResourceReference;
+import org.xwiki.rendering.renderer.reference.link.URILabelGenerator;
+
+/**
+ * Generate link labels for MAILTO URIs.
+ *
+ * @version $Id$
+ * @since 2.2RC1
+ */
+@Component("mailto")
+public class MailtoURILabelGenerator implements URILabelGenerator {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.reference.link.URILabelGenerator#generateLabel(
+ * org.xwiki.rendering.listener.reference.ResourceReference)
+ */
+ public String generateLabel(ResourceReference reference) {
+ // Remove the query string (if any).
+ return StringUtils.substringBefore(reference.getReference(), "?");
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/ParametersPrinter.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/ParametersPrinter.java
new file mode 100644
index 000000000..488bf5c2e
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/ParametersPrinter.java
@@ -0,0 +1,83 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.renderer;
+
+import java.util.Map;
+
+/**
+ * Generates syntax for a parameters group like macros and links.
+ *
+ * @version $Id$
+ * @since 1.9RC2
+ */
+public class ParametersPrinter {
+
+ /**
+ * Quote character.
+ */
+ private static final String QUOTE = "\"";
+
+ /**
+ * Print the parameters as a String.
+ *
+ * @param parameters
+ * the parameters to print
+ * @param escapeChar
+ * the character used in front of a special character when need to escape it
+ * @return the printed parameters
+ */
+ public String print(Map parameters, char escapeChar) {
+ StringBuffer buffer = new StringBuffer();
+ for (Map.Entry entry : parameters.entrySet()) {
+ String value = entry.getValue();
+ String key = entry.getKey();
+
+ if (key != null && value != null) {
+ if (buffer.length() > 0) {
+ buffer.append(' ');
+ }
+ buffer.append(print(key, value, escapeChar));
+ }
+ }
+
+ return buffer.toString();
+ }
+
+ /**
+ * Print a parameter as a String.
+ *
+ * @param parameterName
+ * the name of the parameter to print
+ * @param parameterValue
+ * the value of the parameter to print
+ * @param escapeChar
+ * the character used in front of a special character when need to escape it
+ * @return the printed parameter
+ */
+ public String print(String parameterName, String parameterValue, char escapeChar) {
+ // escape the escaping character
+ String value = parameterValue.replace(String.valueOf(escapeChar),
+ String.valueOf(escapeChar) + escapeChar);
+ // escape quote
+ value = value.replace(QUOTE, String.valueOf(escapeChar) + QUOTE);
+
+ return parameterName + "=" + QUOTE + value + QUOTE;
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/event/EventBlockRenderer.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/event/EventBlockRenderer.java
new file mode 100644
index 000000000..71410a398
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/event/EventBlockRenderer.java
@@ -0,0 +1,37 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.renderer.event;
+
+import org.xwiki.component.annotation.Component;
+import org.xwiki.component.annotation.Requirement;
+import org.xwiki.rendering.internal.renderer.AbstractBlockRenderer;
+import org.xwiki.rendering.renderer.PrintRendererFactory;
+
+@Component("event/1.0")
+public class EventBlockRenderer extends AbstractBlockRenderer {
+
+ @Requirement("event/1.0")
+ private PrintRendererFactory eventRendererFactory;
+
+ @Override
+ protected PrintRendererFactory getPrintRendererFactory() {
+ return this.eventRendererFactory;
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/event/EventRenderer.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/event/EventRenderer.java
new file mode 100644
index 000000000..01a39a00e
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/event/EventRenderer.java
@@ -0,0 +1,59 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.renderer.event;
+
+import org.xwiki.component.annotation.Component;
+import org.xwiki.component.annotation.InstantiationStrategy;
+import org.xwiki.component.descriptor.ComponentInstantiationStrategy;
+import org.xwiki.component.phase.Initializable;
+import org.xwiki.component.phase.InitializationException;
+import org.xwiki.rendering.listener.chaining.ListenerChain;
+import org.xwiki.rendering.renderer.AbstractChainingPrintRenderer;
+
+/**
+ * Print names of events. Useful for debugging and tracing in general. Note that this class is not
+ * located in the test
+ * source tree since it's currently used at runtime by the WYSIWYG editor for its runtime debug
+ * mode.
+ *
+ * @version $Id$
+ * @since 2.0M3
+ */
+@Component("event/1.0")
+@InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
+public class EventRenderer extends AbstractChainingPrintRenderer implements Initializable {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Initializable#initialize()
+ * @since 2.0M3
+ */
+ public void initialize() throws InitializationException {
+ ListenerChain chain = new ListenerChain();
+ setListenerChain(chain);
+
+ // Construct the listener chain in the right order. Listeners early in the chain are called
+ // before listeners
+ // placed later in the chain.
+ chain.addListener(this);
+ chain.addListener(new EventsChainingRenderer(chain));
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/event/EventRendererFactory.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/event/EventRendererFactory.java
new file mode 100644
index 000000000..80a3506ad
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/event/EventRendererFactory.java
@@ -0,0 +1,43 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.renderer.event;
+
+import org.xwiki.rendering.internal.renderer.*;
+import org.xwiki.component.annotation.Component;
+import org.xwiki.rendering.syntax.Syntax;
+
+/**
+ * Create XHTML Renderers.
+ *
+ * @version $Id$
+ * @since 2.0M3
+ */
+@Component("event/1.0")
+public class EventRendererFactory extends AbstractPrintRendererFactory {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractPrintRendererFactory#getSyntax()
+ */
+ public Syntax getSyntax() {
+ return Syntax.EVENT_1_0;
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/event/EventsChainingRenderer.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/event/EventsChainingRenderer.java
new file mode 100644
index 000000000..326ad800b
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/event/EventsChainingRenderer.java
@@ -0,0 +1,651 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.renderer.event;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.lang.StringUtils;
+import org.xwiki.rendering.listener.Format;
+import org.xwiki.rendering.listener.HeaderLevel;
+import org.xwiki.rendering.listener.reference.ResourceReference;
+import org.xwiki.rendering.listener.ListType;
+import org.xwiki.rendering.listener.chaining.ListenerChain;
+import org.xwiki.rendering.syntax.Syntax;
+import org.xwiki.rendering.renderer.AbstractChainingPrintRenderer;
+
+/**
+ * Prints listener event names in a format useful for testing and debugging.
+ *
+ * @version $Id$
+ * @since 1.8RC1
+ */
+public class EventsChainingRenderer extends AbstractChainingPrintRenderer {
+
+ public EventsChainingRenderer(ListenerChain listenerChain) {
+ setListenerChain(listenerChain);
+ }
+
+ // Events
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.chaining.AbstractChainingListener#beginDocument(java.util.Map)
+ */
+ @Override
+ public void beginDocument(Map parameters) {
+ getPrinter().println("beginDocument" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.chaining.AbstractChainingListener#endDocument(java.util.Map)
+ */
+ @Override
+ public void endDocument(Map parameters) {
+ getPrinter().print("endDocument" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.chaining.AbstractChainingListener#beginGroup(Map)
+ */
+ @Override
+ public void beginGroup(Map parameters) {
+ getPrinter().println("beginGroup" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.chaining.AbstractChainingListener#endGroup(Map)
+ */
+ @Override
+ public void endGroup(Map parameters) {
+ getPrinter().println("endGroup" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginFormat(org.xwiki.rendering.listener.Format,
+ * java.util.Map)
+ */
+ @Override
+ public void beginFormat(Format format, Map parameters) {
+ getPrinter().println("beginFormat [" + format + "]" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endFormat(org.xwiki.rendering.listener.Format,
+ * java.util.Map)
+ */
+ @Override
+ public void endFormat(Format format, Map parameters) {
+ getPrinter().println("endFormat [" + format + "]" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginParagraph(java.util.Map)
+ */
+ @Override
+ public void beginParagraph(Map parameters) {
+ getPrinter().println("beginParagraph" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endParagraph(java.util.Map)
+ */
+ @Override
+ public void endParagraph(Map parameters) {
+ getPrinter().println("endParagraph" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onNewLine()
+ */
+ @Override
+ public void onNewLine() {
+ getPrinter().println("onNewLine");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginLink(
+ * org.xwiki.rendering.listener.reference.ResourceReference , boolean, java.util.Map)
+ */
+ @Override
+ public void beginLink(ResourceReference reference, boolean isFreeStandingURI,
+ Map parameters) {
+ getPrinter()
+ .println("beginLink [" + reference + "] [" + isFreeStandingURI + "]"
+ + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endLink(
+ * org.xwiki.rendering.listener.reference.ResourceReference , boolean, java.util.Map)
+ */
+ @Override
+ public void endLink(ResourceReference reference, boolean isFreeStandingURI,
+ Map parameters) {
+ getPrinter()
+ .println("endLink [" + reference + "] [" + isFreeStandingURI + "]"
+ + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onMacro(java.lang.String,
+ * java.util.Map,
+ * java.lang.String, boolean)
+ */
+ @Override
+ public void onMacro(String id, Map parameters, String content, boolean isInline) {
+ printMacroData("onMacro", id, parameters, content, isInline);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginSection(java.util.Map)
+ */
+ @Override
+ public void beginSection(Map parameters) {
+ getPrinter().println("beginSection" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginHeader(org.xwiki.rendering.listener.HeaderLevel,
+ * String, java.util.Map)
+ */
+ @Override
+ public void beginHeader(HeaderLevel level, String id, Map parameters) {
+ getPrinter()
+ .println("beginHeader [" + level + ", " + id + "]" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endSection(java.util.Map)
+ */
+ @Override
+ public void endSection(Map parameters) {
+ getPrinter().println("endSection" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endHeader(
+ * org.xwiki.rendering.listener.HeaderLevel, String, java.util.Map)
+ */
+ @Override
+ public void endHeader(HeaderLevel level, String id, Map parameters) {
+ getPrinter().println("endHeader [" + level + ", " + id + "]" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onWord(java.lang.String)
+ */
+ @Override
+ public void onWord(String word) {
+ getPrinter().println("onWord [" + getEscaped(word) + "]");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginList(org.xwiki.rendering.listener.ListType,
+ * java.util.Map)
+ */
+ @Override
+ public void beginList(ListType listType, Map parameters) {
+ getPrinter().println("beginList [" + listType + "]" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginListItem()
+ */
+ @Override
+ public void beginListItem() {
+ getPrinter().println("beginListItem");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endList(org.xwiki.rendering.listener.ListType,
+ * java.util.Map)
+ */
+ @Override
+ public void endList(ListType listType, Map parameters) {
+ getPrinter().println("endList [" + listType + "]" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endListItem()
+ */
+ @Override
+ public void endListItem() {
+ getPrinter().println("endListItem");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onSpace()
+ */
+ @Override
+ public void onSpace() {
+ getPrinter().println("onSpace");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onSpecialSymbol(char)
+ */
+ @Override
+ public void onSpecialSymbol(char symbol) {
+ getPrinter().println("onSpecialSymbol [" + symbol + "]");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onRawText(String, Syntax)
+ */
+ @Override
+ public void onRawText(String text, Syntax syntax) {
+ getPrinter().println("onRawText [" + text + "] [" + syntax.toIdString() + "]");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginMacroMarker(java.lang.String,
+ * java.util.Map,
+ * java.lang.String, boolean)
+ */
+ @Override
+ public void beginMacroMarker(String name, Map parameters, String content,
+ boolean isInline) {
+ printMacroData("beginMacroMarker", name, parameters, content, isInline);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endMacroMarker(java.lang.String,
+ * java.util.Map,
+ * java.lang.String, boolean)
+ */
+ @Override
+ public void endMacroMarker(String name, Map parameters, String content,
+ boolean isInline) {
+ printMacroData("endMacroMarker", name, parameters, content, isInline);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onId(java.lang.String)
+ */
+ @Override
+ public void onId(String name) {
+ getPrinter().println("onId [" + name + "]");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onHorizontalLine(java.util.Map)
+ */
+ @Override
+ public void onHorizontalLine(Map parameters) {
+ getPrinter().println("onHorizontalLine" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onEmptyLines(int)
+ */
+ @Override
+ public void onEmptyLines(int count) {
+ getPrinter().println("onEmptyLines [" + count + "]");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onVerbatim(String, boolean,
+ * Map)
+ */
+ @Override
+ public void onVerbatim(String protectedString, boolean isInline, Map parameters) {
+ getPrinter()
+ .println("onVerbatim [" + protectedString + "] [" + isInline + "]"
+ + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginDefinitionList(java.util.Map)
+ * @since 2.0RC1
+ */
+ @Override
+ public void beginDefinitionList(Map parameters) {
+ getPrinter().println("beginDefinitionList" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endDefinitionList(java.util.Map)
+ * @since 2.0RC1
+ */
+ @Override
+ public void endDefinitionList(Map parameters) {
+ getPrinter().println("endDefinitionList" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginDefinitionTerm()
+ */
+ @Override
+ public void beginDefinitionTerm() {
+ getPrinter().println("beginDefinitionTerm");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginDefinitionDescription()
+ */
+ @Override
+ public void beginDefinitionDescription() {
+ getPrinter().println("beginDefinitionDescription");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endDefinitionTerm()
+ */
+ @Override
+ public void endDefinitionTerm() {
+ getPrinter().println("endDefinitionTerm");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endDefinitionDescription()
+ */
+ @Override
+ public void endDefinitionDescription() {
+ getPrinter().println("endDefinitionDescription");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginQuotation(java.util.Map)
+ */
+ @Override
+ public void beginQuotation(Map parameters) {
+ getPrinter().println("beginQuotation" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endQuotation(java.util.Map)
+ */
+ @Override
+ public void endQuotation(Map parameters) {
+ getPrinter().println("endQuotation" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginQuotationLine()
+ */
+ @Override
+ public void beginQuotationLine() {
+ getPrinter().println("beginQuotationLine");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endQuotationLine()
+ */
+ @Override
+ public void endQuotationLine() {
+ getPrinter().println("endQuotationLine");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginTable(java.util.Map)
+ */
+ @Override
+ public void beginTable(Map parameters) {
+ getPrinter().println("beginTable" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginTableCell(java.util.Map)
+ */
+ @Override
+ public void beginTableCell(Map parameters) {
+ getPrinter().println("beginTableCell" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginTableHeadCell(java.util.Map)
+ */
+ @Override
+ public void beginTableHeadCell(Map parameters) {
+ getPrinter().println("beginTableHeadCell" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginTableRow(java.util.Map)
+ */
+ @Override
+ public void beginTableRow(Map parameters) {
+ getPrinter().println("beginTableRow" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endTable(java.util.Map)
+ */
+ @Override
+ public void endTable(Map parameters) {
+ getPrinter().println("endTable" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endTableCell(java.util.Map)
+ */
+ @Override
+ public void endTableCell(Map parameters) {
+ getPrinter().println("endTableCell" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endTableHeadCell(java.util.Map)
+ */
+ @Override
+ public void endTableHeadCell(Map parameters) {
+ getPrinter().println("endTableHeadCell" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#endTableRow(java.util.Map)
+ */
+ @Override
+ public void endTableRow(Map parameters) {
+ getPrinter().println("endTableRow" + serializeParameters(parameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onImage(
+ * org.xwiki.rendering.listener.reference.ResourceReference , boolean, java.util.Map)
+ * @since 2.5RC1
+ */
+ @Override
+ public void onImage(ResourceReference reference, boolean isFreeStandingURI,
+ Map parameters) {
+ getPrinter()
+ .println("onImage [" + reference + "] [" + isFreeStandingURI + "]"
+ + serializeParameters(parameters));
+ }
+
+ public String getEscaped(String str) {
+ String printableStr;
+
+ if (str == null) {
+ printableStr = null;
+ } else if (StringUtils.isAsciiPrintable(str)) {
+ printableStr = str;
+ } else {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < str.length(); i++) {
+ char c = str.charAt(i);
+ if (c > 126) {
+ buffer.append("(((").append((int) c).append(")))");
+ } else {
+ buffer.append(c);
+ }
+ }
+ printableStr = buffer.toString();
+ }
+
+ return printableStr;
+ }
+
+ private void printMacroData(String eventName, String name, Map parameters,
+ String content,
+ boolean isInline) {
+ StringBuffer parametersBuffer = new StringBuffer();
+ for (Iterator paramsIt = parameters.keySet().iterator(); paramsIt.hasNext();) {
+ String paramName = paramsIt.next();
+ parametersBuffer.append(paramName).append("=").append(parameters.get(paramName));
+ if (paramsIt.hasNext()) {
+ parametersBuffer.append("|");
+ }
+ }
+
+ StringBuffer macroBuffer = new StringBuffer();
+
+ macroBuffer.append(eventName);
+ macroBuffer.append(isInline ? "Inline" : "Standalone");
+
+ macroBuffer.append(" [");
+ macroBuffer.append(name);
+ macroBuffer.append("]");
+
+ macroBuffer.append(" [");
+ macroBuffer.append(parametersBuffer);
+ macroBuffer.append("]");
+
+ if (content != null) {
+ macroBuffer.append(" [");
+ macroBuffer.append(content);
+ macroBuffer.append("]");
+ }
+
+ getPrinter().println(macroBuffer.toString());
+ }
+
+ private String serializeParameters(Map parameters) {
+ StringBuffer parametersStr = new StringBuffer();
+ for (Map.Entry entry : parameters.entrySet()) {
+ String value = entry.getValue();
+ String key = entry.getKey();
+
+ if (key != null && value != null) {
+ parametersStr.append('[').append(getEscaped(entry.getKey())).append(']').append('=')
+ .append('[')
+ .append(getEscaped(entry.getValue())).append(']');
+ }
+ }
+
+ if (parametersStr.length() > 0) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(' ').append('[');
+ buffer.append(parametersStr);
+ buffer.append(']');
+ return buffer.toString();
+ } else {
+ return "";
+ }
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/plain/PlainTextBlockRenderer.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/plain/PlainTextBlockRenderer.java
new file mode 100644
index 000000000..5586010a1
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/plain/PlainTextBlockRenderer.java
@@ -0,0 +1,55 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.renderer.plain;
+
+import org.xwiki.component.annotation.Component;
+import org.xwiki.component.annotation.Requirement;
+import org.xwiki.rendering.internal.renderer.AbstractBlockRenderer;
+import org.xwiki.rendering.renderer.PrintRendererFactory;
+
+/**
+ * Print only plain text information. For example it remove anything which need a specific syntax a
+ * simple plain text
+ * editor can't support like the style, link, image, etc. This renderer is mainly used to generate a
+ * simple as possible
+ * label like in a TOC.
+ *
+ * @version $Id$
+ * @since 2.0M3
+ */
+@Component("plain/1.0")
+public class PlainTextBlockRenderer extends AbstractBlockRenderer {
+
+ /**
+ * Used to create new plain/1.0 {@link org.xwiki.rendering.renderer.PrintRenderer}s.
+ */
+ @Requirement("plain/1.0")
+ private PrintRendererFactory plainTextRendererFactory;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.internal.renderer.AbstractBlockRenderer#getPrintRendererFactory()
+ */
+ @Override
+ protected PrintRendererFactory getPrintRendererFactory() {
+ return this.plainTextRendererFactory;
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/plain/PlainTextChainingRenderer.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/plain/PlainTextChainingRenderer.java
new file mode 100644
index 000000000..5e95b13a0
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/plain/PlainTextChainingRenderer.java
@@ -0,0 +1,338 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.renderer.plain;
+
+import java.util.Map;
+
+import org.apache.commons.lang.StringUtils;
+import org.xwiki.rendering.listener.HeaderLevel;
+import org.xwiki.rendering.listener.reference.ResourceReference;
+import org.xwiki.rendering.listener.reference.ResourceType;
+import org.xwiki.rendering.listener.ListType;
+import org.xwiki.rendering.listener.chaining.BlockStateChainingListener;
+import org.xwiki.rendering.listener.chaining.EmptyBlockChainingListener;
+import org.xwiki.rendering.listener.chaining.ListenerChain;
+import org.xwiki.rendering.renderer.reference.link.LinkLabelGenerator;
+import org.xwiki.rendering.renderer.AbstractChainingPrintRenderer;
+
+/**
+ * Print only plain text information. For example it remove anything which need a specific syntax a
+ * simple plain text
+ * editor can't support like the style, link, image, etc. This renderer is mainly used to generate a
+ * simple as possible
+ * label like in a TOC.
+ *
+ * @version $Id$
+ * @since 1.9M1
+ */
+public class PlainTextChainingRenderer extends AbstractChainingPrintRenderer {
+
+ /**
+ * New Line character.
+ */
+ private static final String NL = "\n";
+
+ private boolean isFirstElementRendered;
+
+ /**
+ * Generate link label.
+ */
+ private LinkLabelGenerator linkLabelGenerator;
+
+ /**
+ * The plain text renderer supports when no link label generator is set.
+ */
+ public PlainTextChainingRenderer(ListenerChain listenerChain) {
+ this(null, listenerChain);
+ }
+
+ public PlainTextChainingRenderer(LinkLabelGenerator linkLabelGenerator,
+ ListenerChain listenerChain) {
+ setListenerChain(listenerChain);
+
+ this.linkLabelGenerator = linkLabelGenerator;
+ }
+
+ // State
+
+ private BlockStateChainingListener getBlockState() {
+ return (BlockStateChainingListener) getListenerChain()
+ .getListener(BlockStateChainingListener.class);
+ }
+
+ protected EmptyBlockChainingListener getEmptyBlockState() {
+ return (EmptyBlockChainingListener) getListenerChain()
+ .getListener(EmptyBlockChainingListener.class);
+ }
+
+ // Events
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginParagraph(java.util.Map)
+ */
+ @Override
+ public void beginParagraph(Map parameters) {
+ printEmptyLine();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onNewLine()
+ */
+ @Override
+ public void onNewLine() {
+ getPrinter().print(NL);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.chaining.AbstractChainingListener#endLink(
+ * org.xwiki.rendering.listener.reference.ResourceReference , boolean, java.util.Map)
+ */
+ @Override
+ public void endLink(ResourceReference reference, boolean isFreeStandingURI,
+ Map parameters) {
+ if (getEmptyBlockState().isCurrentContainerBlockEmpty()) {
+ if (reference.getType().equals(ResourceType.DOCUMENT) && this.linkLabelGenerator != null) {
+ getPrinter().print(this.linkLabelGenerator.generate(reference));
+ } else {
+ getPrinter().print(reference.getReference());
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginHeader(org.xwiki.rendering.listener.HeaderLevel,
+ * String, java.util.Map)
+ */
+ @Override
+ public void beginHeader(HeaderLevel level, String id, Map parameters) {
+ printEmptyLine();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onWord(java.lang.String)
+ */
+ @Override
+ public void onWord(String word) {
+ getPrinter().print(word);
+ }
+
+ @Override
+ public void beginList(ListType listType, Map parameters) {
+ if (getBlockState().getListDepth() == 1) {
+ printEmptyLine();
+ } else {
+ getPrinter().print(NL);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginListItem()
+ */
+ @Override
+ public void beginListItem() {
+ if (getBlockState().getListItemIndex() > 0) {
+ getPrinter().print(NL);
+ }
+
+ // TODO: maybe add some syntax here like a - or not
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onSpace()
+ */
+ @Override
+ public void onSpace() {
+ getPrinter().print(" ");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onSpecialSymbol(char)
+ */
+ @Override
+ public void onSpecialSymbol(char symbol) {
+ getPrinter().print(String.valueOf(symbol));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onHorizontalLine(java.util.Map)
+ */
+ @Override
+ public void onHorizontalLine(Map parameters) {
+ printEmptyLine();
+ getPrinter().print("----");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onEmptyLines(int)
+ */
+ @Override
+ public void onEmptyLines(int count) {
+ getPrinter().print(StringUtils.repeat(NL, count));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onVerbatim(String, boolean,
+ * Map)
+ */
+ @Override
+ public void onVerbatim(String protectedString, boolean isInline, Map parameters) {
+ getPrinter().print(protectedString);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginDefinitionList(java.util.Map)
+ * @since 2.0RC1
+ */
+ @Override
+ public void beginDefinitionList(Map parameters) {
+ if (getBlockState().getDefinitionListDepth() == 1 && !getBlockState().isInList()) {
+ printEmptyLine();
+ } else {
+ getPrinter().print(NL);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginDefinitionTerm()
+ */
+ @Override
+ public void beginDefinitionTerm() {
+ if (getBlockState().getDefinitionListItemIndex() > 0) {
+ getPrinter().print(NL);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginDefinitionDescription()
+ */
+ @Override
+ public void beginDefinitionDescription() {
+ if (getBlockState().getDefinitionListItemIndex() > 0) {
+ getPrinter().print(NL);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginQuotationLine()
+ */
+ @Override
+ public void beginQuotationLine() {
+ if (getBlockState().getQuotationLineIndex() > 0) {
+ getPrinter().print(NL);
+ } else {
+ printEmptyLine();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginTable(java.util.Map)
+ */
+ @Override
+ public void beginTable(Map parameters) {
+ printEmptyLine();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginTableCell(java.util.Map)
+ */
+ @Override
+ public void beginTableCell(Map parameters) {
+ if (getBlockState().getCellCol() > 0) {
+ getPrinter().print("\t");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginTableHeadCell(java.util.Map)
+ */
+ @Override
+ public void beginTableHeadCell(Map parameters) {
+ beginTableCell(parameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#beginTableRow(java.util.Map)
+ */
+ @Override
+ public void beginTableRow(Map parameters) {
+ if (getBlockState().getCellRow() > 0) {
+ getPrinter().print(NL);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.renderer.AbstractChainingPrintRenderer#onImage(
+ * org.xwiki.rendering.listener.reference.ResourceReference , boolean, java.util.Map)
+ * @since 2.5RC1
+ */
+ @Override
+ public void onImage(ResourceReference reference, boolean isFreeStandingURI,
+ Map parameters) {
+ // TODO: maybe something could be done here
+ }
+
+ private void printEmptyLine() {
+ if (this.isFirstElementRendered) {
+ getPrinter().print(NL + NL);
+ } else {
+ this.isFirstElementRendered = true;
+ }
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/plain/PlainTextRenderer.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/plain/PlainTextRenderer.java
new file mode 100644
index 000000000..a1d12a089
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/plain/PlainTextRenderer.java
@@ -0,0 +1,69 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.renderer.plain;
+
+import org.xwiki.component.annotation.Component;
+import org.xwiki.component.annotation.InstantiationStrategy;
+import org.xwiki.component.annotation.Requirement;
+import org.xwiki.component.descriptor.ComponentInstantiationStrategy;
+import org.xwiki.component.phase.Initializable;
+import org.xwiki.component.phase.InitializationException;
+import org.xwiki.rendering.listener.chaining.BlockStateChainingListener;
+import org.xwiki.rendering.listener.chaining.EmptyBlockChainingListener;
+import org.xwiki.rendering.listener.chaining.ListenerChain;
+import org.xwiki.rendering.renderer.reference.link.LinkLabelGenerator;
+import org.xwiki.rendering.renderer.AbstractChainingPrintRenderer;
+
+/**
+ * Print only plain text information. For example it remove anything which need a specific syntax a
+ * simple plain text
+ * editor can't support like the style, link, image, etc. This renderer is mainly used to generate a
+ * simple as possible
+ * label like in a TOC.
+ *
+ * @version $Id$
+ * @since 2.0M3
+ */
+@Component("plain/1.0")
+@InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
+public class PlainTextRenderer extends AbstractChainingPrintRenderer implements Initializable {
+
+ @Requirement
+ private LinkLabelGenerator linkLabelGenerator;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Initializable#initialize()
+ * @since 2.0M3
+ */
+ public void initialize() throws InitializationException {
+ ListenerChain chain = new ListenerChain();
+ setListenerChain(chain);
+
+ // Construct the listener chain in the right order. Listeners early in the chain are called
+ // before listeners
+ // placed later in the chain.
+ chain.addListener(this);
+ chain.addListener(new BlockStateChainingListener(chain));
+ chain.addListener(new EmptyBlockChainingListener(chain));
+ chain.addListener(new PlainTextChainingRenderer(this.linkLabelGenerator, chain));
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/plain/PlainTextRendererFactory.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/plain/PlainTextRendererFactory.java
new file mode 100644
index 000000000..08696b739
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/plain/PlainTextRendererFactory.java
@@ -0,0 +1,43 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.renderer.plain;
+
+import org.xwiki.component.annotation.Component;
+import org.xwiki.rendering.syntax.Syntax;
+import org.xwiki.rendering.internal.renderer.AbstractPrintRendererFactory;
+
+/**
+ * Create Plain Text Renderers.
+ *
+ * @version $Id$
+ * @since 2.0M3
+ */
+@Component("plain/1.0")
+public class PlainTextRendererFactory extends AbstractPrintRendererFactory {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractPrintRendererFactory#getSyntax()
+ */
+ public Syntax getSyntax() {
+ return Syntax.PLAIN_1_0;
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/printer/WikiWriter.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/printer/WikiWriter.java
new file mode 100644
index 000000000..12d603615
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/printer/WikiWriter.java
@@ -0,0 +1,90 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.renderer.printer;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.xwiki.rendering.renderer.printer.WikiPrinter;
+
+/**
+ * Bridge so that {@link WikiPrinter} can be used in a tools supporting {@link Writer} api.
+ *
+ * @version $Id$
+ */
+public class WikiWriter extends Writer {
+
+ public WikiWriter(WikiPrinter printer) {
+ super(printer);
+ }
+
+ public void setWikiPrinter(WikiPrinter printer) {
+ this.lock = printer;
+ }
+
+ public WikiPrinter getWikiPrinter() {
+ return (WikiPrinter) this.lock;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.io.Writer#close()
+ */
+ @Override
+ public void close() throws IOException {
+ // WikiPrinter does not support stream close
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.io.Writer#flush()
+ */
+ @Override
+ public void flush() throws IOException {
+ // WikiPrinter does not support stream flush
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.io.Writer#write(char[], int, int)
+ */
+ @Override
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ getWikiPrinter().print(new String(cbuf, off, len));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * Override it to improve speed a little. Otherwise the String is transformed in char table passed
+ * to the over
+ * methods which recreate a String.
+ *
+ * @see java.io.Writer#write(java.lang.String)
+ */
+ @Override
+ public void write(String str) throws IOException {
+ getWikiPrinter().print(str);
+ }
+
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/printer/XHTMLWriter.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/printer/XHTMLWriter.java
new file mode 100644
index 000000000..5be64c032
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/printer/XHTMLWriter.java
@@ -0,0 +1,62 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.renderer.printer;
+
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
+
+/**
+ * XHTMLWriter is an helper to configure XMLWriter to format a DOM4J tree as XHTML.
+ *
+ * @version $Id$
+ */
+public class XHTMLWriter extends XMLWriter {
+
+ protected static final OutputFormat DEFAULT_XHTML_FORMAT;
+
+ static {
+ DEFAULT_XHTML_FORMAT = new OutputFormat();
+ DEFAULT_XHTML_FORMAT.setXHTML(true);
+ }
+
+ public XHTMLWriter(Writer writer) throws UnsupportedEncodingException {
+ super(writer, DEFAULT_XHTML_FORMAT);
+
+ // escape all non US-ASCII to have as less encoding problems as possible
+ setMaximumAllowedCharacter(-1);
+ }
+
+ /**
+ * Escapes a string to be used as an attribute value. Unlike the original method in
+ * {@link XMLWriter}, apostrophes
+ * are replaced by a numerical entity &, since ' is not valid in HTML documents.
+ *
+ * @param text
+ * the attribute value to escape
+ * @return the text with all occurrences of special XML characters replaced by entity references.
+ */
+ @Override
+ protected String escapeAttributeEntities(String text) {
+ return super.escapeAttributeEntities(text).replace("'", "&");
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/syntax/DefaultSyntaxFactory.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/syntax/DefaultSyntaxFactory.java
new file mode 100644
index 000000000..44fbd29b8
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/syntax/DefaultSyntaxFactory.java
@@ -0,0 +1,69 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.syntax;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.xwiki.component.annotation.Component;
+import org.xwiki.component.logging.AbstractLogEnabled;
+import org.xwiki.rendering.parser.ParseException;
+import org.xwiki.rendering.syntax.Syntax;
+import org.xwiki.rendering.syntax.SyntaxFactory;
+import org.xwiki.rendering.syntax.SyntaxType;
+
+/**
+ * @version $Id$
+ * @since 1.5M2
+ */
+@Component
+public class DefaultSyntaxFactory extends AbstractLogEnabled implements SyntaxFactory {
+
+ /**
+ * Used to cut the syntax identifier into syntax name and syntax version.
+ */
+ private static final Pattern SYNTAX_PATTERN = Pattern.compile("(.*)\\/(.*)");
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.syntax.SyntaxFactory#createSyntaxFromIdString(java.lang.String)
+ */
+ public Syntax createSyntaxFromIdString(String syntaxIdAsString) throws ParseException {
+ if (syntaxIdAsString == null) {
+ throw new ParseException("The passed Syntax cannot be NULL");
+ }
+
+ Matcher matcher = SYNTAX_PATTERN.matcher(syntaxIdAsString);
+ if (!matcher.matches()) {
+ throw new ParseException("Invalid Syntax format [" + syntaxIdAsString + "]");
+ }
+
+ String syntaxId = matcher.group(1);
+ String version = matcher.group(2);
+
+ // Use the id as both the human readable name and the technical id (since the syntax string
+ // doesn't contain
+ // any information about the pretty name of a syntax type).
+ SyntaxType syntaxType = new SyntaxType(syntaxId, syntaxId);
+
+ return new Syntax(syntaxType, version);
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/transformation/DefaultTransformationManager.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/transformation/DefaultTransformationManager.java
new file mode 100644
index 000000000..63f1f519b
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/transformation/DefaultTransformationManager.java
@@ -0,0 +1,86 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.internal.transformation;
+
+import org.xwiki.component.annotation.Component;
+import org.xwiki.component.annotation.Requirement;
+import org.xwiki.component.logging.AbstractLogEnabled;
+import org.xwiki.rendering.block.Block;
+import org.xwiki.rendering.block.XDOM;
+import org.xwiki.rendering.configuration.RenderingConfiguration;
+import org.xwiki.rendering.syntax.Syntax;
+import org.xwiki.rendering.transformation.Transformation;
+import org.xwiki.rendering.transformation.TransformationContext;
+import org.xwiki.rendering.transformation.TransformationException;
+import org.xwiki.rendering.transformation.TransformationManager;
+
+/**
+ * Calls all existing transformations (executed by priority) on an existing XDOM object to generate
+ * a new transformed
+ * XDOM.
+ *
+ * @version $Id$
+ * @since 1.5M2
+ */
+@Component
+public class DefaultTransformationManager extends AbstractLogEnabled
+ implements TransformationManager {
+
+ /**
+ * Used to get the ordered list of transformations to execute.
+ */
+ @Requirement
+ private RenderingConfiguration configuration;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.transformation.TransformationManager#performTransformations(org.xwiki.rendering.block.XDOM,
+ * org.xwiki.rendering.syntax.Syntax)
+ */
+ public void performTransformations(XDOM dom, Syntax syntax) throws TransformationException {
+ performTransformations(dom, new TransformationContext(dom, syntax));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.transformation.TransformationManager#performTransformations(org.xwiki.rendering.block.Block,
+ * org.xwiki.rendering.transformation.TransformationContext)
+ */
+ public void performTransformations(Block block, TransformationContext context)
+ throws TransformationException {
+ boolean error = false;
+ for (Transformation transformation : this.configuration.getTransformations()) {
+ try {
+ transformation.transform(block, context);
+ } catch (Exception e) {
+ // Continue running the other transformations
+ getLogger().error("Failed to execute transformation", e);
+ error = true;
+ }
+ }
+ if (error) {
+ throw new TransformationException(
+ "One or several transformations failed to execute properly. "
+ + "See the logs for details.");
+ }
+ }
+}
diff --git a/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/listener/CompositeListener.java b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/listener/CompositeListener.java
new file mode 100644
index 000000000..ee46591b3
--- /dev/null
+++ b/celements-xwiki-rendering-api/src/main/java/org/xwiki/rendering/listener/CompositeListener.java
@@ -0,0 +1,626 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.rendering.listener;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.xwiki.rendering.listener.reference.ResourceReference;
+import org.xwiki.rendering.syntax.Syntax;
+
+/**
+ * Send events to a list of {@link Listener}s.
+ *
+ * @version $Id$
+ * @since 2.1M1
+ */
+public class CompositeListener implements Listener {
+
+ /**
+ * The listeners.
+ */
+ private List listeners = new ArrayList();
+
+ /**
+ * Add a nex listener to the list.
+ *
+ * @param listener
+ * a listener
+ */
+ public void addListener(Listener listener) {
+ this.listeners.add(listener);
+ }
+
+ /**
+ * Get listener at the provided position in the list.
+ *
+ * @param i
+ * the index of the listener in the list
+ * @return the listener
+ */
+ public Listener getListener(int i) {
+ return this.listeners.get(i);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginDefinitionDescription()
+ */
+ public void beginDefinitionDescription() {
+ for (Listener listener : listeners) {
+ listener.beginDefinitionDescription();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginDefinitionList(java.util.Map)
+ */
+ public void beginDefinitionList(Map parameters) {
+ for (Listener listener : listeners) {
+ listener.beginDefinitionList(parameters);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginDefinitionTerm()
+ */
+ public void beginDefinitionTerm() {
+ for (Listener listener : listeners) {
+ listener.beginDefinitionTerm();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginDocument(java.util.Map)
+ */
+ public void beginDocument(Map parameters) {
+ for (Listener listener : listeners) {
+ listener.beginDocument(parameters);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginFormat(org.xwiki.rendering.listener.Format,
+ * java.util.Map)
+ */
+ public void beginFormat(Format format, Map parameters) {
+ for (Listener listener : listeners) {
+ listener.beginFormat(format, parameters);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginGroup(java.util.Map)
+ */
+ public void beginGroup(Map parameters) {
+ for (Listener listener : listeners) {
+ listener.beginGroup(parameters);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginHeader(org.xwiki.rendering.listener.HeaderLevel,
+ * java.lang.String, java.util.Map)
+ */
+ public void beginHeader(HeaderLevel level, String id, Map parameters) {
+ for (Listener listener : listeners) {
+ listener.beginHeader(level, id, parameters);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginList(org.xwiki.rendering.listener.ListType,
+ * java.util.Map)
+ */
+ public void beginList(ListType listType, Map parameters) {
+ for (Listener listener : listeners) {
+ listener.beginList(listType, parameters);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginListItem()
+ */
+ public void beginListItem() {
+ for (Listener listener : listeners) {
+ listener.beginListItem();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginMacroMarker(java.lang.String, java.util.Map,
+ * java.lang.String,
+ * boolean)
+ */
+ public void beginMacroMarker(String name, Map macroParameters, String content,
+ boolean isInline) {
+ for (Listener listener : listeners) {
+ listener.beginMacroMarker(name, macroParameters, content, isInline);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginParagraph(java.util.Map)
+ */
+ public void beginParagraph(Map parameters) {
+ for (Listener listener : listeners) {
+ listener.beginParagraph(parameters);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginQuotation(java.util.Map)
+ */
+ public void beginQuotation(Map parameters) {
+ for (Listener listener : listeners) {
+ listener.beginQuotation(parameters);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginQuotationLine()
+ */
+ public void beginQuotationLine() {
+ for (Listener listener : listeners) {
+ listener.beginQuotationLine();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginSection(java.util.Map)
+ */
+ public void beginSection(Map parameters) {
+ for (Listener listener : listeners) {
+ listener.beginSection(parameters);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.xwiki.rendering.listener.Listener#beginTable(java.util.Map)
+ */
+ public void beginTable(Map