1*f5a7bb7cSJürgen Schmidt /************************************************************** 2*f5a7bb7cSJürgen Schmidt * 3*f5a7bb7cSJürgen Schmidt * Licensed to the Apache Software Foundation (ASF) under one 4*f5a7bb7cSJürgen Schmidt * or more contributor license agreements. See the NOTICE file 5*f5a7bb7cSJürgen Schmidt * distributed with this work for additional information 6*f5a7bb7cSJürgen Schmidt * regarding copyright ownership. The ASF licenses this file 7*f5a7bb7cSJürgen Schmidt * to you under the Apache License, Version 2.0 (the 8*f5a7bb7cSJürgen Schmidt * "License"); you may not use this file except in compliance 9*f5a7bb7cSJürgen Schmidt * with the License. You may obtain a copy of the License at 10*f5a7bb7cSJürgen Schmidt * 11*f5a7bb7cSJürgen Schmidt * http://www.apache.org/licenses/LICENSE-2.0 12*f5a7bb7cSJürgen Schmidt * 13*f5a7bb7cSJürgen Schmidt * Unless required by applicable law or agreed to in writing, 14*f5a7bb7cSJürgen Schmidt * software distributed under the License is distributed on an 15*f5a7bb7cSJürgen Schmidt * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f5a7bb7cSJürgen Schmidt * KIND, either express or implied. See the License for the 17*f5a7bb7cSJürgen Schmidt * specific language governing permissions and limitations 18*f5a7bb7cSJürgen Schmidt * under the License. 19*f5a7bb7cSJürgen Schmidt * 20*f5a7bb7cSJürgen Schmidt *************************************************************/ 211ff9903bSLi Feng Wang package fvt.uno.sw.frame; 221ff9903bSLi Feng Wang 231ff9903bSLi Feng Wang import static org.junit.Assert.*; 241ff9903bSLi Feng Wang 251ff9903bSLi Feng Wang import java.util.Arrays; 261ff9903bSLi Feng Wang import java.util.Collection; 271ff9903bSLi Feng Wang 281ff9903bSLi Feng Wang import org.junit.After; 291ff9903bSLi Feng Wang import org.junit.AfterClass; 301ff9903bSLi Feng Wang import org.junit.Before; 311ff9903bSLi Feng Wang import org.junit.Test; 321ff9903bSLi Feng Wang import org.junit.runner.RunWith; 331ff9903bSLi Feng Wang import org.junit.runners.Parameterized; 341ff9903bSLi Feng Wang import org.junit.runners.Parameterized.Parameters; 351ff9903bSLi Feng Wang import org.openoffice.test.common.Testspace; 361ff9903bSLi Feng Wang import org.openoffice.test.uno.UnoApp; 371ff9903bSLi Feng Wang 381ff9903bSLi Feng Wang import testlib.uno.SWUtil; 391ff9903bSLi Feng Wang 401ff9903bSLi Feng Wang import com.sun.star.beans.XPropertySet; 411ff9903bSLi Feng Wang import com.sun.star.container.XNameAccess; 421ff9903bSLi Feng Wang import com.sun.star.lang.XMultiServiceFactory; 431ff9903bSLi Feng Wang import com.sun.star.table.ShadowFormat; 441ff9903bSLi Feng Wang import com.sun.star.table.ShadowLocation; 451ff9903bSLi Feng Wang import com.sun.star.text.XText; 461ff9903bSLi Feng Wang import com.sun.star.text.XTextCursor; 471ff9903bSLi Feng Wang import com.sun.star.text.XTextDocument; 481ff9903bSLi Feng Wang import com.sun.star.text.XTextFrame; 491ff9903bSLi Feng Wang import com.sun.star.text.XTextFramesSupplier; 501ff9903bSLi Feng Wang import com.sun.star.uno.UnoRuntime; 511ff9903bSLi Feng Wang @RunWith(value = Parameterized.class) 521ff9903bSLi Feng Wang public class FrameShadow { 531ff9903bSLi Feng Wang private static final UnoApp app = new UnoApp(); 541ff9903bSLi Feng Wang private XTextDocument xTextDocument=null; 551ff9903bSLi Feng Wang private XMultiServiceFactory xWriterFactory=null; 561ff9903bSLi Feng Wang private XText xText=null; 571ff9903bSLi Feng Wang private int shadowColor; 581ff9903bSLi Feng Wang private short shadowWidth; 591ff9903bSLi Feng Wang private ShadowLocation shadowLocation; FrameShadow(ShadowLocation shadowLocation,short shadowWidth,int shadowColor)601ff9903bSLi Feng Wang public FrameShadow(ShadowLocation shadowLocation,short shadowWidth,int shadowColor){ 611ff9903bSLi Feng Wang this.shadowLocation=shadowLocation; 621ff9903bSLi Feng Wang this.shadowWidth=shadowWidth; 631ff9903bSLi Feng Wang this.shadowColor=shadowColor; 641ff9903bSLi Feng Wang } 651ff9903bSLi Feng Wang @Parameters data()661ff9903bSLi Feng Wang public static Collection<Object[]> data(){ 671ff9903bSLi Feng Wang Object[][] params = new Object[][]{ 681ff9903bSLi Feng Wang {ShadowLocation.NONE,(short)0,0}, 691ff9903bSLi Feng Wang {ShadowLocation.TOP_LEFT,(short)101,0x00FF00FF}, 701ff9903bSLi Feng Wang {ShadowLocation.TOP_RIGHT,(short)101,0x00FF00FF}, 711ff9903bSLi Feng Wang {ShadowLocation.BOTTOM_LEFT,(short)101,0x00FF00FF}, 721ff9903bSLi Feng Wang {ShadowLocation.BOTTOM_RIGHT,(short)101,0x00FF00FF}, 731ff9903bSLi Feng Wang }; 741ff9903bSLi Feng Wang return Arrays.asList(params); 751ff9903bSLi Feng Wang } 761ff9903bSLi Feng Wang @Before setUp()771ff9903bSLi Feng Wang public void setUp() throws Exception { 781ff9903bSLi Feng Wang app.start(); 791ff9903bSLi Feng Wang } 801ff9903bSLi Feng Wang 811ff9903bSLi Feng Wang @After tearDown()821ff9903bSLi Feng Wang public void tearDown() throws Exception { 831ff9903bSLi Feng Wang app.close(); 841ff9903bSLi Feng Wang } 851ff9903bSLi Feng Wang 861ff9903bSLi Feng Wang @Test testFrameShadow()871ff9903bSLi Feng Wang public void testFrameShadow() throws Exception { 881ff9903bSLi Feng Wang xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter")); 891ff9903bSLi Feng Wang xText=xTextDocument.getText(); 901ff9903bSLi Feng Wang XTextCursor xTextCursor = xText.createTextCursor(); 911ff9903bSLi Feng Wang // get internal service factory of the document 921ff9903bSLi Feng Wang xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); 931ff9903bSLi Feng Wang // Create a new table from the document's factory 941ff9903bSLi Feng Wang XTextFrame xTextFrame1 = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame")); 951ff9903bSLi Feng Wang xText.insertTextContent(xTextCursor,xTextFrame1,false); 961ff9903bSLi Feng Wang XPropertySet xTextFrameProps1 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame1); 971ff9903bSLi Feng Wang ShadowFormat shadowFormat=new ShadowFormat(); 981ff9903bSLi Feng Wang shadowFormat.Color=shadowColor; 991ff9903bSLi Feng Wang shadowFormat.Location=shadowLocation; 1001ff9903bSLi Feng Wang shadowFormat.ShadowWidth=shadowWidth; 1011ff9903bSLi Feng Wang xTextFrameProps1.setPropertyValue("ShadowFormat",shadowFormat); 1021ff9903bSLi Feng Wang //reopen the document 1031ff9903bSLi Feng Wang XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, SWUtil.saveTo_Override_reload(xTextDocument,"writer8", Testspace.getPath("output/test.odt"),app)); 1041ff9903bSLi Feng Wang XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt); 1051ff9903bSLi Feng Wang XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames(); 1061ff9903bSLi Feng Wang XTextFrame xTextFrame_Assert1=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrames_odt.getByName("Frame1")); 1071ff9903bSLi Feng Wang XPropertySet xTextFrameProps_assert1 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame_Assert1); 1081ff9903bSLi Feng Wang ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xTextFrameProps_assert1.getPropertyValue("ShadowFormat")); 1091ff9903bSLi Feng Wang assertEquals("assert shadow color",shadowColor,shadowFormat_Assert1.Color); 1101ff9903bSLi Feng Wang assertEquals("assert shadow location",shadowLocation,shadowFormat_Assert1.Location); 1111ff9903bSLi Feng Wang assertEquals("assert shadow width",shadowWidth,shadowFormat_Assert1.ShadowWidth); 1121ff9903bSLi Feng Wang } 1131ff9903bSLi Feng Wang } 114