Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / ucb / qa / complex / tdoc / _XContent.java
blobd97349937dbd4de017e1c77e3cf2bc4f859db8e0
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package complex.tdoc;
20 import com.sun.star.ucb.XContent;
21 import com.sun.star.ucb.XContentEventListener;
22 import com.sun.star.ucb.XContentIdentifier;
23 import share.LogWriter;
25 public class _XContent {
26 public XContent oObj = null;
27 public LogWriter log = null;
28 private ContentListener listener = null;
30 public boolean _addContentEventListener() {
31 listener = new ContentListener();
32 oObj.addContentEventListener(listener);
33 return true;
35 public boolean _getContentType() {
36 String type = oObj.getContentType();
37 log.println("Type: " + type);
38 return type != null && type.indexOf("vnd.sun.star.tdoc") != -1;
40 public boolean _getIdentifier() {
41 XContentIdentifier xIdent = oObj.getIdentifier();
42 String id = xIdent.getContentIdentifier();
43 String scheme = xIdent.getContentProviderScheme();
44 log.println("Id: " + id);
45 log.println("Scheme: " + scheme);
46 return id != null && scheme != null && id.indexOf("vnd.sun.star.tdoc") != -1 && scheme.indexOf("vnd.sun.star.tdoc") != -1;
48 public boolean _removeContentEventListener() {
49 System.out.println("Event: " + (listener.disposed || listener.firedEvent));
50 oObj.removeContentEventListener(listener);
51 return true;
55 private class ContentListener implements XContentEventListener {
56 private boolean disposed = false;
57 private boolean firedEvent = false;
59 public void reset() {
60 disposed = false;
61 firedEvent = false;
64 public void contentEvent(com.sun.star.ucb.ContentEvent contentEvent) {
65 firedEvent = true;
68 public void disposing(com.sun.star.lang.EventObject eventObject) {
69 disposed = true;