On Tue, Sep 28, 2010 at 18:00, Vincent Massol <[email protected]> wrote: > hmmm IMO this macro should be in the xwiki-office/ directory along with the > other 2 projects. > > WDYT?
+1 it's not really a standard standalone macro but more one of the office module interfaces > > Thanks > -Vincent > > On Sep 28, 2010, at 5:52 PM, mflorea (SVN) wrote: > >> Author: mflorea >> Date: 2010-09-28 17:52:58 +0200 (Tue, 28 Sep 2010) >> New Revision: 31441 >> >> Added: >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/ >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/pom.xml >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/ >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/ >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/ >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/ >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/ >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/rendering/ >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/rendering/internal/ >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/rendering/internal/macro/ >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/rendering/internal/macro/office/ >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/rendering/internal/macro/office/OfficeMacro.java >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/rendering/macro/ >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/rendering/macro/office/ >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/rendering/macro/office/OfficeMacroParameters.java >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/resources/ >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/resources/META-INF/ >> >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/resources/META-INF/components.txt >> Modified: >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/pom.xml >> Log: >> XWIKI-5538: Create a macro to view office attachments >> >> >> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/pom.xml >> =================================================================== >> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/pom.xml >> 2010-09-28 14:59:38 UTC (rev 31440) >> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/pom.xml >> 2010-09-28 15:52:58 UTC (rev 31441) >> @@ -116,5 +116,6 @@ >> <module>xwiki-rendering-macro-ruby</module> >> <module>xwiki-rendering-macro-python</module> >> <module>xwiki-rendering-macro-php</module> >> + <module>xwiki-rendering-macro-office</module> >> </modules> >> </project> >> >> Added: >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/pom.xml >> =================================================================== >> --- >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/pom.xml >> (rev 0) >> +++ >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/pom.xml >> 2010-09-28 15:52:58 UTC (rev 31441) >> @@ -0,0 +1,58 @@ >> +<?xml version="1.0" encoding="UTF-8"?> >> + >> +<!-- >> + * >> + * 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. >> + * >> +--> >> + >> +<project xmlns="http://maven.apache.org/POM/4.0.0" >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 >> http://maven.apache.org/maven-v4_0_0.xsd"> >> + <parent> >> + <artifactId>xwiki-core-rendering-macros-parent</artifactId> >> + <groupId>org.xwiki.platform</groupId> >> + <version>2.5-SNAPSHOT</version> >> + </parent> >> + <modelVersion>4.0.0</modelVersion> >> + <artifactId>xwiki-core-rendering-macro-office</artifactId> >> + <name>XWiki Platform - Core - Rendering - Macro - Office</name> >> + <version>2.5-SNAPSHOT</version> >> + <description>View office attachments (doc, ppt, xls, odt, odp, ods etc.) >> inside wiki pages without downloading or >> + importing them.</description> >> + <dependencies> >> + <dependency> >> + <groupId>org.xwiki.platform</groupId> >> + <artifactId>xwiki-core-office-viewer</artifactId> >> + <version>${project.version}</version> >> + </dependency> >> + </dependencies> >> + <build> >> + <plugins> >> + <plugin> >> + <!-- Apply the Checkstyle configurations defined in the top level >> pom.xml file --> >> + <groupId>org.apache.maven.plugins</groupId> >> + <artifactId>maven-checkstyle-plugin</artifactId> >> + </plugin> >> + </plugins> >> + </build> >> + <properties> >> + <!-- Skip Clirr execution since this is the first release of this >> module. Remove once XE 2.5M2 is released. --> >> + <xwiki.clirr.skip>true</xwiki.clirr.skip> >> + </properties> >> +</project> >> >> >> Property changes on: >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/pom.xml >> ___________________________________________________________________ >> Added: svn:keywords >> + Author Id Revision HeadURL >> Added: svn:eol-style >> + native >> >> Added: >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/rendering/internal/macro/office/OfficeMacro.java >> =================================================================== >> --- >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/rendering/internal/macro/office/OfficeMacro.java >> (rev 0) >> +++ >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/rendering/internal/macro/office/OfficeMacro.java >> 2010-09-28 15:52:58 UTC (rev 31441) >> @@ -0,0 +1,108 @@ >> +/* >> + * 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.macro.office; >> + >> +import java.util.Collections; >> +import java.util.List; >> +import java.util.Map; >> + >> +import org.xwiki.bridge.DocumentAccessBridge; >> +import org.xwiki.component.annotation.Component; >> +import org.xwiki.component.annotation.Requirement; >> +import org.xwiki.model.EntityType; >> +import org.xwiki.model.reference.AttachmentReference; >> +import org.xwiki.model.reference.DocumentReference; >> +import org.xwiki.model.reference.EntityReferenceResolver; >> +import org.xwiki.office.viewer.OfficeViewer; >> +import org.xwiki.rendering.block.Block; >> +import org.xwiki.rendering.macro.AbstractMacro; >> +import org.xwiki.rendering.macro.MacroExecutionException; >> +import org.xwiki.rendering.macro.office.OfficeMacroParameters; >> +import org.xwiki.rendering.transformation.MacroTransformationContext; >> + >> +/** >> + * View office attachments (doc, ppt, xls, odt, odp, ods etc.) inside wiki >> pages without downloading or importing them. >> + * >> + * @version $Id$ >> + * @since 2.5M2 >> + */ >> +...@component("office") >> +public class OfficeMacro extends AbstractMacro<OfficeMacroParameters> >> +{ >> + /** >> + * The component used to resolve the attachment string reference >> relative to the current document reference. >> + */ >> + �...@requirement("explicit") >> + private EntityReferenceResolver<String> >> explicitStringEntityReferenceResolver; >> + >> + /** >> + * The component used to get the current document reference. >> + */ >> + �...@requirement >> + private DocumentAccessBridge documentAccessBridge; >> + >> + /** >> + * The component used to view the office attachments. >> + */ >> + �...@requirement >> + private OfficeViewer officeViewer; >> + >> + /** >> + * Default constructor. >> + */ >> + public OfficeMacro() >> + { >> + super("Office Document Viewer", "View office attachments (doc, ppt, >> xls, odt, odp, ods etc.) inside " >> + + "wiki pages without downloading or importing them.", >> OfficeMacroParameters.class); >> + >> + setDefaultCategory(DEFAULT_CATEGORY_CONTENT); >> + } >> + >> + /** >> + * {...@inheritdoc} >> + * >> + * @see AbstractMacro#execute(Object, String, >> MacroTransformationContext) >> + */ >> + public List<Block> execute(OfficeMacroParameters parameters, String >> content, MacroTransformationContext context) >> + throws MacroExecutionException >> + { >> + DocumentReference currentDocumentReference = >> documentAccessBridge.getCurrentDocumentReference(); >> + AttachmentReference attachmentReference = >> + new >> AttachmentReference(explicitStringEntityReferenceResolver.resolve(parameters.getAttachment(), >> + EntityType.ATTACHMENT, currentDocumentReference)); >> + Map<String, String> viewParameters = >> + Collections.singletonMap("filterStyles", >> String.valueOf(parameters.isFilterStyles())); >> + try { >> + return officeViewer.createView(attachmentReference, >> viewParameters).getChildren(); >> + } catch (Exception e) { >> + throw new MacroExecutionException("Failed to view office >> attachment.", e); >> + } >> + } >> + >> + /** >> + * {...@inheritdoc} >> + * >> + * @see AbstractMacro#supportsInlineMode() >> + */ >> + public boolean supportsInlineMode() >> + { >> + return false; >> + } >> +} >> >> >> Property changes on: >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/rendering/internal/macro/office/OfficeMacro.java >> ___________________________________________________________________ >> Added: svn:keywords >> + Author Id Revision HeadURL >> Added: svn:eol-style >> + native >> >> Added: >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/rendering/macro/office/OfficeMacroParameters.java >> =================================================================== >> --- >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/rendering/macro/office/OfficeMacroParameters.java >> (rev 0) >> +++ >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/rendering/macro/office/OfficeMacroParameters.java >> 2010-09-28 15:52:58 UTC (rev 31441) >> @@ -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.macro.office; >> + >> +import org.xwiki.properties.annotation.PropertyDescription; >> +import org.xwiki.properties.annotation.PropertyMandatory; >> + >> +/** >> + * Parameters for the {...@link >> org.xwiki.rendering.internal.macro.office.OfficeMacro}. >> + * >> + * @version $Id$ >> + * @since 2.5M2 >> + */ >> +public class OfficeMacroParameters >> +{ >> + /** >> + * The office attachment to be viewed. Use an attachment string >> reference to specify which office file should be >> + * viewed: {...@code file.ppt}, {...@code [email protected]}, {...@code >> [email protected]} or {...@code wiki:[email protected]}. >> + */ >> + private String attachment; >> + >> + /** >> + * Whether to filter in-line CSS styles present in the HTML content >> produced by the OpenOffice server. Office >> + * content is usually better integrated in the host wiki page when >> styles are filtered. >> + * <p> >> + * Styles are filtered by default. >> + */ >> + private boolean filterStyles = true; >> + >> + /** >> + * @return a string reference to the office attachment to be viewed >> + */ >> + public String getAttachment() >> + { >> + return attachment; >> + } >> + >> + /** >> + * Sets the office attachment to be viewed. >> + * >> + * @param attachment an attachment string reference >> + */ >> + �...@propertydescription("The office attachment to be viewed. Use an >> attachment string reference to specify which " >> + + "office file should be viewed: file.ppt, [email protected], >> [email protected] or wiki:[email protected].") >> + �...@propertymandatory >> + public void setAttachment(String attachment) >> + { >> + this.attachment = attachment; >> + } >> + >> + /** >> + * @return {...@code true} if the CSS styles present in the HTML >> content produces by the OpenOffice server are >> + * filtered, {...@code false} otherwise >> + */ >> + public boolean isFilterStyles() >> + { >> + return filterStyles; >> + } >> + >> + /** >> + * Sets whether to filter in-line CSS styles present in the HTML >> content produced by the OpenOffice server. >> + * >> + * @param filterStyles {...@code true} to filter the CSS style present >> in the HTML content produces by the OpenOffice >> + * server, {...@code false} otherwise >> + */ >> + �...@propertydescription("Whether to filter in-line CSS styles present >> in the HTML content produced by the OpenOffice " >> + + "server. Office content is usually better integrated in the host >> wiki page when styles are filtered.") >> + public void setFilterStyles(boolean filterStyles) >> + { >> + this.filterStyles = filterStyles; >> + } >> +} >> >> >> Property changes on: >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/java/org/xwiki/rendering/macro/office/OfficeMacroParameters.java >> ___________________________________________________________________ >> Added: svn:keywords >> + Author Id Revision HeadURL >> Added: svn:eol-style >> + native >> >> Added: >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/resources/META-INF/components.txt >> =================================================================== >> --- >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/resources/META-INF/components.txt >> (rev 0) >> +++ >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/resources/META-INF/components.txt >> 2010-09-28 15:52:58 UTC (rev 31441) >> @@ -0,0 +1 @@ >> +org.xwiki.rendering.internal.macro.office.OfficeMacro >> \ No newline at end of file >> >> >> Property changes on: >> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-office/src/main/resources/META-INF/components.txt >> ___________________________________________________________________ >> Added: svn:eol-style >> + native > > _______________________________________________ > devs mailing list > [email protected] > http://lists.xwiki.org/mailman/listinfo/devs > -- Thomas Mortagne _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

