SWUtil.java (deb45f49) SWUtil.java (1ff9903b)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 7 unchanged lines hidden (view full) ---

16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21package testlib.uno;
22
23
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 7 unchanged lines hidden (view full) ---

16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21package testlib.uno;
22
23
24import org.openoffice.test.common.FileUtil;
24import org.openoffice.test.uno.UnoApp;
25
26import com.sun.star.beans.PropertyValue;
27import com.sun.star.beans.XPropertySet;
28import com.sun.star.container.XNameAccess;
29import com.sun.star.container.XNameContainer;
30import com.sun.star.container.XNamed;
31import com.sun.star.document.XDocumentInfo;

--- 5 unchanged lines hidden (view full) ---

37import com.sun.star.style.BreakType;
38import com.sun.star.style.XStyle;
39import com.sun.star.style.XStyleFamiliesSupplier;
40import com.sun.star.text.ControlCharacter;
41import com.sun.star.text.XText;
42import com.sun.star.text.XTextContent;
43import com.sun.star.text.XTextCursor;
44import com.sun.star.text.XTextDocument;
25import org.openoffice.test.uno.UnoApp;
26
27import com.sun.star.beans.PropertyValue;
28import com.sun.star.beans.XPropertySet;
29import com.sun.star.container.XNameAccess;
30import com.sun.star.container.XNameContainer;
31import com.sun.star.container.XNamed;
32import com.sun.star.document.XDocumentInfo;

--- 5 unchanged lines hidden (view full) ---

38import com.sun.star.style.BreakType;
39import com.sun.star.style.XStyle;
40import com.sun.star.style.XStyleFamiliesSupplier;
41import com.sun.star.text.ControlCharacter;
42import com.sun.star.text.XText;
43import com.sun.star.text.XTextContent;
44import com.sun.star.text.XTextCursor;
45import com.sun.star.text.XTextDocument;
46import com.sun.star.frame.XComponentLoader;
45import com.sun.star.frame.XModel;
46import com.sun.star.frame.XController;
47import com.sun.star.uno.UnoRuntime;
48
49public class SWUtil {
50
51
52

--- 171 unchanged lines hidden (view full) ---

224 XTextDocument textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xComponent);
225 XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier)UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, textDocument);
226 XNameAccess xFamilies = (XNameAccess) UnoRuntime.queryInterface (XNameAccess.class, xSupplier.getStyleFamilies());
227 XNameContainer xFamily = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xFamilies.getByName("PageStyles"));
228 XStyle xStyle = (XStyle)UnoRuntime.queryInterface(XStyle.class, xFamily.getByName("Default"));
229 XPropertySet xStyleProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStyle);
230 xStyleProps.setPropertyValue (propertyName.toString(), propertyValue);
231 }
47import com.sun.star.frame.XModel;
48import com.sun.star.frame.XController;
49import com.sun.star.uno.UnoRuntime;
50
51public class SWUtil {
52
53
54

--- 171 unchanged lines hidden (view full) ---

226 XTextDocument textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xComponent);
227 XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier)UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, textDocument);
228 XNameAccess xFamilies = (XNameAccess) UnoRuntime.queryInterface (XNameAccess.class, xSupplier.getStyleFamilies());
229 XNameContainer xFamily = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xFamilies.getByName("PageStyles"));
230 XStyle xStyle = (XStyle)UnoRuntime.queryInterface(XStyle.class, xFamily.getByName("Default"));
231 XPropertySet xStyleProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStyle);
232 xStyleProps.setPropertyValue (propertyName.toString(), propertyValue);
233 }
234
235 public static XTextDocument saveTo_Override_reload(XTextDocument xTextDocument,String filtervalue, String url,UnoApp app) throws Exception {
236 XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
237 PropertyValue[] aStoreProperties = new PropertyValue[2];
238 aStoreProperties[0] = new PropertyValue();
239 aStoreProperties[1] = new PropertyValue();
240 aStoreProperties[0].Name = "Override";
241 aStoreProperties[0].Value = true;
242 aStoreProperties[1].Name = "FilterName";
243 aStoreProperties[1].Value = filtervalue;
244 xStorable_odt.storeToURL(FileUtil.getUrl(url), aStoreProperties);
245 //reopen the document
246 return (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(url));
247 }
248 /**
249 * create document from template
250 */
251 public static XComponent newDocumentFromTemplate(String templatePath,UnoApp unoApp) throws Exception
252 {
253 XComponentLoader componentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, unoApp.getDesktop());
254 PropertyValue[] pros = new PropertyValue[1];
255 pros[0] = new PropertyValue();
256 pros[0].Name = "AsTemplate";
257 pros[0].Value = new Boolean(true);
258 XComponent component = componentLoader.loadComponentFromURL(FileUtil.getUrl(templatePath), "_blank", 0,pros);
259 return component;
260 }
232}
261}