summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Bauer <mba@openoffice.org>2010-10-21 15:10:42 +0200
committerMathias Bauer <mba@openoffice.org>2010-10-21 15:10:42 +0200
commitf8ee9cd0a46653343d102bee8a669e0a417608f5 (patch)
tree1697015666bc7e299a07846113582c8aabbeb68d
parent1e902f896bae749c3bf20af93caaca06253a2c2a (diff)
parent7e56aed62ec2230680d6f4a69ae3462974daa458 (diff)
CWS changehid: resync to m90
Notes
Notes: split repo tag: filters_ooo/DEV300_m91
-rw-r--r--filter/prj/build.lst3
-rw-r--r--filter/qa/complex/filter/misc/FinalizedMandatoryTest.java217
-rw-r--r--filter/qa/complex/filter/misc/TypeDetection6FileFormat.java93
-rwxr-xr-xfilter/qa/complex/filter/misc/makefile.mk80
-rw-r--r--filter/source/pdf/pdfexport.cxx977
-rw-r--r--filter/source/pdf/pdfexport.hxx7
-rw-r--r--oox/inc/oox/drawingml/fillproperties.hxx2
-rw-r--r--oox/inc/oox/helper/graphichelper.hxx4
-rw-r--r--oox/inc/oox/ppt/slidepersist.hxx2
-rw-r--r--oox/source/drawingml/fillproperties.cxx21
-rw-r--r--oox/source/drawingml/fillpropertiesgroupcontext.cxx10
-rw-r--r--oox/source/helper/graphichelper.cxx25
-rw-r--r--oox/source/ppt/slidefragmenthandler.cxx7
-rw-r--r--oox/source/ppt/slidepersist.cxx7
-rw-r--r--oox/source/token/properties.txt1
-rw-r--r--unoxml/prj/build.lst2
-rw-r--r--unoxml/qa/complex/tests.sce1
-rw-r--r--unoxml/qa/complex/unoxml/RDFRepositoryTest.java (renamed from unoxml/qa/complex/RDFRepositoryTest.java)332
-rw-r--r--unoxml/qa/complex/unoxml/TestDocument.java39
-rw-r--r--unoxml/qa/complex/unoxml/makefile.mk (renamed from unoxml/qa/complex/makefile.mk)44
-rw-r--r--unoxml/qa/complex/unoxml/testdocuments/example.rdf (renamed from unoxml/qa/complex/testdocuments/example.rdf)0
21 files changed, 585 insertions, 1289 deletions
diff --git a/filter/prj/build.lst b/filter/prj/build.lst
index bed99e401b7f..065b4313c57b 100644
--- a/filter/prj/build.lst
+++ b/filter/prj/build.lst
@@ -42,3 +42,6 @@ fl filter\source\config\cache nmake - all fl_config
fl filter\source\config\fragments\types nmake - all fl_fcfg_fragments_types fl_inc NULL
fl filter\source\config\fragments\filters nmake - all fl_fcfg_fragments_filters fl_inc NULL
fl filter\source\config\fragments nmake - all fl_fcfg_fragments fl_fcfg_fragments_filters fl_inc NULL
+
+# took very long
+# fl filter\qa\complex\filter\misc nmake - all fl_qa_complex NULL
diff --git a/filter/qa/complex/filter/misc/FinalizedMandatoryTest.java b/filter/qa/complex/filter/misc/FinalizedMandatoryTest.java
index e32b81caa85b..a269afec836d 100644
--- a/filter/qa/complex/filter/misc/FinalizedMandatoryTest.java
+++ b/filter/qa/complex/filter/misc/FinalizedMandatoryTest.java
@@ -24,7 +24,6 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
package complex.filter.misc;
import com.sun.star.beans.PropertyValue;
@@ -39,10 +38,18 @@ import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;
import com.sun.star.util.XFlushable;
-import complexlib.ComplexTestCase;
-import util.utils;
-
-
+// import complexlib.ComplexTestCase;
+// import util.utils;
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
/**
* This complex test checks the functionality of the properties "Finalized" and "Mandatory" of
@@ -74,7 +81,8 @@ import util.utils;
* <CODE>Mandatory=true</CODE>
* <CODE>Mandatory=false</CODE>
*/
-public class FinalizedMandatoryTest extends ComplexTestCase {
+public class FinalizedMandatoryTest
+{
static XMultiServiceFactory xMSF;
@@ -82,21 +90,21 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
* A function to tell the framework, which test functions are available.
* @return All test methods.
*/
- public String[] getTestMethodNames() {
- return new String[]{"checkReadonlySupportFilterFactory",
- "checkReadonlySupportTypeDetection"};
- }
-
+// public String[] getTestMethodNames() {
+// return new String[]{"checkReadonlySupportFilterFactory",
+// "checkReadonlySupportTypeDetection"};
+// }
/** Create the environment for following tests.
* Use either a component loader from desktop or
* from frame
* @throws Exception Exception
*/
- public void before() throws Exception {
+ @Before public void before() throws Exception
+ {
// create TypeDetection
- xMSF = (XMultiServiceFactory)param.getMSF();
- assure("Could not get XMultiServiceFactory", xMSF != null);
+ xMSF = getMSF();
+ assertNotNull("Could not get XMultiServiceFactory", xMSF);
}
@@ -106,14 +114,16 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
* @throws Exception was thrown if creataion failes
* @return <CODE>XInterface</CODE> of service
*/
- public XInterface getTestObject(String serviceName) throws Exception{
+ private XInterface getTestObject(String serviceName) throws Exception
+ {
Object oInterface = xMSF.createInstance(serviceName);
- if (oInterface == null) {
- failed("Service wasn't created") ;
- throw new Exception("could not create service '"+serviceName+"'");
- }
+ assertNotNull("Service wan't created", oInterface);
+// if (oInterface == null) {
+// failed("Service wasn't created") ;
+// throw new Exception("could not create service '"+serviceName+"'");
+// }
return (XInterface) oInterface;
}
@@ -121,7 +131,8 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
* call the function <CODE>checkReadonlySupport</CODE> to test <CODE>com.sun.star.document.FilterFactory</CODE>
* @see com.sun.star.document.FilterFactory
*/
- public void checkReadonlySupportFilterFactory(){
+ @Test public void checkReadonlySupportFilterFactory()
+ {
checkReadonlySupport("com.sun.star.document.FilterFactory");
}
@@ -129,26 +140,30 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
* call the function <CODE>checkReadonlySupport</CODE> to test <CODE>com.sun.star.document.TypeDetection</CODE>
* @see com.sun.star.document.TypeDetection
*/
- public void checkReadonlySupportTypeDetection(){
+ @Test public void checkReadonlySupportTypeDetection()
+ {
checkReadonlySupport("com.sun.star.document.TypeDetection");
}
-
/**
* test the given service <CODE>serviceName</CODE>.
* For every filter a new instace was created and the tests started.
* @param serviceName the name of the service to test
*/
- private void checkReadonlySupport(String serviceName){
- log.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
- log.println("testing service '" + serviceName + "'");
+ private void checkReadonlySupport(String serviceName)
+ {
+ System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+ System.out.println("testing service '" + serviceName + "'");
XInterface oObj = null;
- try{
+ try
+ {
oObj = getTestObject(serviceName);
- log.println("ImplName: "+utils.getImplName(oObj));
- } catch (java.lang.Exception e){
- failed("could not get test object");
+ System.out.println("ImplName: " + util.utils.getImplName(oObj));
+ }
+ catch (java.lang.Exception e)
+ {
+ fail("could not get test object");
}
boolean mandantoryTrue = false;
@@ -157,19 +172,21 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
boolean finalizedFalse = false;
- XNameAccess xNA = (XNameAccess) UnoRuntime.queryInterface
- (XNameAccess.class, oObj);
+ XNameAccess xNA = UnoRuntime.queryInterface(XNameAccess.class, oObj);
String[] filterNames = xNA.getElementNames();
// XNameContainer; XNameReplace
String filterName = filterNames[0];
- Object[] instance = null;;
- for (int i = 0; i < filterNames.length; i++) {
- log.println("------------------------------------------------");
- try{
+ Object[] instance = null;
+
+ for (int i = 0; i < filterNames.length; i++)
+ {
+ System.out.println("------------------------------------------------");
+ try
+ {
PropertyValue instanceProp = new PropertyValue();
filterName = filterNames[i];
- log.println(filterName);
+ System.out.println(filterName);
// testobject must new created for every test.
// We change in a loop the container and try to flush this changes.
@@ -177,16 +194,19 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
// similar to a document which could not be saved beacuse of invalid
// contend. While you don't remove the invalid conted you will never
// be able to save the document. Same here.
- try{
+ try
+ {
oObj = getTestObject(serviceName);
- } catch (java.lang.Exception e){
- failed("could not get test object", CONTINUE);
+ }
+ catch (java.lang.Exception e)
+ {
+ fail("could not get test object");
}
- xNA = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oObj);
- XNameContainer xNC = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, oObj);
- XNameReplace xNR = (XNameReplace) UnoRuntime.queryInterface(XNameReplace.class, oObj);
- XFlushable xFlush = (XFlushable) UnoRuntime.queryInterface(XFlushable.class, oObj);
+ xNA = UnoRuntime.queryInterface(XNameAccess.class, oObj);
+ XNameContainer xNC = UnoRuntime.queryInterface(XNameContainer.class, oObj);
+ XNameReplace xNR = UnoRuntime.queryInterface(XNameReplace.class, oObj);
+ XFlushable xFlush = UnoRuntime.queryInterface(XFlushable.class, oObj);
instance = (Object[]) xNA.getByName(filterName);
PropertyValue[] props = (PropertyValue[]) instance;
@@ -204,59 +224,75 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
finalizedFalse |= !isFinalized;
//change the filter
- setPropertyValueValue((PropertyValue[])instance, "UIName", "dummy");
+ setPropertyValueValue((PropertyValue[]) instance, "UIName", "dummy");
// 1a.) try to change the filter in the container
- try{
+ try
+ {
xNR.replaceByName(filterName, instance);
- }catch (IllegalArgumentException e){
- failed("could not replace filter properties ('" + filterName + "')", CONTINUE);
+ }
+ catch (IllegalArgumentException e)
+ {
+ fail("could not replace filter properties ('" + filterName + "')");
}
// 1b.) try to wirte the changed filter to the configuration.
// This must result in a exception if the filter is finalized.
boolean flushError = false;
- try{
+ try
+ {
xFlush.flush();
- } catch (WrappedTargetRuntimeException e){
+ }
+ catch (WrappedTargetRuntimeException e)
+ {
flushError = true;
- assure("Unexpected exception wihle flushing changed filter '"+ filterName + "'", isFinalized,CONTINUE);
+ assertTrue("Unexpected exception wihle flushing changed filter '" + filterName + "'", isFinalized);
}
- assure("Expected exception was not thorwn while flushing changed filter '"+ filterName + "' Finalized:" + isFinalized,
- !(flushError ^ isFinalized), CONTINUE);
+ assertTrue("Expected exception was not thorwn while flushing changed filter '" + filterName + "' Finalized:" + isFinalized,
+ !(flushError ^ isFinalized));
// 2a.) try to remove the filter from the container
- try{
+ try
+ {
xNC.removeByName(filterName);
- }catch (NoSuchElementException e){
- failed("could not remove filter from container ('" + filterName + "')", CONTINUE);
+ }
+ catch (NoSuchElementException e)
+ {
+ fail("could not remove filter from container ('" + filterName + "')");
}
// 1b.) try to wirte the changed filter to the configuration.
// This must result in a exception if the filter is mandatory
flushError = false;
- try{
+ try
+ {
xFlush.flush();
- } catch (WrappedTargetRuntimeException e){
+ }
+ catch (WrappedTargetRuntimeException e)
+ {
flushError = true;
- assure("Unexpected exception wihle flushing removed filter '"+ filterName + "'", isMandatory,CONTINUE);
+ assertTrue("Unexpected exception wihle flushing removed filter '" + filterName + "'", isMandatory);
}
- assure("Expected exception was not thorwn while flushing removed filter '"+ filterName + "' Mandatory:" + isMandatory,
- !(flushError ^ isMandatory), CONTINUE);
+ assertTrue("Expected exception was not thorwn while flushing removed filter '" + filterName + "' Mandatory:" + isMandatory,
+ !(flushError ^ isMandatory));
- } catch (NoSuchElementException e){
- failed("Couldn't get elements from object", true);
- } catch (WrappedTargetException e){
- failed("Couldn't get elements from object", true);
+ }
+ catch (NoSuchElementException e)
+ {
+ fail("Couldn't get elements from object");
+ }
+ catch (WrappedTargetException e)
+ {
+ fail("Couldn't get elements from object");
}
}
String preMsg = "Could not find filter with state ";
String postMsg = " Please check if such filter is installed!";
- assure(preMsg + "'Mandatory=true'" + postMsg ,mandantoryTrue, CONTINUE);
- assure(preMsg + "'Mandatory=false'" + postMsg ,mandantoryFalse, CONTINUE);
- assure(preMsg + "'Finalized=true'" + postMsg ,finalizedTrue, CONTINUE);
- assure(preMsg + "'Finalized=false'" + postMsg ,finalizedFalse, CONTINUE);
+ assertTrue(preMsg + "'Mandatory=true'" + postMsg, mandantoryTrue);
+ assertTrue(preMsg + "'Mandatory=false'" + postMsg, mandantoryFalse);
+ assertTrue(preMsg + "'Finalized=true'" + postMsg, finalizedTrue);
+ assertTrue(preMsg + "'Finalized=false'" + postMsg, finalizedFalse);
}
/**
@@ -265,13 +301,18 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
* @see com.sun.star.beans.PropertyValue
* @param props Sequenze of PropertyValue
*/
- protected void printPropertyValues(PropertyValue[] props) {
+ protected void printPropertyValues(PropertyValue[] props)
+ {
int i = 0;
- while (i < props.length ) {
- log.println(props[i].Name + ":" + props[i].Value.toString());
+ while (i < props.length)
+ {
+ System.out.println(props[i].Name + ":" + props[i].Value.toString());
i++;
}
- if (i < props.length) log.println(props[i].Name + ":" + props[i].Value.toString());
+ if (i < props.length)
+ {
+ System.out.println(props[i].Name + ":" + props[i].Value.toString());
+ }
}
/**
@@ -280,9 +321,11 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
* @param pName the name of the property the value shoud be returned
* @return the value of the property
*/
- protected Object getPropertyValueValue(PropertyValue[] props, String pName) {
+ protected Object getPropertyValueValue(PropertyValue[] props, String pName)
+ {
int i = 0;
- while (i < props.length && !props[i].Name.equals(pName)) {
+ while (i < props.length && !props[i].Name.equals(pName))
+ {
i++;
}
return i < props.length ? props[i].Value : null;
@@ -294,14 +337,36 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
* @param pName name of the property which should be changed
* @param pValue the value the property should be assigned
*/
- protected void setPropertyValueValue(PropertyValue[] props, String pName, Object pValue) {
+ protected void setPropertyValueValue(PropertyValue[] props, String pName, Object pValue)
+ {
int i = 0;
- while (i < props.length && !props[i].Name.equals(pName)) {
+ while (i < props.length && !props[i].Name.equals(pName))
+ {
i++;
}
props[i].Value = pValue;
}
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+ @AfterClass
+ public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+ private static final OfficeConnection connection = new OfficeConnection();
}
diff --git a/filter/qa/complex/filter/misc/TypeDetection6FileFormat.java b/filter/qa/complex/filter/misc/TypeDetection6FileFormat.java
index 842a365d4714..6fda574ae8f5 100644
--- a/filter/qa/complex/filter/misc/TypeDetection6FileFormat.java
+++ b/filter/qa/complex/filter/misc/TypeDetection6FileFormat.java
@@ -3,21 +3,31 @@
*
* Created on 26. April 2004, 10:37
*/
-
package complex.filter.misc;
import com.sun.star.container.XNameAccess;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;
-import complexlib.ComplexTestCase;
+
import util.utils;
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
/**
*
* @author cn93815
*/
-public class TypeDetection6FileFormat extends ComplexTestCase {
+public class TypeDetection6FileFormat
+{
static XMultiServiceFactory xMSF;
@@ -25,20 +35,20 @@ public class TypeDetection6FileFormat extends ComplexTestCase {
* A function to tell the framework, which test functions are available.
* @return All test methods.
*/
- public String[] getTestMethodNames() {
- return new String[]{"checkFilterFactory",
- "checkTypeDetection"};
- }
-
+// public String[] getTestMethodNames() {
+// return new String[]{"checkFilterFactory",
+// "checkTypeDetection"};
+// }
/** Create the environment for following tests.
* Use either a component loader from desktop or
* from frame
* @throws Exception Exception
*/
- public void before() throws Exception {
+ @Before public void before() throws Exception
+ {
- xMSF = (XMultiServiceFactory)param.getMSF();
- assure("Could not get XMultiServiceFactory", xMSF != null);
+ xMSF = getMSF();
+ assertNotNull("Could not get XMultiServiceFactory", xMSF);
}
@@ -46,7 +56,8 @@ public class TypeDetection6FileFormat extends ComplexTestCase {
* call the function <CODE>checkFileFormatSupport</CODE> to test <CODE>com.sun.star.document.FilterFactory</CODE>
* @see com.sun.star.document.FilterFactory
*/
- public void checkFilterFactory(){
+ @Test public void checkFilterFactory()
+ {
checkFileFormatSupport("com.sun.star.document.FilterFactory");
}
@@ -54,7 +65,8 @@ public class TypeDetection6FileFormat extends ComplexTestCase {
* call the function <CODE>checkFileFormatSupport</CODE> to test <CODE>com.sun.star.document.TypeDetection</CODE>
* @see com.sun.star.document.TypeDetection
*/
- public void checkTypeDetection(){
+ @Test public void checkTypeDetection()
+ {
checkFileFormatSupport("com.sun.star.document.TypeDetection");
}
@@ -64,42 +76,67 @@ public class TypeDetection6FileFormat extends ComplexTestCase {
* The serve was created and the filter 'TypeDetection6FileFormat' was searched
* @param serviceName the name of the service to test
*/
- private void checkFileFormatSupport(String serviceName){
- log.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
- log.println("testing service '" + serviceName + "'");
+ private void checkFileFormatSupport(String serviceName)
+ {
+ System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+ System.out.println("testing service '" + serviceName + "'");
XInterface oObj = null;
- try{
+ try
+ {
oObj = getTestObject(serviceName);
- log.println("ImplName: "+utils.getImplName(oObj));
- } catch (java.lang.Exception e){
- failed("could not get test object");
+ System.out.println("ImplName: " + utils.getImplName(oObj));
+ }
+ catch (java.lang.Exception e)
+ {
+ fail("could not get test object");
}
- XNameAccess xNA = (XNameAccess) UnoRuntime.queryInterface
- (XNameAccess.class, oObj);
+ XNameAccess xNA = UnoRuntime.queryInterface(XNameAccess.class, oObj);
String msg = "Could not find filter 'TypeDetection6FileFormat'!";
msg += "\nMaybe 'TypeDetection6FileFormat.xcu' is not registered.";
- assure(msg, xNA.hasByName("TypeDetection6FileFormat"),CONTINUE);
+ assertTrue(msg, xNA.hasByName("TypeDetection6FileFormat"));
}
- /**
+ /**
* Creates an instance for the given <CODE>serviceName</CODE>
* @param serviceName the name of the service which should be created
* @throws Exception was thrown if creataion failes
* @return <CODE>XInterface</CODE> of service
*/
- public XInterface getTestObject(String serviceName) throws Exception{
+ public XInterface getTestObject(String serviceName) throws Exception
+ {
Object oInterface = xMSF.createInstance(serviceName);
- if (oInterface == null) {
- failed("Service wasn't created") ;
- throw new Exception("could not create service '"+serviceName+"'");
+ if (oInterface == null)
+ {
+ fail("Service wasn't created");
+ throw new Exception("could not create service '" + serviceName + "'");
}
return (XInterface) oInterface;
}
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass public static void setUpConnection() throws Exception {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+
+ private static final OfficeConnection connection = new OfficeConnection();
}
diff --git a/filter/qa/complex/filter/misc/makefile.mk b/filter/qa/complex/filter/misc/makefile.mk
index 2792b2438b6e..5ac072a2e071 100755
--- a/filter/qa/complex/filter/misc/makefile.mk
+++ b/filter/qa/complex/filter/misc/makefile.mk
@@ -25,73 +25,35 @@
#
#*************************************************************************
-PRJ = ..$/..$/..$/..
-PRJNAME = filter
-TARGET = Filter
-PACKAGE = complex$/filter$/misc
-
-# --- Settings -----------------------------------------------------
-.INCLUDE: settings.mk
-
-
-#----- compile .java files -----------------------------------------
-
-JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
-JAVAFILES = FinalizedMandatoryTest.java TypeDetection6FileFormat.java
-JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
-
-#----- make a jar from compiled files ------------------------------
-
-MAXLINELENGTH = 100000
-
-JARCLASSDIRS = $(PACKAGE)
-JARTARGET = $(TARGET).jar
-JARCOMPRESS = TRUE
-
-# --- Parameters for the test --------------------------------------
-
-# start an office if the parameter is set for the makefile
-.IF "$(OFFICE)" == ""
-CT_APPEXECCOMMAND =
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
.ELSE
-CT_APPEXECCOMMAND = -AppExecutionCommand \
- "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
-.ENDIF
-
-# test base is java complex
-CT_TESTBASE = -TestBase java_complex
-
-# replace $/ with . in package name
-CT_PACKAGE = -o $(PACKAGE:s\$/\.\)
-
-# start the runner application
-CT_APP = org.openoffice.Runner
+PRJ = ../../../..
+PRJNAME = filter
+TARGET = qa_complex_filter_misc
-# --- Targets ------------------------------------------------------
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/filter/misc
+JAVATESTFILES = \
+ TypeDetection6FileFormat.java \
+ FinalizedMandatoryTest.java
-.IF "$(depend)" == ""
-DisplayHint : ALLTAR
-.ELSE
-DisplayHint : ALLDEP
-.ENDIF
+JAVAFILES = $(JAVATESTFILES)
-.INCLUDE : target.mk
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar jurt.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+.END
-DisplayHint:
- @echo "\ntype 'dmake FinalizedMandatoryTest'"
- @echo "\ntype 'dmake TypeDetection6FileFormat'"
- @echo "! BE SHURE YOU HAVE 'TypeDetection6FileFormat.xcu' SUCCESSFUL REGISTERED IN YOU OFFICE !"
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
-RUN: run
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
-run: \
- DisplayHint
+ALLTAR : javatest
+.END
-FinalizedMandatoryTest:
- java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_PACKAGE).FinalizedMandatoryTest
-
-TypeDetection6FileFormat:
- java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_PACKAGE).TypeDetection6FileFormat
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index 43f6f1faf2f1..a8d4e1d0d14c 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -50,6 +50,8 @@
#include <svtools/filter.hxx>
#include <svl/solar.hrc>
#include <comphelper/string.hxx>
+#include <unotools/streamwrap.hxx>
+#include <com/sun/star/io/XSeekable.hpp>
#include "basegfx/polygon/b2dpolygon.hxx"
#include "basegfx/polygon/b2dpolypolygon.hxx"
#include "basegfx/polygon/b2dpolygontools.hxx"
@@ -72,6 +74,7 @@
#include <unotools/configmgr.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/graphic/XGraphicProvider.hpp>
using namespace ::rtl;
using namespace ::vcl;
@@ -80,6 +83,7 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::view;
+using namespace ::com::sun::star::graphic;
// -------------
// - PDFExport -
@@ -935,21 +939,37 @@ void PDFExport::showErrors( const std::set< PDFWriter::ErrorCode >& rErrors )
sal_Bool PDFExport::ImplExportPage( PDFWriter& rWriter, PDFExtOutDevData& rPDFExtOutDevData, const GDIMetaFile& rMtf )
{
- VirtualDevice aDummyVDev;
+ vcl::PDFWriter::PlayMetafileContext aCtx;
+
+ GDIMetaFile aMtf;
+ if( mbRemoveTransparencies )
+ {
+ aCtx.m_bTransparenciesWereRemoved = rWriter.GetReferenceDevice()->
+ RemoveTransparenciesFromMetaFile( rMtf, aMtf, mnMaxImageResolution, mnMaxImageResolution,
+ false, true, mbReduceImageResolution );
+ }
+ else
+ {
+ aMtf = rMtf;
+ }
+ aCtx.m_nMaxImageResolution = mbReduceImageResolution ? mnMaxImageResolution : 0;
+ aCtx.m_bOnlyLosslessCompression = mbUseLosslessCompression;
+ aCtx.m_nJPEGQuality = mnQuality;
+
+
const Size aSizePDF( OutputDevice::LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MAP_POINT ) );
Point aOrigin;
Rectangle aPageRect( aOrigin, rMtf.GetPrefSize() );
- sal_Bool bRet = sal_False;
-
- aDummyVDev.EnableOutput( sal_False );
- aDummyVDev.SetMapMode( rMtf.GetPrefMapMode() );
+ sal_Bool bRet = sal_True;
rWriter.NewPage( aSizePDF.Width(), aSizePDF.Height() );
rWriter.SetMapMode( rMtf.GetPrefMapMode() );
basegfx::B2DRectangle aB2DRect( aPageRect.Left(), aPageRect.Top(), aPageRect.Right(), aPageRect.Bottom() );
rWriter.SetClipRegion( basegfx::B2DPolyPolygon( basegfx::tools::createPolygonFromRect( aB2DRect ) ) );
- bRet = ImplWriteActions( rWriter, &rPDFExtOutDevData, rMtf, aDummyVDev );
+
+ rWriter.PlayMetafile( aMtf, aCtx, &rPDFExtOutDevData );
+
rPDFExtOutDevData.ResetSyncData();
if( mbWatermark )
@@ -1031,949 +1051,4 @@ void PDFExport::ImplWriteWatermark( PDFWriter& rWriter, const Size& rPageSize )
rWriter.Pop();
}
-// -----------------------------------------------------------------------------
-
-sal_Bool PDFExport::ImplWriteActions( PDFWriter& rWriter, PDFExtOutDevData* pPDFExtOutDevData,
- const GDIMetaFile& rInMtf, VirtualDevice& rDummyVDev )
-{
- bool bAssertionFired( false );
-
- GDIMetaFile aMtf;
- bool bTransparenciesRemoved = false;
- if( mbRemoveTransparencies )
- {
- bTransparenciesRemoved = rWriter.GetReferenceDevice()->
- RemoveTransparenciesFromMetaFile( rInMtf, aMtf, mnMaxImageResolution, mnMaxImageResolution,
- false, true, mbReduceImageResolution );
- }
- else
- {
- aMtf = rInMtf;
- }
-
-
- for( sal_uInt32 i = 0, nCount = aMtf.GetActionCount(); i < nCount; )
- {
- if ( !pPDFExtOutDevData || !pPDFExtOutDevData->PlaySyncPageAct( rWriter, i ) )
- {
- const MetaAction* pAction = aMtf.GetAction( i );
- const USHORT nType = pAction->GetType();
-
- switch( nType )
- {
- case( META_PIXEL_ACTION ):
- {
- const MetaPixelAction* pA = (const MetaPixelAction*) pAction;
- rWriter.DrawPixel( pA->GetPoint(), pA->GetColor() );
- }
- break;
-
- case( META_POINT_ACTION ):
- {
- const MetaPointAction* pA = (const MetaPointAction*) pAction;
- rWriter.DrawPixel( pA->GetPoint() );
- }
- break;
-
- case( META_LINE_ACTION ):
- {
- const MetaLineAction* pA = (const MetaLineAction*) pAction;
- if ( pA->GetLineInfo().IsDefault() )
- rWriter.DrawLine( pA->GetStartPoint(), pA->GetEndPoint() );
- else
- rWriter.DrawLine( pA->GetStartPoint(), pA->GetEndPoint(), pA->GetLineInfo() );
- }
- break;
-
- case( META_RECT_ACTION ):
- {
- const MetaRectAction* pA = (const MetaRectAction*) pAction;
- rWriter.DrawRect( pA->GetRect() );
- }
- break;
-
- case( META_ROUNDRECT_ACTION ):
- {
- const MetaRoundRectAction* pA = (const MetaRoundRectAction*) pAction;
- rWriter.DrawRect( pA->GetRect(), pA->GetHorzRound(), pA->GetVertRound() );
- }
- break;
-
- case( META_ELLIPSE_ACTION ):
- {
- const MetaEllipseAction* pA = (const MetaEllipseAction*) pAction;
- rWriter.DrawEllipse( pA->GetRect() );
- }
- break;
-
- case( META_ARC_ACTION ):
- {
- const MetaArcAction* pA = (const MetaArcAction*) pAction;
- rWriter.DrawArc( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() );
- }
- break;
-
- case( META_PIE_ACTION ):
- {
- const MetaArcAction* pA = (const MetaArcAction*) pAction;
- rWriter.DrawPie( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() );
- }
- break;
-
- case( META_CHORD_ACTION ):
- {
- const MetaChordAction* pA = (const MetaChordAction*) pAction;
- rWriter.DrawChord( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() );
- }
- break;
-
- case( META_POLYGON_ACTION ):
- {
- const MetaPolygonAction* pA = (const MetaPolygonAction*) pAction;
- rWriter.DrawPolygon( pA->GetPolygon() );
- }
- break;
-
- case( META_POLYLINE_ACTION ):
- {
- const MetaPolyLineAction* pA = (const MetaPolyLineAction*) pAction;
- if ( pA->GetLineInfo().IsDefault() )
- rWriter.DrawPolyLine( pA->GetPolygon() );
- else
- rWriter.DrawPolyLine( pA->GetPolygon(), pA->GetLineInfo() );
- }
- break;
-
- case( META_POLYPOLYGON_ACTION ):
- {
- const MetaPolyPolygonAction* pA = (const MetaPolyPolygonAction*) pAction;
- rWriter.DrawPolyPolygon( pA->GetPolyPolygon() );
- }
- break;
-
- case( META_GRADIENT_ACTION ):
- {
- const MetaGradientAction* pA = (const MetaGradientAction*) pAction;
- const PolyPolygon aPolyPoly( pA->GetRect() );
-
- ImplWriteGradient( rWriter, aPolyPoly, pA->GetGradient(), rDummyVDev );
- }
- break;
-
- case( META_GRADIENTEX_ACTION ):
- {
- const MetaGradientExAction* pA = (const MetaGradientExAction*) pAction;
- ImplWriteGradient( rWriter, pA->GetPolyPolygon(), pA->GetGradient(), rDummyVDev );
- }
- break;
-
- case META_HATCH_ACTION:
- {
- const MetaHatchAction* pA = (const MetaHatchAction*) pAction;
- rWriter.DrawHatch( pA->GetPolyPolygon(), pA->GetHatch() );
- }
- break;
-
- case( META_TRANSPARENT_ACTION ):
- {
- const MetaTransparentAction* pA = (const MetaTransparentAction*) pAction;
- rWriter.DrawTransparent( pA->GetPolyPolygon(), pA->GetTransparence() );
- }
- break;
-
- case( META_FLOATTRANSPARENT_ACTION ):
- {
- const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*) pAction;
-
- GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() );
- const Point& rPos = pA->GetPoint();
- const Size& rSize= pA->GetSize();
- const Gradient& rTransparenceGradient = pA->GetGradient();
-
- // special case constant alpha value
- if( rTransparenceGradient.GetStartColor() == rTransparenceGradient.GetEndColor() )
- {
- const Color aTransCol( rTransparenceGradient.GetStartColor() );
- const USHORT nTransPercent = aTransCol.GetLuminance() * 100 / 255;
- rWriter.BeginTransparencyGroup();
- ImplWriteActions( rWriter, NULL, aTmpMtf, rDummyVDev );
- rWriter.EndTransparencyGroup( Rectangle( rPos, rSize ), nTransPercent );
- }
- else
- {
- const Size aDstSizeTwip( rDummyVDev.PixelToLogic( rDummyVDev.LogicToPixel( rSize ), MAP_TWIP ) );
- sal_Int32 nMaxBmpDPI = mbUseLosslessCompression ? 300 : 72;
- if ( mbReduceImageResolution )
- {
- if ( nMaxBmpDPI > mnMaxImageResolution )
- nMaxBmpDPI = mnMaxImageResolution;
- }
- const sal_Int32 nPixelX = (sal_Int32)((double)aDstSizeTwip.Width() * (double)nMaxBmpDPI / 1440.0);
- const sal_Int32 nPixelY = (sal_Int32)((double)aDstSizeTwip.Height() * (double)nMaxBmpDPI / 1440.0);
- if ( nPixelX && nPixelY )
- {
- Size aDstSizePixel( nPixelX, nPixelY );
- VirtualDevice* pVDev = new VirtualDevice;
- if( pVDev->SetOutputSizePixel( aDstSizePixel ) )
- {
- Bitmap aPaint, aMask;
- AlphaMask aAlpha;
- Point aPoint;
-
- MapMode aMapMode( rDummyVDev.GetMapMode() );
- aMapMode.SetOrigin( aPoint );
- pVDev->SetMapMode( aMapMode );
- Size aDstSize( pVDev->PixelToLogic( aDstSizePixel ) );
-
- Point aMtfOrigin( aTmpMtf.GetPrefMapMode().GetOrigin() );
- if ( aMtfOrigin.X() || aMtfOrigin.Y() )
- aTmpMtf.Move( -aMtfOrigin.X(), -aMtfOrigin.Y() );
- double fScaleX = (double)aDstSize.Width() / (double)aTmpMtf.GetPrefSize().Width();
- double fScaleY = (double)aDstSize.Height() / (double)aTmpMtf.GetPrefSize().Height();
- if( fScaleX != 1.0 || fScaleY != 1.0 )
- aTmpMtf.Scale( fScaleX, fScaleY );
- aTmpMtf.SetPrefMapMode( aMapMode );
-
- // create paint bitmap
- aTmpMtf.WindStart();
- aTmpMtf.Play( pVDev, aPoint, aDstSize );
- aTmpMtf.WindStart();
-
- pVDev->EnableMapMode( FALSE );
- aPaint = pVDev->GetBitmap( aPoint, aDstSizePixel );
- pVDev->EnableMapMode( TRUE );
-
- // create mask bitmap
- pVDev->SetLineColor( COL_BLACK );
- pVDev->SetFillColor( COL_BLACK );
- pVDev->DrawRect( Rectangle( aPoint, aDstSize ) );
- pVDev->SetDrawMode( DRAWMODE_WHITELINE | DRAWMODE_WHITEFILL | DRAWMODE_WHITETEXT |
- DRAWMODE_WHITEBITMAP | DRAWMODE_WHITEGRADIENT );
- aTmpMtf.WindStart();
- aTmpMtf.Play( pVDev, aPoint, aDstSize );
- aTmpMtf.WindStart();
- pVDev->EnableMapMode( FALSE );
- aMask = pVDev->GetBitmap( aPoint, aDstSizePixel );
- pVDev->EnableMapMode( TRUE );
-
- // create alpha mask from gradient
- pVDev->SetDrawMode( DRAWMODE_GRAYGRADIENT );
- pVDev->DrawGradient( Rectangle( aPoint, aDstSize ), rTransparenceGradient );
- pVDev->SetDrawMode( DRAWMODE_DEFAULT );
- pVDev->EnableMapMode( FALSE );
- pVDev->DrawMask( aPoint, aDstSizePixel, aMask, Color( COL_WHITE ) );
- aAlpha = pVDev->GetBitmap( aPoint, aDstSizePixel );
- ImplWriteBitmapEx( rWriter, rDummyVDev, rPos, rSize, BitmapEx( aPaint, aAlpha ) );
- }
- delete pVDev;
- }
- }
- }
- break;
-
- case( META_EPS_ACTION ):
- {
- const MetaEPSAction* pA = (const MetaEPSAction*) pAction;
- const GDIMetaFile aSubstitute( pA->GetSubstitute() );
-
- rWriter.Push();
- rDummyVDev.Push();
-
- MapMode aMapMode( aSubstitute.GetPrefMapMode() );
- Size aOutSize( rDummyVDev.LogicToLogic( pA->GetSize(), rDummyVDev.GetMapMode(), aMapMode ) );
- aMapMode.SetScaleX( Fraction( aOutSize.Width(), aSubstitute.GetPrefSize().Width() ) );
- aMapMode.SetScaleY( Fraction( aOutSize.Height(), aSubstitute.GetPrefSize().Height() ) );
- aMapMode.SetOrigin( rDummyVDev.LogicToLogic( pA->GetPoint(), rDummyVDev.GetMapMode(), aMapMode ) );
-
- rWriter.SetMapMode( aMapMode );
- rDummyVDev.SetMapMode( aMapMode );
- ImplWriteActions( rWriter, NULL, aSubstitute, rDummyVDev );
- rDummyVDev.Pop();
- rWriter.Pop();
- }
- break;
-
- case( META_COMMENT_ACTION ):
- if( ! bTransparenciesRemoved )
- {
- const MetaCommentAction* pA = (const MetaCommentAction*) pAction;
- String aSkipComment;
-
- if( pA->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL )
- {
- const MetaGradientExAction* pGradAction = NULL;
- sal_Bool bDone = sal_False;
-
- while( !bDone && ( ++i < nCount ) )
- {
- pAction = aMtf.GetAction( i );
-
- if( pAction->GetType() == META_GRADIENTEX_ACTION )
- pGradAction = (const MetaGradientExAction*) pAction;
- else if( ( pAction->GetType() == META_COMMENT_ACTION ) &&
- ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_END" ) == COMPARE_EQUAL ) )
- {
- bDone = sal_True;
- }
- }
-
- if( pGradAction )
- ImplWriteGradient( rWriter, pGradAction->GetPolyPolygon(), pGradAction->GetGradient(), rDummyVDev );
- }
- else
- {
- const BYTE* pData = pA->GetData();
- if ( pData )
- {
- SvMemoryStream aMemStm( (void*)pData, pA->GetDataSize(), STREAM_READ );
- sal_Bool bSkipSequence = sal_False;
- ByteString sSeqEnd;
-
- if( pA->GetComment().Equals( "XPATHSTROKE_SEQ_BEGIN" ) )
- {
- sSeqEnd = ByteString( "XPATHSTROKE_SEQ_END" );
- SvtGraphicStroke aStroke;
- aMemStm >> aStroke;
-
- Polygon aPath;
- aStroke.getPath( aPath );
-
- PolyPolygon aStartArrow;
- PolyPolygon aEndArrow;
- double fTransparency( aStroke.getTransparency() );
- double fStrokeWidth( aStroke.getStrokeWidth() );
- SvtGraphicStroke::DashArray aDashArray;
-
- aStroke.getStartArrow( aStartArrow );
- aStroke.getEndArrow( aEndArrow );
- aStroke.getDashArray( aDashArray );
-
- bSkipSequence = sal_True;
- if ( aStartArrow.Count() || aEndArrow.Count() )
- bSkipSequence = sal_False;
- if ( aDashArray.size() && ( fStrokeWidth != 0.0 ) && ( fTransparency == 0.0 ) )
- bSkipSequence = sal_False;
- if ( bSkipSequence )
- {
- PDFWriter::ExtLineInfo aInfo;
- aInfo.m_fLineWidth = fStrokeWidth;
- aInfo.m_fTransparency = fTransparency;
- aInfo.m_fMiterLimit = aStroke.getMiterLimit();
- switch( aStroke.getCapType() )
- {
- default:
- case SvtGraphicStroke::capButt: aInfo.m_eCap = PDFWriter::capButt;break;
- case SvtGraphicStroke::capRound: aInfo.m_eCap = PDFWriter::capRound;break;
- case SvtGraphicStroke::capSquare: aInfo.m_eCap = PDFWriter::capSquare;break;
- }
- switch( aStroke.getJoinType() )
- {
- default:
- case SvtGraphicStroke::joinMiter: aInfo.m_eJoin = PDFWriter::joinMiter;break;
- case SvtGraphicStroke::joinRound: aInfo.m_eJoin = PDFWriter::joinRound;break;
- case SvtGraphicStroke::joinBevel: aInfo.m_eJoin = PDFWriter::joinBevel;break;
- case SvtGraphicStroke::joinNone:
- aInfo.m_eJoin = PDFWriter::joinMiter;
- aInfo.m_fMiterLimit = 0.0;
- break;
- }
- aInfo.m_aDashArray = aDashArray;
-
- if(SvtGraphicStroke::joinNone == aStroke.getJoinType()
- && fStrokeWidth > 0.0)
- {
- // emulate no edge rounding by handling single edges
- const sal_uInt16 nPoints(aPath.GetSize());
- const bool bCurve(aPath.HasFlags());
-
- for(sal_uInt16 a(0); a + 1 < nPoints; a++)
- {
- if(bCurve
- && POLY_NORMAL != aPath.GetFlags(a + 1)
- && a + 2 < nPoints
- && POLY_NORMAL != aPath.GetFlags(a + 2)
- && a + 3 < nPoints)
- {
- const Polygon aSnippet(4,
- aPath.GetConstPointAry() + a,
- aPath.GetConstFlagAry() + a);
- rWriter.DrawPolyLine( aSnippet, aInfo );
- a += 2;
- }
- else
- {
- const Polygon aSnippet(2,
- aPath.GetConstPointAry() + a);
- rWriter.DrawPolyLine( aSnippet, aInfo );
- }
- }
- }
- else
- {
- rWriter.DrawPolyLine( aPath, aInfo );
- }
- }
- }
- else if ( pA->GetComment().Equals( "XPATHFILL_SEQ_BEGIN" ) )
- {
- sSeqEnd = ByteString( "XPATHFILL_SEQ_END" );
- SvtGraphicFill aFill;
- aMemStm >> aFill;
-
- if ( ( aFill.getFillType() == SvtGraphicFill::fillSolid ) && ( aFill.getFillRule() == SvtGraphicFill::fillEvenOdd ) )
- {
- double fTransparency = aFill.getTransparency();
- if ( fTransparency == 0.0 )
- {
- PolyPolygon aPath;
- aFill.getPath( aPath );
-
- bSkipSequence = sal_True;
- rWriter.DrawPolyPolygon( aPath );
- }
- else if ( fTransparency == 1.0 )
- bSkipSequence = sal_True;
- }
-/* #i81548# removing optimization for fill textures, because most of the texture settings are not
- exported properly. In OpenOffice 3.1 the drawing layer will support graphic primitives, then it
- will not be a problem to optimize the filltexture export. But for wysiwyg is more important than
- filesize.
- else if( aFill.getFillType() == SvtGraphicFill::fillTexture && aFill.isTiling() )
- {
- sal_Int32 nPattern = mnCachePatternId;
- Graphic aPatternGraphic;
- aFill.getGraphic( aPatternGraphic );
- bool bUseCache = false;
- SvtGraphicFill::Transform aPatTransform;
- aFill.getTransform( aPatTransform );
-
- if( mnCachePatternId >= 0 )
- {
- SvtGraphicFill::Transform aCacheTransform;
- maCacheFill.getTransform( aCacheTransform );
- if( aCacheTransform.matrix[0] == aPatTransform.matrix[0] &&
- aCacheTransform.matrix[1] == aPatTransform.matrix[1] &&
- aCacheTransform.matrix[2] == aPatTransform.matrix[2] &&
- aCacheTransform.matrix[3] == aPatTransform.matrix[3] &&
- aCacheTransform.matrix[4] == aPatTransform.matrix[4] &&
- aCacheTransform.matrix[5] == aPatTransform.matrix[5]
- )
- {
- Graphic aCacheGraphic;
- maCacheFill.getGraphic( aCacheGraphic );
- if( aCacheGraphic == aPatternGraphic )
- bUseCache = true;
- }
- }
-
- if( ! bUseCache )
- {
-
- // paint graphic to metafile
- GDIMetaFile aPattern;
- rDummyVDev.SetConnectMetaFile( &aPattern );
- rDummyVDev.Push();
- rDummyVDev.SetMapMode( aPatternGraphic.GetPrefMapMode() );
-
- aPatternGraphic.Draw( &rDummyVDev, Point( 0, 0 ) );
- rDummyVDev.Pop();
- rDummyVDev.SetConnectMetaFile( NULL );
- aPattern.WindStart();
-
- MapMode aPatternMapMode( aPatternGraphic.GetPrefMapMode() );
- // prepare pattern from metafile
- Size aPrefSize( aPatternGraphic.GetPrefSize() );
- // FIXME: this magic -1 shouldn't be necessary
- aPrefSize.Width() -= 1;
- aPrefSize.Height() -= 1;
- aPrefSize = rWriter.GetReferenceDevice()->
- LogicToLogic( aPrefSize,
- &aPatternMapMode,
- &rWriter.GetReferenceDevice()->GetMapMode() );
- // build bounding rectangle of pattern
- Rectangle aBound( Point( 0, 0 ), aPrefSize );
- rWriter.BeginPattern( aBound );
- rWriter.Push();
- rDummyVDev.Push();
- rWriter.SetMapMode( aPatternMapMode );
- rDummyVDev.SetMapMode( aPatternMapMode );
- ImplWriteActions( rWriter, NULL, aPattern, rDummyVDev );
- rDummyVDev.Pop();
- rWriter.Pop();
-
- nPattern = rWriter.EndPattern( aPatTransform );
-
- // try some caching and reuse pattern
- mnCachePatternId = nPattern;
- maCacheFill = aFill;
- }
-
- // draw polypolygon with pattern fill
- PolyPolygon aPath;
- aFill.getPath( aPath );
- rWriter.DrawPolyPolygon( aPath, nPattern, aFill.getFillRule() == SvtGraphicFill::fillEvenOdd );
-
- bSkipSequence = sal_True;
- }
-*/
- }
- if ( bSkipSequence )
- {
- while( ++i < nCount )
- {
- pAction = aMtf.GetAction( i );
- if ( pAction->GetType() == META_COMMENT_ACTION )
- {
- ByteString sComment( ((MetaCommentAction*)pAction)->GetComment() );
- if ( sComment.Equals( sSeqEnd ) )
- break;
- }
- // #i44496#
- // the replacement action for stroke is a filled rectangle
- // the set fillcolor of the replacement is part of the graphics
- // state and must not be skipped
- else if( pAction->GetType() == META_FILLCOLOR_ACTION )
- {
- const MetaFillColorAction* pMA = (const MetaFillColorAction*) pAction;
- if( pMA->IsSetting() )
- rWriter.SetFillColor( pMA->GetColor() );
- else
- rWriter.SetFillColor();
- }
- }
- }
- }
- }
- }
- break;
-
- case( META_BMP_ACTION ):
- {
- const MetaBmpAction* pA = (const MetaBmpAction*) pAction;
- BitmapEx aBitmapEx( pA->GetBitmap() );
- Size aSize( OutputDevice::LogicToLogic( aBitmapEx.GetPrefSize(),
- aBitmapEx.GetPrefMapMode(), rDummyVDev.GetMapMode() ) );
- if( ! ( aSize.Width() && aSize.Height() ) )
- aSize = rDummyVDev.PixelToLogic( aBitmapEx.GetSizePixel() );
- ImplWriteBitmapEx( rWriter, rDummyVDev, pA->GetPoint(), aSize, aBitmapEx );
- }
- break;
-
- case( META_BMPSCALE_ACTION ):
- {
- const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*) pAction;
- ImplWriteBitmapEx( rWriter, rDummyVDev, pA->GetPoint(), pA->GetSize(), BitmapEx( pA->GetBitmap() ) );
- }
- break;
-
- case( META_BMPSCALEPART_ACTION ):
- {
- const MetaBmpScalePartAction* pA = (const MetaBmpScalePartAction*) pAction;
- BitmapEx aBitmapEx( pA->GetBitmap() );
- aBitmapEx.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) );
- ImplWriteBitmapEx( rWriter, rDummyVDev, pA->GetDestPoint(), pA->GetDestSize(), aBitmapEx );
- }
- break;
-
- case( META_BMPEX_ACTION ):
- {
- const MetaBmpExAction* pA = (const MetaBmpExAction*) pAction;
- BitmapEx aBitmapEx( pA->GetBitmapEx() );
- Size aSize( OutputDevice::LogicToLogic( aBitmapEx.GetPrefSize(),
- aBitmapEx.GetPrefMapMode(), rDummyVDev.GetMapMode() ) );
- ImplWriteBitmapEx( rWriter, rDummyVDev, pA->GetPoint(), aSize, aBitmapEx );
- }
- break;
-
- case( META_BMPEXSCALE_ACTION ):
- {
- const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*) pAction;
- ImplWriteBitmapEx( rWriter, rDummyVDev, pA->GetPoint(), pA->GetSize(), pA->GetBitmapEx() );
- }
- break;
-
- case( META_BMPEXSCALEPART_ACTION ):
- {
- const MetaBmpExScalePartAction* pA = (const MetaBmpExScalePartAction*) pAction;
- BitmapEx aBitmapEx( pA->GetBitmapEx() );
- aBitmapEx.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) );
- ImplWriteBitmapEx( rWriter, rDummyVDev, pA->GetDestPoint(), pA->GetDestSize(), aBitmapEx );
- }
- break;
-
- case( META_MASK_ACTION ):
- case( META_MASKSCALE_ACTION ):
- case( META_MASKSCALEPART_ACTION ):
- {
- DBG_ERROR( "MetaMask...Action not supported yet" );
- }
- break;
-
- case( META_TEXT_ACTION ):
- {
- const MetaTextAction* pA = (const MetaTextAction*) pAction;
- rWriter.DrawText( pA->GetPoint(), String( pA->GetText(), pA->GetIndex(), pA->GetLen() ) );
- }
- break;
-
- case( META_TEXTRECT_ACTION ):
- {
- const MetaTextRectAction* pA = (const MetaTextRectAction*) pAction;
- rWriter.DrawText( pA->GetRect(), String( pA->GetText() ), pA->GetStyle() );
- }
- break;
-
- case( META_TEXTARRAY_ACTION ):
- {
- const MetaTextArrayAction* pA = (const MetaTextArrayAction*) pAction;
- rWriter.DrawTextArray( pA->GetPoint(), pA->GetText(), pA->GetDXArray(), pA->GetIndex(), pA->GetLen() );
- }
- break;
-
- case( META_STRETCHTEXT_ACTION ):
- {
- const MetaStretchTextAction* pA = (const MetaStretchTextAction*) pAction;
- rWriter.DrawStretchText( pA->GetPoint(), pA->GetWidth(), pA->GetText(), pA->GetIndex(), pA->GetLen() );
- }
- break;
-
-
- case( META_TEXTLINE_ACTION ):
- {
- const MetaTextLineAction* pA = (const MetaTextLineAction*) pAction;
- rWriter.DrawTextLine( pA->GetStartPoint(), pA->GetWidth(), pA->GetStrikeout(), pA->GetUnderline(), pA->GetOverline() );
-
- }
- break;
-
- case( META_CLIPREGION_ACTION ):
- {
- const MetaClipRegionAction* pA = (const MetaClipRegionAction*) pAction;
-
- if( pA->IsClipping() )
- {
- if( pA->GetRegion().IsEmpty() )
- rWriter.SetClipRegion( basegfx::B2DPolyPolygon() );
- else
- {
- Region aReg( pA->GetRegion() );
- rWriter.SetClipRegion( aReg.ConvertToB2DPolyPolygon() );
- }
- }
- else
- rWriter.SetClipRegion();
- }
- break;
-
- case( META_ISECTRECTCLIPREGION_ACTION ):
- {
- const MetaISectRectClipRegionAction* pA = (const MetaISectRectClipRegionAction*) pAction;
- rWriter.IntersectClipRegion( pA->GetRect() );
- }
- break;
-
- case( META_ISECTREGIONCLIPREGION_ACTION ):
- {
- const MetaISectRegionClipRegionAction* pA = (const MetaISectRegionClipRegionAction*) pAction;
- Region aReg( pA->GetRegion() );
- rWriter.IntersectClipRegion( aReg.ConvertToB2DPolyPolygon() );
- }
- break;
-
- case( META_MOVECLIPREGION_ACTION ):
- {
- const MetaMoveClipRegionAction* pA = (const MetaMoveClipRegionAction*) pAction;
- rWriter.MoveClipRegion( pA->GetHorzMove(), pA->GetVertMove() );
- }
- break;
-
- case( META_MAPMODE_ACTION ):
- {
- const_cast< MetaAction* >( pAction )->Execute( &rDummyVDev );
- rWriter.SetMapMode( rDummyVDev.GetMapMode() );
- }
- break;
-
- case( META_LINECOLOR_ACTION ):
- {
- const MetaLineColorAction* pA = (const MetaLineColorAction*) pAction;
-
- if( pA->IsSetting() )
- rWriter.SetLineColor( pA->GetColor() );
- else
- rWriter.SetLineColor();
- }
- break;
-
- case( META_FILLCOLOR_ACTION ):
- {
- const MetaFillColorAction* pA = (const MetaFillColorAction*) pAction;
-
- if( pA->IsSetting() )
- rWriter.SetFillColor( pA->GetColor() );
- else
- rWriter.SetFillColor();
- }
- break;
-
- case( META_TEXTLINECOLOR_ACTION ):
- {
- const MetaTextLineColorAction* pA = (const MetaTextLineColorAction*) pAction;
-
- if( pA->IsSetting() )
- rWriter.SetTextLineColor( pA->GetColor() );
- else
- rWriter.SetTextLineColor();
- }
- break;
-
- case( META_OVERLINECOLOR_ACTION ):
- {
- const MetaOverlineColorAction* pA = (const MetaOverlineColorAction*) pAction;
-
- if( pA->IsSetting() )
- rWriter.SetOverlineColor( pA->GetColor() );
- else
- rWriter.SetOverlineColor();
- }
- break;
-
- case( META_TEXTFILLCOLOR_ACTION ):
- {
- const MetaTextFillColorAction* pA = (const MetaTextFillColorAction*) pAction;
-
- if( pA->IsSetting() )
- rWriter.SetTextFillColor( pA->GetColor() );
- else
- rWriter.SetTextFillColor();
- }
- break;
-
- case( META_TEXTCOLOR_ACTION ):
- {
- const MetaTextColorAction* pA = (const MetaTextColorAction*) pAction;
- rWriter.SetTextColor( pA->GetColor() );
- }
- break;
-
- case( META_TEXTALIGN_ACTION ):
- {
- const MetaTextAlignAction* pA = (const MetaTextAlignAction*) pAction;
- rWriter.SetTextAlign( pA->GetTextAlign() );
- }
- break;
-
- case( META_FONT_ACTION ):
- {
- const MetaFontAction* pA = (const MetaFontAction*) pAction;
- rWriter.SetFont( pA->GetFont() );
- }
- break;
-
- case( META_PUSH_ACTION ):
- {
- const MetaPushAction* pA = (const MetaPushAction*) pAction;
-
- rDummyVDev.Push( pA->GetFlags() );
- rWriter.Push( pA->GetFlags() );
- }
- break;
-
- case( META_POP_ACTION ):
- {
- rDummyVDev.Pop();
- rWriter.Pop();
- }
- break;
-
- case( META_LAYOUTMODE_ACTION ):
- {
- const MetaLayoutModeAction* pA = (const MetaLayoutModeAction*) pAction;
- rWriter.SetLayoutMode( pA->GetLayoutMode() );
- }
- break;
-
- case META_TEXTLANGUAGE_ACTION:
- {
- const MetaTextLanguageAction* pA = (const MetaTextLanguageAction*) pAction;
- rWriter.SetDigitLanguage( pA->GetTextLanguage() );
- }
- break;
-
- case( META_WALLPAPER_ACTION ):
- {
- const MetaWallpaperAction* pA = (const MetaWallpaperAction*) pAction;
- rWriter.DrawWallpaper( pA->GetRect(), pA->GetWallpaper() );
- }
- break;
-
- case( META_RASTEROP_ACTION ):
- {
- // !!! >>> we don't want to support this actions
- }
- break;
-
- case( META_REFPOINT_ACTION ):
- {
- // !!! >>> we don't want to support this actions
- }
- break;
-
- default:
- // #i24604# Made assertion fire only once per
- // metafile. The asserted actions here are all
- // deprecated
- if( !bAssertionFired )
- {
- bAssertionFired = true;
- DBG_ERROR( "PDFExport::ImplWriteActions: deprecated and unsupported MetaAction encountered" );
- }
- break;
- }
- i++;
- }
- }
-
- return sal_True;
-}
-
-// -----------------------------------------------------------------------------
-
-void PDFExport::ImplWriteGradient( PDFWriter& rWriter, const PolyPolygon& rPolyPoly, const Gradient& rGradient, VirtualDevice& rDummyVDev )
-{
- GDIMetaFile aTmpMtf;
-
- rDummyVDev.AddGradientActions( rPolyPoly.GetBoundRect(), rGradient, aTmpMtf );
-
- rWriter.Push();
- rWriter.IntersectClipRegion( rPolyPoly.getB2DPolyPolygon() );
- ImplWriteActions( rWriter, NULL, aTmpMtf, rDummyVDev );
- rWriter.Pop();
-}
-
-// -----------------------------------------------------------------------------
-
-void PDFExport::ImplWriteBitmapEx( PDFWriter& rWriter, VirtualDevice& rDummyVDev,
- const Point& rPoint, const Size& rSize, const BitmapEx& rBitmapEx )
-{
- if ( !rBitmapEx.IsEmpty() && rSize.Width() && rSize.Height() )
- {
- BitmapEx aBitmapEx( rBitmapEx );
- Point aPoint( rPoint );
- Size aSize( rSize );
-
- // #i19065# Negative sizes have mirror semantics on
- // OutputDevice. BitmapEx and co. have no idea about that, so
- // perform that _before_ doing anything with aBitmapEx.
- ULONG nMirrorFlags(BMP_MIRROR_NONE);
- if( aSize.Width() < 0 )
- {
- aSize.Width() *= -1;
- aPoint.X() -= aSize.Width();
- nMirrorFlags |= BMP_MIRROR_HORZ;
- }
- if( aSize.Height() < 0 )
- {
- aSize.Height() *= -1;
- aPoint.Y() -= aSize.Height();
- nMirrorFlags |= BMP_MIRROR_VERT;
- }
-
- if( nMirrorFlags != BMP_MIRROR_NONE )
- {
- aBitmapEx.Mirror( nMirrorFlags );
- }
- if ( mbReduceImageResolution )
- {
- // do downsampling if neccessary
- const Size aDstSizeTwip( rDummyVDev.PixelToLogic( rDummyVDev.LogicToPixel( aSize ), MAP_TWIP ) );
- const Size aBmpSize( aBitmapEx.GetSizePixel() );
- const double fBmpPixelX = aBmpSize.Width();
- const double fBmpPixelY = aBmpSize.Height();
- const double fMaxPixelX = aDstSizeTwip.Width() * mnMaxImageResolution / 1440.0;
- const double fMaxPixelY = aDstSizeTwip.Height() * mnMaxImageResolution / 1440.0;
-
- // check, if the bitmap DPI exceeds the maximum DPI (allow 4 pixel rounding tolerance)
- if( ( ( fBmpPixelX > ( fMaxPixelX + 4 ) ) ||
- ( fBmpPixelY > ( fMaxPixelY + 4 ) ) ) &&
- ( fBmpPixelY > 0.0 ) && ( fMaxPixelY > 0.0 ) )
- {
- // do scaling
- Size aNewBmpSize;
- const double fBmpWH = fBmpPixelX / fBmpPixelY;
- const double fMaxWH = fMaxPixelX / fMaxPixelY;
-
- if( fBmpWH < fMaxWH )
- {
- aNewBmpSize.Width() = FRound( fMaxPixelY * fBmpWH );
- aNewBmpSize.Height() = FRound( fMaxPixelY );
- }
- else if( fBmpWH > 0.0 )
- {
- aNewBmpSize.Width() = FRound( fMaxPixelX );
- aNewBmpSize.Height() = FRound( fMaxPixelX / fBmpWH);
- }
- if( aNewBmpSize.Width() && aNewBmpSize.Height() )
- aBitmapEx.Scale( aNewBmpSize );
- else
- aBitmapEx.SetEmpty();
- }
- }
-
- const Size aSizePixel( aBitmapEx.GetSizePixel() );
- if ( aSizePixel.Width() && aSizePixel.Height() )
- {
- sal_Bool bUseJPGCompression = !mbUseLosslessCompression;
- if ( ( aSizePixel.Width() < 32 ) || ( aSizePixel.Height() < 32 ) )
- bUseJPGCompression = sal_False;
-
- SvMemoryStream aStrm;
- Bitmap aMask;
-
- bool bTrueColorJPG = true;
- if ( bUseJPGCompression )
- {
- sal_uInt32 nZippedFileSize; // sj: we will calculate the filesize of a zipped bitmap
- { // to determine if jpeg compression is usefull
- SvMemoryStream aTemp;
- aTemp.SetCompressMode( aTemp.GetCompressMode() | COMPRESSMODE_ZBITMAP );
- aTemp.SetVersion( SOFFICE_FILEFORMAT_40 ); // sj: up from version 40 our bitmap stream operator
- aTemp << aBitmapEx; // is capable of zlib stream compression
- aTemp.Seek( STREAM_SEEK_TO_END );
- nZippedFileSize = aTemp.Tell();
- }
- if ( aBitmapEx.IsTransparent() )
- {
- if ( aBitmapEx.IsAlpha() )
- aMask = aBitmapEx.GetAlpha().GetBitmap();
- else
- aMask = aBitmapEx.GetMask();
- }
- GraphicFilter aGraphicFilter;
- Graphic aGraphic( aBitmapEx.GetBitmap() );
- sal_uInt16 nFormatName = aGraphicFilter.GetExportFormatNumberForShortName( OUString( RTL_CONSTASCII_USTRINGPARAM( "JPG" ) ) );
- sal_Int32 nColorMode = 0;
-
- Sequence< PropertyValue > aFilterData( 2 );
- aFilterData[ 0 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Quality" ) );
- aFilterData[ 0 ].Value <<= mnQuality;
- aFilterData[ 1 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "ColorMode" ) );
- aFilterData[ 1 ].Value <<= nColorMode;
-
- /*sal_uInt16 nError =*/ aGraphicFilter.ExportGraphic( aGraphic, String(), aStrm, nFormatName, &aFilterData );
- bTrueColorJPG = ((aGraphicFilter.GetExportGraphicHint() & GRFILTER_OUTHINT_GREY) == 0);
- aStrm.Seek( STREAM_SEEK_TO_END );
- if ( aStrm.Tell() > nZippedFileSize )
- bUseJPGCompression = sal_False;
- }
- if ( bUseJPGCompression )
- rWriter.DrawJPGBitmap( aStrm, bTrueColorJPG, aSizePixel, Rectangle( aPoint, aSize ), aMask );
- else if ( aBitmapEx.IsTransparent() )
- rWriter.DrawBitmapEx( aPoint, aSize, aBitmapEx );
- else
- rWriter.DrawBitmap( aPoint, aSize, aBitmapEx.GetBitmap() );
- }
- }
-}
-
diff --git a/filter/source/pdf/pdfexport.hxx b/filter/source/pdf/pdfexport.hxx
index 18c760b85675..71bee383133c 100644
--- a/filter/source/pdf/pdfexport.hxx
+++ b/filter/source/pdf/pdfexport.hxx
@@ -117,13 +117,6 @@ private:
//<---
sal_Bool ImplExportPage( ::vcl::PDFWriter& rWriter, ::vcl::PDFExtOutDevData& rPDFExtOutDevData,
const GDIMetaFile& rMtf );
- sal_Bool ImplWriteActions( ::vcl::PDFWriter& rWriter, ::vcl::PDFExtOutDevData* pPDFExtOutDevData,
- const GDIMetaFile& rMtf, VirtualDevice& rDummyVDev );
- void ImplWriteGradient( ::vcl::PDFWriter& rWriter, const PolyPolygon& rPolyPoly,
- const Gradient& rGradient, VirtualDevice& rDummyVDev );
- void ImplWriteBitmapEx( ::vcl::PDFWriter& rWriter, VirtualDevice& rDummyVDev,
- const Point& rPoint, const Size& rSize, const BitmapEx& rBitmap );
-
void ImplWriteWatermark( ::vcl::PDFWriter& rWriter, const Size& rPageSize );
public:
diff --git a/oox/inc/oox/drawingml/fillproperties.hxx b/oox/inc/oox/drawingml/fillproperties.hxx
index 42457e6f4dde..d62651ebdc20 100644
--- a/oox/inc/oox/drawingml/fillproperties.hxx
+++ b/oox/inc/oox/drawingml/fillproperties.hxx
@@ -117,6 +117,8 @@ struct BlipFillProperties
OptValue< sal_Int32 > moBitmapMode; /// Bitmap tile or stretch.
OptValue< ::com::sun::star::geometry::IntegerRectangle2D >
moFillRect; /// Stretch fill offsets.
+ OptValue< ::com::sun::star::geometry::IntegerRectangle2D >
+ moClipRect;
OptValue< sal_Int32 > moTileOffsetX; /// Width of bitmap tiles (EMUs).
OptValue< sal_Int32 > moTileOffsetY; /// Height of bitmap tiles (EMUs).
OptValue< sal_Int32 > moTileScaleX; /// Horizontal scaling of bitmap tiles (1/1000 percent).
diff --git a/oox/inc/oox/helper/graphichelper.hxx b/oox/inc/oox/helper/graphichelper.hxx
index 37002940cb17..1c112efcf923 100644
--- a/oox/inc/oox/helper/graphichelper.hxx
+++ b/oox/inc/oox/helper/graphichelper.hxx
@@ -148,6 +148,10 @@ public:
@return The URL of the created and internally cached graphic object. */
::rtl::OUString importEmbeddedGraphicObject( const ::rtl::OUString& rStreamName ) const;
+ /** calculates the orignal size of a graphic which is necessary to be able to calculate cropping values
+ @return The original Graphic size in 100thmm */
+ ::com::sun::star::awt::Size getOriginalSize( const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic ) const;
+
// ------------------------------------------------------------------------
private:
typedef ::std::map< sal_Int32, sal_Int32 > SystemPalette;
diff --git a/oox/inc/oox/ppt/slidepersist.hxx b/oox/inc/oox/ppt/slidepersist.hxx
index 31156a56ee84..bcb0c5803d61 100644
--- a/oox/inc/oox/ppt/slidepersist.hxx
+++ b/oox/inc/oox/ppt/slidepersist.hxx
@@ -91,6 +91,7 @@ public:
void setBackgroundProperties( const oox::drawingml::FillPropertiesPtr pFillPropertiesPtr ){ mpBackgroundPropertiesPtr = pFillPropertiesPtr; }
oox::drawingml::FillPropertiesPtr getBackgroundProperties() const { return mpBackgroundPropertiesPtr; }
+ oox::drawingml::Color& getBackgroundColorRef() { return maBackgroundColorRef; }
sal_Bool isMasterPage() const { return mbMaster; }
sal_Bool isNotesPage() const { return mbNotes; }
@@ -130,6 +131,7 @@ private:
SlidePersistPtr mpMasterPagePtr;
oox::drawingml::ShapePtr maShapesPtr;
+ oox::drawingml::Color maBackgroundColorRef;
oox::drawingml::FillPropertiesPtr mpBackgroundPropertiesPtr;
::std::list< boost::shared_ptr< TimeNode > > maTimeNodeList;
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index 168055935104..08d001f09a62 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -29,6 +29,7 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/awt/Gradient.hpp>
+#include <com/sun/star/text/GraphicCrop.hpp>
#include <com/sun/star/awt/Size.hpp>
#include <com/sun/star/drawing/BitmapMode.hpp>
#include <com/sun/star/drawing/ColorMode.hpp>
@@ -435,6 +436,26 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe
OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic );
if( aGraphicUrl.getLength() > 0 )
rPropMap[ PROP_GraphicURL ] <<= aGraphicUrl;
+
+ // cropping
+ if ( maBlipProps.moClipRect.has() )
+ {
+ geometry::IntegerRectangle2D oClipRect( maBlipProps.moClipRect.get() );
+ awt::Size aOriginalSize( rGraphicHelper.getOriginalSize( xGraphic ) );
+ if ( aOriginalSize.Width && aOriginalSize.Height )
+ {
+ text::GraphicCrop aGraphCrop( 0, 0, 0, 0 );
+ if ( oClipRect.X1 )
+ aGraphCrop.Left = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X1 ) / 100000 );
+ if ( oClipRect.Y1 )
+ aGraphCrop.Top = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y1 ) / 100000 );
+ if ( oClipRect.X2 )
+ aGraphCrop.Right = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X2 ) / 100000 );
+ if ( oClipRect.Y2 )
+ aGraphCrop.Bottom = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y2 ) / 100000 );
+ rPropMap[ PROP_GraphicCrop ] <<= aGraphCrop;
+ }
+ }
}
// color effect
diff --git a/oox/source/drawingml/fillpropertiesgroupcontext.cxx b/oox/source/drawingml/fillpropertiesgroupcontext.cxx
index b9d7fa7e1142..cb2037294786 100644
--- a/oox/source/drawingml/fillpropertiesgroupcontext.cxx
+++ b/oox/source/drawingml/fillpropertiesgroupcontext.cxx
@@ -225,7 +225,15 @@ Reference< XFastContextHandler > BlipFillContext::createFastChildContext(
return new BlipContext( *this, rxAttribs, mrBlipProps );
case A_TOKEN( srcRect ):
- // TODO
+ {
+ rtl::OUString aDefault( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "0" ) ) );
+ ::com::sun::star::geometry::IntegerRectangle2D aClipRect;
+ aClipRect.X1 = GetPercent( aAttribs.getString( XML_l, aDefault ) );
+ aClipRect.Y1 = GetPercent( aAttribs.getString( XML_t, aDefault ) );
+ aClipRect.X2 = GetPercent( aAttribs.getString( XML_r, aDefault ) );
+ aClipRect.Y2 = GetPercent( aAttribs.getString( XML_b, aDefault ) );
+ mrBlipProps.moClipRect = aClipRect;
+ }
break;
case A_TOKEN( tile ):
diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx
index 455778f939f7..ae664cf86668 100644
--- a/oox/source/helper/graphichelper.cxx
+++ b/oox/source/helper/graphichelper.cxx
@@ -38,6 +38,7 @@
#include <comphelper/seqstream.hxx>
#include "tokens.hxx"
#include "oox/helper/containerhelper.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
using ::rtl::OUString;
using ::com::sun::star::awt::DeviceInfo;
@@ -52,6 +53,7 @@ using ::com::sun::star::graphic::GraphicObject;
using ::com::sun::star::graphic::XGraphic;
using ::com::sun::star::graphic::XGraphicObject;
using ::com::sun::star::graphic::XGraphicProvider;
+using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::io::XInputStream;
using ::com::sun::star::lang::XMultiServiceFactory;
using ::com::sun::star::uno::Exception;
@@ -352,6 +354,29 @@ OUString GraphicHelper::importEmbeddedGraphicObject( const OUString& rStreamName
return xGraphic.is() ? createGraphicObject( xGraphic ) : OUString();
}
+Size GraphicHelper::getOriginalSize( const Reference< XGraphic >& xGraphic ) const
+{
+ Size aSize100thMM( 0, 0 );
+ Reference< XPropertySet > xGraphicPropertySet( xGraphic, UNO_QUERY_THROW );
+ if ( xGraphicPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Size100thMM" ) ) ) >>= aSize100thMM )
+ {
+ if ( !aSize100thMM.Width && !aSize100thMM.Height )
+ { // MAPMODE_PIXEL USED :-(
+ Size aSourceSizePixel( 0, 0 );
+ if ( xGraphicPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SizePixel" ) ) ) >>= aSourceSizePixel )
+ {
+ const DeviceInfo& rDeviceInfo = getDeviceInfo();
+ if ( rDeviceInfo.PixelPerMeterX && rDeviceInfo.PixelPerMeterY )
+ {
+ aSize100thMM.Width = static_cast< sal_Int32 >( ( aSourceSizePixel.Width * 100000.0 ) / rDeviceInfo.PixelPerMeterX );
+ aSize100thMM.Height = static_cast< sal_Int32 >( ( aSourceSizePixel.Height * 100000.0 ) / rDeviceInfo.PixelPerMeterY );
+ }
+ }
+ }
+ }
+ return aSize100thMM;
+}
+
// ============================================================================
} // namespace oox
diff --git a/oox/source/ppt/slidefragmenthandler.cxx b/oox/source/ppt/slidefragmenthandler.cxx
index 69f32e01e7eb..7e77f5a54938 100644
--- a/oox/source/ppt/slidefragmenthandler.cxx
+++ b/oox/source/ppt/slidefragmenthandler.cxx
@@ -145,7 +145,14 @@ Reference< XFastContextHandler > SlideFragmentHandler::createFastChildContext( s
mpSlidePersistPtr->setBackgroundProperties( pFillPropertiesPtr );
}
break;
+
case NMSP_PPT|XML_bgRef: // a:CT_StyleMatrixReference
+ {
+ FillPropertiesPtr pFillPropertiesPtr( new FillProperties(
+ *mpSlidePersistPtr->getTheme()->getFillStyle( xAttribs->getOptionalValue( XML_idx ).toInt32() ) ) );
+ xRet.set( new ColorContext( *this, mpSlidePersistPtr->getBackgroundColorRef() ) );
+ mpSlidePersistPtr->setBackgroundProperties( pFillPropertiesPtr );
+ }
break;
case NMSP_PPT|XML_clrMap: // CT_ColorMapping
diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index ce99ffc49f19..8555ba371b77 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -173,12 +173,17 @@ void SlidePersist::createBackground( const XmlFilterBase& rFilterBase )
{
try
{
+ sal_Int32 nPhClr = API_RGB_TRANSPARENT;
+ if ( maBackgroundColorRef.isUsed() )
+ nPhClr = maBackgroundColorRef.getColor( rFilterBase.getGraphicHelper() );
+
PropertyMap aPropMap;
static const rtl::OUString sBackground( RTL_CONSTASCII_USTRINGPARAM( "Background" ) );
uno::Reference< beans::XPropertySet > xPagePropSet( mxPage, uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySet > xPropertySet( aPropMap.makePropertySet() );
PropertySet aPropSet( xPropertySet );
- mpBackgroundPropertiesPtr->pushToPropSet( aPropSet, rFilterBase.getModelObjectHelper(), rFilterBase.getGraphicHelper() );
+ mpBackgroundPropertiesPtr->pushToPropSet( aPropSet, rFilterBase.getModelObjectHelper(),
+ rFilterBase.getGraphicHelper(), oox::drawingml::FillProperties::DEFAULT_IDS, 0, nPhClr );
xPagePropSet->setPropertyValue( sBackground, Any( xPropertySet ) );
}
catch( Exception )
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index da1aeb2ed265..ba51c3577a8e 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -166,6 +166,7 @@ Geometry3D
GradientName
Graphic
GraphicColorMode
+GraphicCrop
GraphicSize
GraphicURL
GridColor
diff --git a/unoxml/prj/build.lst b/unoxml/prj/build.lst
index cc54f6d3ad28..1a6b330c2c6b 100644
--- a/unoxml/prj/build.lst
+++ b/unoxml/prj/build.lst
@@ -4,3 +4,5 @@ ux unoxml\source\xpath nmake - all ux_xpath ux_dom NULL
ux unoxml\source\events nmake - all ux_events ux_dom NULL
ux unoxml\source\service nmake - all ux_service ux_dom ux_xpath ux_events NULL
ux unoxml\source\rdf nmake - all ux_librdf NULL
+
+ux unoxml\qa\complex\unoxml nmake - all ux_complex ux_librdf NULL
diff --git a/unoxml/qa/complex/tests.sce b/unoxml/qa/complex/tests.sce
deleted file mode 100644
index 20596551f156..000000000000
--- a/unoxml/qa/complex/tests.sce
+++ /dev/null
@@ -1 +0,0 @@
--o complex.unoxml.RDFRepositoryTest
diff --git a/unoxml/qa/complex/RDFRepositoryTest.java b/unoxml/qa/complex/unoxml/RDFRepositoryTest.java
index f3f9cbd8ae41..d047ef77440e 100644
--- a/unoxml/qa/complex/RDFRepositoryTest.java
+++ b/unoxml/qa/complex/unoxml/RDFRepositoryTest.java
@@ -27,21 +27,16 @@
package complex.unoxml;
-import complexlib.ComplexTestCase;
import helper.StreamSimulator;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
-import com.sun.star.uno.Any;
import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.lang.XInitialization;
-import com.sun.star.lang.XEventListener;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.lang.WrappedTargetException;
import com.sun.star.lang.WrappedTargetRuntimeException;
import com.sun.star.beans.XPropertySet;
-import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.Pair;
import com.sun.star.beans.StringPair;
import com.sun.star.container.XEnumeration;
@@ -52,6 +47,15 @@ import com.sun.star.io.XOutputStream;
import com.sun.star.text.XTextRange;
import com.sun.star.text.XText;
import com.sun.star.rdf.*;
+import lib.TestParameters;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
/**
* Test case for service com.sun.star.rdf.Repository
@@ -60,7 +64,7 @@ import com.sun.star.rdf.*;
*
* @author mst
*/
-public class RDFRepositoryTest extends ComplexTestCase
+public class RDFRepositoryTest
{
XComponentContext xContext;
String tempDir;
@@ -80,112 +84,113 @@ public class RDFRepositoryTest extends ComplexTestCase
XLiteral littype;
String rdfs = "http://www.w3.org/2000/01/rdf-schema#";
- public String[] getTestMethodNames ()
- {
- return new String[] { "check", "checkSPARQL", "checkRDFa" };
- }
+ /**
+ * The test parameters
+ */
+ private static TestParameters param = null;
+
+// public String[] getTestMethodNames ()
+// {
+// return new String[] { "check", "checkSPARQL", "checkRDFa" };
+// }
- public void before()
+ @Before public void before()
{
try {
- XMultiServiceFactory xMSF = (XMultiServiceFactory) param.getMSF();
- assure("could not create MultiServiceFactory.", xMSF != null);
- XPropertySet xPropertySet = (XPropertySet)
- UnoRuntime.queryInterface(XPropertySet.class, xMSF);
+ XMultiServiceFactory xMSF = getMSF();
+ param = new TestParameters();
+ param.put("ServiceFactory", xMSF);
+
+ assertNotNull("could not create MultiServiceFactory.", xMSF);
+ XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xMSF);
Object defaultCtx = xPropertySet.getPropertyValue("DefaultContext");
- xContext = (XComponentContext)
- UnoRuntime.queryInterface(XComponentContext.class, defaultCtx);
- assure("could not get component context.", xContext != null);
+ xContext = UnoRuntime.queryInterface(XComponentContext.class, defaultCtx);
+ assertNotNull("could not get component context.", xContext);
tempDir = util.utils.getOfficeTemp/*Dir*/(xMSF);
- log.println("tempdir: " + tempDir);
+ System.out.println("tempdir: " + tempDir);
foo = URI.create(xContext, "uri:foo");
- assure("foo", null != foo);
+ assertNotNull("foo", foo);
bar = URI.create(xContext, "uri:bar");
- assure("bar", null != bar);
+ assertNotNull("bar", bar);
baz = URI.create(xContext, "uri:baz");
- assure("baz", null != baz);
+ assertNotNull("baz", baz);
uint = URI.create(xContext, "uri:int");
- assure("uint", null != uint);
+ assertNotNull("uint", uint);
blank = BlankNode.create(xContext, "_:uno");
- assure("blank", null != blank);
+ assertNotNull("blank", blank);
lit = Literal.create(xContext, "i am the literal");
- assure("lit", null != lit);
+ assertNotNull("lit", lit);
litlang = Literal.createWithLanguage(xContext,
"i am the literal", "en");
- assure("litlang", null != litlang);
+ assertNotNull("litlang", litlang);
littype = Literal.createWithType(xContext, "42", uint);
- assure("littype", null != littype);
+ assertNotNull("littype", littype);
rdfslabel = URI.create(xContext, rdfs + "label");
- assure("rdfslabel", null != rdfslabel);
+ assertNotNull("rdfslabel", rdfslabel);
manifest = URI.create(xContext, "manifest:manifest"); //FIXME
- assure("manifest", null != manifest);
+ assertNotNull("manifest", manifest);
uuid = URI.create(xContext,
"urn:uuid:224ab023-77b8-4396-a75a-8cecd85b81e3");
- assure("uuid", null != uuid);
+ assertNotNull("uuid", uuid);
base = URI.create(xContext, "base-uri:"); //FIXME
- assure("base", null != base);
+ assertNotNull("base", base);
} catch (Exception e) {
report(e);
}
+ //FIXME: ?
+// xRep = Repository.create(xContext);
+ System.out.println("Creating service Repository...");
+ xRep = UnoRuntime.queryInterface(XDocumentRepository.class, Repository.create(xContext));
+ assertNotNull("null", xRep);
+ System.out.println("...done");
}
- public void after()
+ @After public void after()
{
xRep = null;
}
- public void check()
+ @Test public void check()
{
try {
-
- log.println("Creating service Repository...");
-
- //FIXME: ?
-// xRep = Repository.create(xContext);
- xRep = (XDocumentRepository) UnoRuntime.queryInterface(
- XDocumentRepository.class, Repository.create(xContext));
- assure("null", null != xRep);
-
- log.println("...done");
-
- log.println("Checking that new repository is really empty...");
- assure("empty: graphs", 0 == xRep.getGraphNames().length);
+ System.out.println("Checking that new repository is really empty...");
+ assertTrue("empty: graphs", 0 == xRep.getGraphNames().length);
XEnumeration stmts;
stmts = xRep.getStatements(null, null, null);
- assure("empty: stmts", !stmts.hasMoreElements());
+ assertTrue("empty: stmts", !stmts.hasMoreElements());
- log.println("...done");
+ System.out.println("...done");
- log.println("Checking graph creation...");
+ System.out.println("Checking graph creation...");
XNamedGraph xFooGraph = xRep.createGraph(foo);
- assure("foo graph", null != xFooGraph);
+ assertNotNull("foo graph", xFooGraph);
try {
xRep.createGraph(foo);
- assure("creating duplicate graph was allowed", false);
+ assertFalse("creating duplicate graph was allowed", false);
} catch (ElementExistException e) {
// ignore
}
try {
xRep.createGraph(null);
- assure("invalid graph name was allowed", false);
+ assertFalse("invalid graph name was allowed", false);
} catch (IllegalArgumentException e) {
// ignore
}
XURI[] names = xRep.getGraphNames();
- assure("no foo graph in getGraphNames",
+ assertTrue("no foo graph in getGraphNames",
1 == names.length && eq(names[0], foo));
- assure("no foo graph", null != xRep.getGraph(foo));
+ assertNotNull("no foo graph", xRep.getGraph(foo));
stmts = xFooGraph.getStatements(null, null, null);
- assure("stmts in foo graph", !stmts.hasMoreElements());
+ assertTrue("stmts in foo graph", !stmts.hasMoreElements());
XOutputStream xFooOut =
new StreamSimulator(tempDir + "empty.rdf", false, param);
@@ -195,94 +200,94 @@ public class RDFRepositoryTest extends ComplexTestCase
XInputStream xFooIn =
new StreamSimulator(tempDir + "empty.rdf", true, param);
xRep.importGraph(FileFormat.RDF_XML, xFooIn, bar, base);
- assure("no bar graph", null != xRep.getGraph(bar));
+ assertNotNull("no bar graph", xRep.getGraph(bar));
- log.println("...done");
+ System.out.println("...done");
- log.println("Checking graph manipulation...");
+ System.out.println("Checking graph manipulation...");
XEnumeration xFooEnum;
Statement xFoo_FooBarBaz = new Statement(foo, bar, baz, foo);
xFooGraph.addStatement(foo, bar, baz);
xFooEnum = xFooGraph.getStatements(null, null, null);
- assure("addStatement(foo,bar,baz)",
+ assertTrue("addStatement(foo,bar,baz)",
eq(xFooEnum, new Statement[] { xFoo_FooBarBaz }));
Statement xFoo_FooBarBlank = new Statement(foo, bar, blank, foo);
xFooGraph.addStatement(foo, bar, blank);
xFooEnum = xFooGraph.getStatements(null, null, null);
- assure("addStatement(foo,bar,blank)",
+ assertTrue("addStatement(foo,bar,blank)",
eq(xFooEnum,
new Statement[] { xFoo_FooBarBaz, xFoo_FooBarBlank }));
xFooEnum = xRep.getStatements(null, null, null);
- assure("addStatement(foo,bar,blank) (global)",
+ assertTrue("addStatement(foo,bar,blank) (global)",
eq(xFooEnum,
new Statement[] { xFoo_FooBarBaz, xFoo_FooBarBlank }));
Statement xFoo_BazBarLit = new Statement(baz, bar, lit, foo);
xFooGraph.addStatement(baz, bar, lit);
xFooEnum = xFooGraph.getStatements(null, null, null);
- assure("addStatement(baz,bar,lit)",
+ assertTrue("addStatement(baz,bar,lit)",
eq(xFooEnum, new Statement[] {
xFoo_FooBarBaz, xFoo_FooBarBlank, xFoo_BazBarLit }));
xFooEnum = xFooGraph.getStatements(baz, bar, null);
- assure("addStatement(baz,bar,lit) (baz,bar)",
+ assertTrue("addStatement(baz,bar,lit) (baz,bar)",
eq(xFooEnum, new Statement[] { xFoo_BazBarLit }));
Statement xFoo_BazBarLitlang =
new Statement(baz, bar, litlang, foo);
xFooGraph.addStatement(baz, bar, litlang);
xFooEnum = xFooGraph.getStatements(null, null, null);
- assure("addStatement(baz,bar,litlang)",
+ assertTrue("addStatement(baz,bar,litlang)",
eq(xFooEnum, new Statement[] {
xFoo_FooBarBaz, xFoo_FooBarBlank, xFoo_BazBarLit,
xFoo_BazBarLitlang }));
xFooEnum = xFooGraph.getStatements(null, null, baz);
- assure("addStatement(baz,bar,litlang) (baz)",
+ assertTrue("addStatement(baz,bar,litlang) (baz)",
eq(xFooEnum, new Statement[] { xFoo_FooBarBaz }));
Statement xFoo_BazBarLittype =
new Statement(baz, bar, littype, foo);
xFooGraph.addStatement(baz, bar, littype);
xFooEnum = xFooGraph.getStatements(null, null, null);
- assure("addStatement(baz,bar,littype)",
+ assertTrue("addStatement(baz,bar,littype)",
eq(xFooEnum, new Statement[] { xFoo_FooBarBaz, xFoo_FooBarBlank,
xFoo_BazBarLit, xFoo_BazBarLitlang, xFoo_BazBarLittype }));
xFooGraph.removeStatements(baz, bar, litlang);
xFooEnum = xFooGraph.getStatements(null, null, null);
- assure("removeStatement(baz,bar,litlang)",
+ assertTrue("removeStatement(baz,bar,litlang)",
eq(xFooEnum, new Statement[] { xFoo_FooBarBaz, xFoo_FooBarBlank,
xFoo_BazBarLit, xFoo_BazBarLittype }));
xFooGraph.removeStatements(foo, bar, null);
xFooEnum = xFooGraph.getStatements(null, null, null);
- assure("removeStatement(foo,bar,null)",
+ assertTrue("removeStatement(foo,bar,null)",
eq(xFooEnum, new Statement[] {
xFoo_BazBarLit, xFoo_BazBarLittype }));
xFooGraph.addStatement(foo, bar, baz);
xFooEnum = xFooGraph.getStatements(null, null, null);
- assure("addStatement(foo,bar,baz) (re-add)",
+ assertTrue("addStatement(foo,bar,baz) (re-add)",
eq(xFooEnum, new Statement[] { xFoo_FooBarBaz,
xFoo_BazBarLit, xFoo_BazBarLittype }));
xFooGraph.addStatement(foo, bar, baz);
xFooEnum = xFooGraph.getStatements(null, null, null);
- assure("addStatement(foo,bar,baz) (duplicate)",
+ assertTrue("addStatement(foo,bar,baz) (duplicate)",
eq(xFooEnum, new Statement[] { xFoo_FooBarBaz,
xFoo_BazBarLit, xFoo_BazBarLittype }));
xFooGraph.addStatement(xFooGraph, bar, baz);
xFooEnum = xFooGraph.getStatements(null, null, null);
- assure("addStatement(foo,bar,baz) (triplicate, as graph)",
+ assertTrue("addStatement(foo,bar,baz) (triplicate, as graph)",
eq(xFooEnum, new Statement[] { xFoo_FooBarBaz,
xFoo_BazBarLit, xFoo_BazBarLittype }));
- log.println("...done");
+ System.out.println("...done");
- log.println("Checking graph import/export...");
+ System.out.println("Checking graph import/export...");
xFooOut = new StreamSimulator(tempDir + "foo.rdf", false, param);
xRep.exportGraph(FileFormat.RDF_XML, xFooOut, foo, base);
@@ -291,7 +296,7 @@ public class RDFRepositoryTest extends ComplexTestCase
xFooIn = new StreamSimulator(tempDir + "foo.rdf", true, param);
try {
xRep.importGraph(FileFormat.RDF_XML, xFooIn, bar, base);
- assure("importing existing graph did not fail", false);
+ assertFalse("importing existing graph did not fail", false);
} catch (ElementExistException e) {
// ignore
}
@@ -299,77 +304,77 @@ public class RDFRepositoryTest extends ComplexTestCase
xFooIn = new StreamSimulator(tempDir + "foo.rdf", true, param);
xRep.importGraph(FileFormat.RDF_XML, xFooIn, baz, base);
XNamedGraph xBazGraph = xRep.getGraph(baz);
- assure("no baz graph", null != xBazGraph);
+ assertNotNull("no baz graph", xBazGraph);
Statement xBaz_FooBarBaz = new Statement(foo, bar, baz, baz);
Statement xBaz_BazBarLit = new Statement(baz, bar, lit, baz);
Statement xBaz_BazBarLittype =
new Statement(baz, bar, littype, baz);
XEnumeration xBazEnum = xBazGraph.getStatements(null, null, null);
- assure("importing exported graph",
+ assertTrue("importing exported graph",
eq(xBazEnum, new Statement[] {
xBaz_FooBarBaz, xBaz_BazBarLit, xBaz_BazBarLittype }));
- log.println("...done");
+ System.out.println("...done");
- log.println("Checking graph deletion...");
+ System.out.println("Checking graph deletion...");
xFooGraph.clear();
xFooEnum = xFooGraph.getStatements(null, null, null);
- assure("clear", eq(xFooEnum, new Statement[] { }));
+ assertTrue("clear", eq(xFooEnum, new Statement[] { }));
xRep.destroyGraph(baz);
- assure("baz graph zombie", null == xRep.getGraph(baz));
+ assertNull("baz graph zombie", xRep.getGraph(baz));
try {
xBazGraph.clear();
- assure("deleted graph not invalid (clear)", false);
+ assertFalse("deleted graph not invalid (clear)", false);
} catch (NoSuchElementException e) {
// ignore
}
try {
xBazGraph.addStatement(foo, foo, foo);
- assure("deleted graph not invalid (add)", false);
+ assertFalse("deleted graph not invalid (add)", false);
} catch (NoSuchElementException e) {
// ignore
}
try {
xBazGraph.removeStatements(null, null, null);
- assure("deleted graph not invalid (remove)", false);
+ assertFalse("deleted graph not invalid (remove)", false);
} catch (NoSuchElementException e) {
// ignore
}
try {
xBazGraph.getStatements(null, null, null);
- assure("deleted graph not invalid (get)", false);
+ assertFalse("deleted graph not invalid (get)", false);
} catch (NoSuchElementException e) {
// ignore
}
- log.println("...done");
+ System.out.println("...done");
} catch (Exception e) {
report(e);
}
}
- public void checkSPARQL()
+ @Test public void checkSPARQL()
{
try {
- log.println("Checking SPARQL queries...");
+ System.out.println("Checking SPARQL queries...");
- XInputStream xIn = new StreamSimulator(
- util.utils.getFullTestDocName("example.rdf"), true, param);
+ XInputStream xIn = new StreamSimulator(TestDocument.getUrl("example.rdf"), true, param);
+ // util.utils.getFullTestDocName("example.rdf"), true, param);
xRep.importGraph(FileFormat.RDF_XML, xIn, manifest, base);
String query;
query = "SELECT ?p WHERE { ?p rdf:type pkg:Package . }";
XQuerySelectResult result = xRep.querySelect(mkNss() + query);
- assure("query: package-id\n" + query,
+ assertTrue("query: package-id\n" + query,
eq(result, new String[] { "p" },
new XNode[][] { { uuid } }));
@@ -377,7 +382,7 @@ public class RDFRepositoryTest extends ComplexTestCase
"> WHERE { ?pkg rdf:type pkg:Package . ?pkg pkg:hasPart ?part ."
+ " ?part pkg:path ?path . ?part rdf:type odf:ContentFile. }";
result = xRep.querySelect(mkNss() + query);
- assure("query: contentfile",
+ assertTrue("query: contentfile",
eq(result, new String[] { "part", "path" },
new XNode[][] { { BlankNode.create(xContext, "whatever"),
Literal.create(xContext, "content.xml") } }));
@@ -386,7 +391,7 @@ public class RDFRepositoryTest extends ComplexTestCase
+ "?pkg rdf:type pkg:Package . ?pkg pkg:hasPart ?part . "
+ "?part pkg:path ?path . ?part rdf:type odf:ContentFile. }";
result = xRep.querySelect(mkNss() + query);
- assure("query: contentfile\n" + query,
+ assertTrue("query: contentfile\n" + query,
eq(result, new String[] { "pkg", "path" },
new XNode[][] { { uuid ,
Literal.create(xContext, "content.xml") } }));
@@ -395,7 +400,7 @@ public class RDFRepositoryTest extends ComplexTestCase
+ "?pkg rdf:type pkg:Package . ?pkg pkg:hasPart ?part . "
+ "?part pkg:path ?path . ?part rdf:type odf:StylesFile. }";
result = xRep.querySelect(mkNss() + query);
- assure("query: stylesfile\n" + query,
+ assertTrue("query: stylesfile\n" + query,
eq(result, new String[] { "part", "path" },
new XNode[][] { }));
@@ -403,7 +408,7 @@ public class RDFRepositoryTest extends ComplexTestCase
+ "?pkg rdf:type pkg:Package . ?pkg pkg:hasPart ?part . "
+ "?part pkg:path ?path . ?part rdf:type odf:MetadataFile. }";
result = xRep.querySelect(mkNss() + query);
- assure("query: metadatafile\n" + query,
+ assertTrue("query: metadatafile\n" + query,
eq(result, new String[] { "part", "path" },
new XNode[][] { {
URI.create(xContext, "http://hospital-employee/doctor"),
@@ -424,9 +429,9 @@ public class RDFRepositoryTest extends ComplexTestCase
+ " pkg:idref ?idref . "
+ " FILTER (?type = odf:ContentFile || ?type = odf:StylesFile)"
+ " }";
-//log.println(query);
+//System.out.println(query);
result = xRep.querySelect(mkNss() + query);
- assure("query: example-element-2\n" + query,
+ assertTrue("query: example-element-2\n" + query,
eq(result, new String[] { "path", "idref" },
new XNode[][] { {
Literal.create(xContext, "content.xml"),
@@ -438,24 +443,24 @@ public class RDFRepositoryTest extends ComplexTestCase
lit.getStringValue() + "\" } FROM <" + toS(manifest) +
"> WHERE { ?pkg rdf:type pkg:Package . } ";
XEnumeration xResultEnum = xRep.queryConstruct(mkNss() + query);
- assure("query: construct\n" + query,
+ assertTrue("query: construct\n" + query,
eq(xResultEnum, new Statement[] { x_PkgFooLit }));
query = "ASK { ?pkg rdf:type pkg:Package . }";
boolean bResult = xRep.queryAsk(mkNss() + query);
- assure("query: ask\n" + query, bResult);
+ assertTrue("query: ask\n" + query, bResult);
- log.println("...done");
+ System.out.println("...done");
} catch (Exception e) {
report(e);
}
}
- public void checkRDFa()
+ @Test public void checkRDFa()
{
try {
- log.println("Checking RDFa gunk...");
+ System.out.println("Checking RDFa gunk...");
String content = "behold, for i am the content.";
XTextRange xTR = new TestRange(content);
@@ -463,19 +468,19 @@ public class RDFRepositoryTest extends ComplexTestCase
Pair<Statement[], Boolean> result =
xRep.getStatementRDFa((XMetadatable)xTR);
- assure("RDFa: get: not empty (initial)",
+ assertTrue("RDFa: get: not empty (initial)",
0 == result.First.length);
try {
xRep.setStatementRDFa(foo, new XURI[] {}, xM, "", null);
- assure("RDFa: set: no predicate", false);
+ assertFalse("RDFa: set: no predicate", false);
} catch (IllegalArgumentException e) {
// ignore
}
try {
xRep.setStatementRDFa(foo, new XURI[] {bar}, null, "", null);
- assure("RDFa: set: null", false);
+ assertFalse("RDFa: set: null", false);
} catch (IllegalArgumentException e) {
// ignore
}
@@ -485,16 +490,16 @@ public class RDFRepositoryTest extends ComplexTestCase
xRep.setStatementRDFa(foo, new XURI[] { bar }, xM, "", null);
result = xRep.getStatementRDFa((XMetadatable)xTR);
- assure("RDFa: get: without content",
+ assertTrue("RDFa: get: without content",
!result.Second && (1 == result.First.length)
- && eq((Statement)result.First[0], x_FooBarTRLit));
+ && eq(result.First[0], x_FooBarTRLit));
//FIXME: do this?
xTR.setString(lit.getStringValue());
/*
Statement xFooBarLit = new Statement(foo, bar, lit, null);
result = xRep.getStatementRDFa((XMetadatable)xTR);
- assure("RDFa: get: change",
+ assertTrue("RDFa: get: change",
eq((Statement)result.First, xFooBarLit) && null == result.Second);
*/
@@ -502,17 +507,17 @@ public class RDFRepositoryTest extends ComplexTestCase
xRep.setStatementRDFa(foo, new XURI[] { bar }, xM, "42", uint);
result = xRep.getStatementRDFa((XMetadatable)xTR);
- assure("RDFa: get: with content",
+ assertTrue("RDFa: get: with content",
result.Second &&
(1 == result.First.length) &&
- eq((Statement)result.First[0], x_FooBarLittype));
+ eq(result.First[0], x_FooBarLittype));
//FIXME: do this?
xTR.setString(content);
/*
Statement xFooLabelTRLit = new Statement(foo, rdfslabel, trlit, null);
result = xRep.getStatementRDFa((XMetadatable)xTR);
- assure("RDFa: get: change (label)",
+ assertTrue("RDFa: get: change (label)",
eq((Statement)result.First, xFooBarLittype) &&
eq((Statement)result.Second, xFooLabelTRLit));
*/
@@ -520,7 +525,7 @@ public class RDFRepositoryTest extends ComplexTestCase
xRep.removeStatementRDFa((XMetadatable)xTR);
result = xRep.getStatementRDFa((XMetadatable)xTR);
- assure("RDFa: get: not empty (removed)",
+ assertTrue("RDFa: get: not empty (removed)",
0 == result.First.length);
xRep.setStatementRDFa(foo, new XURI[] { foo, bar, baz }, xM,
@@ -529,7 +534,7 @@ public class RDFRepositoryTest extends ComplexTestCase
Statement x_FooFooTRLit = new Statement(foo, foo, trlit, null);
Statement x_FooBazTRLit = new Statement(foo, baz, trlit, null);
result = xRep.getStatementRDFa((XMetadatable) xTR);
- assure("RDFa: get: without content (multiple predicates, reinsert)",
+ assertTrue("RDFa: get: without content (multiple predicates, reinsert)",
!result.Second &&
eq(result.First, new Statement[] {
x_FooFooTRLit, x_FooBarTRLit, x_FooBazTRLit }));
@@ -537,10 +542,10 @@ public class RDFRepositoryTest extends ComplexTestCase
xRep.removeStatementRDFa((XMetadatable)xTR);
result = xRep.getStatementRDFa((XMetadatable) xTR);
- assure("RDFa: get: not empty (re-removed)",
+ assertTrue("RDFa: get: not empty (re-removed)",
0 == result.First.length);
- log.println("...done");
+ System.out.println("...done");
} catch (Exception e) {
report(e);
@@ -553,36 +558,38 @@ public class RDFRepositoryTest extends ComplexTestCase
{
if (e instanceof WrappedTargetException)
{
- log.println("Cause:");
+ System.out.println("Cause:");
Exception cause = (Exception)
(((WrappedTargetException)e).TargetException);
- log.println(cause.toString());
+ System.out.println(cause.toString());
report2(cause);
} else if (e instanceof WrappedTargetRuntimeException) {
- log.println("Cause:");
+ System.out.println("Cause:");
Exception cause = (Exception)
(((WrappedTargetRuntimeException)e).TargetException);
- log.println(cause.toString());
+ System.out.println(cause.toString());
report2(cause);
}
}
public void report(Exception e) {
- log.println("Exception occurred:");
- e.printStackTrace((java.io.PrintWriter) log);
+ System.out.println("Exception occurred:");
+ e.printStackTrace();
report2(e);
- failed();
+ fail();
}
public static String toS(XNode n) {
- if (null == n) return "< null >";
+ if (null == n)
+ {
+ return "< null >";
+ }
return n.getStringValue();
}
static boolean isBlank(XNode i_node)
{
- XBlankNode blank = (XBlankNode) UnoRuntime.queryInterface(
- XBlankNode.class, i_node);
+ XBlankNode blank = UnoRuntime.queryInterface(XBlankNode.class, i_node);
return blank != null;
}
@@ -615,7 +622,7 @@ public class RDFRepositoryTest extends ComplexTestCase
java.util.Collection c = new java.util.Vector();
while (i_Enum.hasMoreElements()) {
Statement s = (Statement) i_Enum.nextElement();
-//log.println("toSeq: " + s.getSubject().getStringValue() + " " + s.getPredicate().getStringValue() + " " + s.getObject().getStringValue() + ".");
+//System.out.println("toSeq: " + s.getSubject().getStringValue() + " " + s.getPredicate().getStringValue() + " " + s.getObject().getStringValue() + ".");
c.add(s);
}
// return (Statement[]) c.toArray();
@@ -650,7 +657,10 @@ public class RDFRepositoryTest extends ComplexTestCase
{
XNode[] left = (XNode[]) i_Left;
XNode[] right = (XNode[]) i_Right;
- if (left.length != right.length) throw new RuntimeException();
+ if (left.length != right.length)
+ {
+ throw new RuntimeException();
+ }
for (int i = 0; i < left.length; ++i) {
int eq = (left[i].getStringValue().compareTo(
right[i].getStringValue()));
@@ -667,10 +677,22 @@ public class RDFRepositoryTest extends ComplexTestCase
int eq;
Statement left = (Statement) i_Left;
Statement right = (Statement) i_Right;
- if ((eq = cmp(left.Graph, right.Graph )) != 0) return eq;
- if ((eq = cmp(left.Subject, right.Subject )) != 0) return eq;
- if ((eq = cmp(left.Predicate, right.Predicate)) != 0) return eq;
- if ((eq = cmp(left.Object, right.Object )) != 0) return eq;
+ if ((eq = cmp(left.Graph, right.Graph )) != 0)
+ {
+ return eq;
+ }
+ if ((eq = cmp(left.Subject, right.Subject )) != 0)
+ {
+ return eq;
+ }
+ if ((eq = cmp(left.Predicate, right.Predicate)) != 0)
+ {
+ return eq;
+ }
+ if ((eq = cmp(left.Object, right.Object )) != 0)
+ {
+ return eq;
+ }
return 0;
}
@@ -693,23 +715,23 @@ public class RDFRepositoryTest extends ComplexTestCase
XURI lG = i_Left.Graph;
XURI rG = i_Right.Graph;
if (!eq(lG, rG)) {
- log.println("Graphs differ: " + toS(lG) + " != " + toS(rG));
+ System.out.println("Graphs differ: " + toS(lG) + " != " + toS(rG));
return false;
}
if (!eq(i_Left.Subject, i_Right.Subject)) {
- log.println("Subjects differ: " +
+ System.out.println("Subjects differ: " +
i_Left.Subject.getStringValue() + " != " +
i_Right.Subject.getStringValue());
return false;
}
if (!eq(i_Left.Predicate, i_Right.Predicate)) {
- log.println("Predicates differ: " +
+ System.out.println("Predicates differ: " +
i_Left.Predicate.getStringValue() + " != " +
i_Right.Predicate.getStringValue());
return false;
}
if (!eq(i_Left.Object, i_Right.Object)) {
- log.println("Objects differ: " +
+ System.out.println("Objects differ: " +
i_Left.Object.getStringValue() + " != " +
i_Right.Object.getStringValue());
return false;
@@ -720,7 +742,7 @@ public class RDFRepositoryTest extends ComplexTestCase
static boolean eq(Statement[] i_Result, Statement[] i_Expected)
{
if (i_Result.length != i_Expected.length) {
- log.println("eq: different lengths: " + i_Result.length + " " +
+ System.out.println("eq: different lengths: " + i_Result.length + " " +
i_Expected.length);
return false;
}
@@ -729,7 +751,10 @@ public class RDFRepositoryTest extends ComplexTestCase
java.util.Arrays.sort(i_Result, new StmtComp());
java.util.Arrays.sort(expected, new StmtComp());
for (int i = 0; i < expected.length; ++i) {
- if (!eq(i_Result[i], expected[i])) return false;
+ if (!eq(i_Result[i], expected[i]))
+ {
+ return false;
+ }
}
return true;
}
@@ -760,11 +785,11 @@ public class RDFRepositoryTest extends ComplexTestCase
XEnumeration iter = (XEnumeration) i_Result;
XNode[][] bindings = toSeqs(iter);
if (vars.length != i_Vars.length) {
- log.println("var lengths differ");
+ System.out.println("var lengths differ");
return false;
}
if (bindings.length != i_Bindings.length) {
- log.println("binding lengths differ: " + i_Bindings.length +
+ System.out.println("binding lengths differ: " + i_Bindings.length +
" vs " + bindings.length );
return false;
}
@@ -772,16 +797,16 @@ public class RDFRepositoryTest extends ComplexTestCase
java.util.Arrays.sort(i_Bindings, new BindingComp());
for (int i = 0; i < i_Bindings.length; ++i) {
if (i_Bindings[i].length != i_Vars.length) {
- log.println("TEST ERROR!");
+ System.out.println("TEST ERROR!");
throw new Exception();
}
if (bindings[i].length != i_Vars.length) {
- log.println("binding length and var length differ");
+ System.out.println("binding length and var length differ");
return false;
}
for (int j = 0; j < i_Vars.length; ++j) {
if (!eq(bindings[i][j], i_Bindings[i][j])) {
- log.println("bindings differ: " +
+ System.out.println("bindings differ: " +
toS(bindings[i][j]) + " != " + toS(i_Bindings[i][j]));
return false;
}
@@ -789,7 +814,7 @@ public class RDFRepositoryTest extends ComplexTestCase
}
for (int i = 0; i < i_Vars.length; ++i) {
if (!vars[i].equals(i_Vars[i])) {
- log.println("variable names differ: " +
+ System.out.println("variable names differ: " +
vars[i] + " != " + i_Vars[i]);
return false;
}
@@ -828,7 +853,7 @@ public class RDFRepositoryTest extends ComplexTestCase
{ return new StringPair(m_Stream, m_XmlId); }
public void setMetadataReference(StringPair i_Ref)
throws IllegalArgumentException
- { m_Stream = (String)i_Ref.First; m_XmlId = (String)i_Ref.Second; }
+ { m_Stream = i_Ref.First; m_XmlId = i_Ref.Second; }
public void ensureMetadataReference()
{ m_Stream = "content.xml"; m_XmlId = "42"; }
@@ -843,5 +868,26 @@ public class RDFRepositoryTest extends ComplexTestCase
public String getString() { return m_Text; }
public void setString(String i_Str) { m_Text = i_Str; }
}
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass public static void setUpConnection() throws Exception {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+
+ private static final OfficeConnection connection = new OfficeConnection();
}
diff --git a/unoxml/qa/complex/unoxml/TestDocument.java b/unoxml/qa/complex/unoxml/TestDocument.java
new file mode 100644
index 000000000000..bce9510e4d94
--- /dev/null
+++ b/unoxml/qa/complex/unoxml/TestDocument.java
@@ -0,0 +1,39 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org 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 version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
+
+package complex.unoxml;
+
+import java.io.File;
+import org.openoffice.test.OfficeFileUrl;
+
+final class TestDocument {
+ public static String getUrl(String name) {
+ return OfficeFileUrl.getAbsolute(new File("testdocuments", name));
+ }
+
+ private TestDocument() {}
+}
diff --git a/unoxml/qa/complex/makefile.mk b/unoxml/qa/complex/unoxml/makefile.mk
index c74cbcb80dcf..136d23a9a232 100644
--- a/unoxml/qa/complex/makefile.mk
+++ b/unoxml/qa/complex/unoxml/makefile.mk
@@ -25,35 +25,35 @@
#
#***********************************************************************/
-PRJ = ..$/..
-TARGET = unoxml_test
-PRJNAME = $(TARGET)
-PACKAGE = complex$/unoxml
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
-# --- Settings -----------------------------------------------------
-.INCLUDE: settings.mk
-
-
-#----- compile .java files -----------------------------------------
+PRJ = ../../..
+PRJNAME = unoxml
+TARGET = qa_complex_unoxml
-JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
-JAVAFILES = RDFRepositoryTest.java \
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/unoxml
+JAVATESTFILES = \
+ RDFRepositoryTest.java
-JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+JAVAFILES = $(JAVATESTFILES) \
+ TestDocument.java
-#----- make a jar from compiled files ------------------------------
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar jurt.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
-MAXLINELENGTH = 100000
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+.END
-JARCLASSDIRS = $(PACKAGE)
-JARTARGET = $(TARGET).jar
-JARCOMPRESS = TRUE
-
-# --- Targets ------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
-.INCLUDE : target.mk
+ALLTAR : javatest
+.END
-run:
- +java -cp $(CLASSPATH) org.openoffice.Runner -TestBase java_complex -sce tests.sce -tdoc $(PWD)$/testdocuments
diff --git a/unoxml/qa/complex/testdocuments/example.rdf b/unoxml/qa/complex/unoxml/testdocuments/example.rdf
index 07ef7f07b6fd..07ef7f07b6fd 100644
--- a/unoxml/qa/complex/testdocuments/example.rdf
+++ b/unoxml/qa/complex/unoxml/testdocuments/example.rdf