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 .
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 private final LogWriter log
= null;
28 private ContentListener listener
= null;
30 public boolean _addContentEventListener() {
31 listener
= new ContentListener();
32 oObj
.addContentEventListener(listener
);
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
);
55 private class ContentListener
implements XContentEventListener
{
56 private boolean disposed
= false;
57 private boolean firedEvent
= false;
59 public void contentEvent(com
.sun
.star
.ucb
.ContentEvent contentEvent
) {
63 public void disposing(com
.sun
.star
.lang
.EventObject eventObject
) {