Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
fd4432ed
Kaydet (Commit)
fd4432ed
authored
Ara 11, 2003
tarafından
Kurt Zenker
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
INTEGRATION: CWS qadev14 (1.2.12); FILE MERGED
2003/12/04 19:07:07 sg 1.2.12.1: #114056#CHG: adapted test
üst
ee305f00
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
316 additions
and
9 deletions
+316
-9
_XChangesBatch.java
qadevOOo/tests/java/ifc/util/_XChangesBatch.java
+136
-2
_XChangesNotifier.java
qadevOOo/tests/java/ifc/util/_XChangesNotifier.java
+180
-7
No files found.
qadevOOo/tests/java/ifc/util/_XChangesBatch.java
Dosyayı görüntüle @
fd4432ed
...
...
@@ -2,9 +2,9 @@
*
* $RCSfile: _XChangesBatch.java,v $
*
* $Revision: 1.
2
$
* $Revision: 1.
3
$
*
* last change:$Date: 2003-
09-08 11:29:18
$
* last change:$Date: 2003-
12-11 11:48:49
$
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
...
...
@@ -61,21 +61,155 @@
package
ifc
.
util
;
import
com.sun.star.beans.Property
;
import
com.sun.star.beans.PropertyValue
;
import
com.sun.star.beans.XProperty
;
import
com.sun.star.beans.XPropertySet
;
import
com.sun.star.container.XHierarchicalName
;
import
com.sun.star.container.XHierarchicalNameAccess
;
import
com.sun.star.container.XNameAccess
;
import
com.sun.star.container.XNameReplace
;
import
com.sun.star.document.XTypeDetection
;
import
com.sun.star.uno.UnoRuntime
;
import
com.sun.star.util.ElementChange
;
import
lib.MultiMethodTest
;
import
com.sun.star.util.XChangesBatch
;
import
java.io.PrintWriter
;
import
lib.Status
;
import
lib.StatusException
;
public
class
_XChangesBatch
extends
MultiMethodTest
{
public
XChangesBatch
oObj
;
private
Object
changeElement
=
null
;
private
Object
originalElement
=
null
;
private
String
elementName
=
null
;
private
XPropertySet
xProp
=
null
;
private
XNameReplace
xNameReplace
=
null
;
/**
* add a change that can be committed
*/
protected
void
before
()
{
changeElement
=
tEnv
.
getObjRelation
(
"XChangesBatch.ChangeElement"
);
originalElement
=
tEnv
.
getObjRelation
(
"XChangesBatch.OriginalElement"
);
elementName
=
(
String
)
tEnv
.
getObjRelation
(
"XChangesBatch.PropertyName"
);
// to do a change, get an XPropertySet
xProp
=
(
XPropertySet
)
tEnv
.
getObjRelation
(
"XChangesBatch.PropertySet"
);
try
{
if
(
originalElement
==
null
&&
xProp
!=
null
)
originalElement
=
xProp
.
getPropertyValue
(
elementName
);
}
catch
(
com
.
sun
.
star
.
uno
.
Exception
e
)
{
throw
new
StatusException
(
"Could not get property '"
+
elementName
+
"'."
,
e
);
}
// or get an XNameReplace
xNameReplace
=
(
XNameReplace
)
tEnv
.
getObjRelation
(
"XChangesBatch.NameReplace"
);
try
{
if
(
originalElement
==
null
&&
xNameReplace
!=
null
)
originalElement
=
xNameReplace
.
getByName
(
elementName
);
}
catch
(
com
.
sun
.
star
.
uno
.
Exception
e
)
{
throw
new
StatusException
(
"Could not get element by name '"
+
elementName
+
"'."
,
e
);
}
if
(
changeElement
==
null
||
originalElement
==
null
||
elementName
==
null
||
(
xProp
==
null
&&
xNameReplace
==
null
))
{
log
.
println
(
changeElement
==
null
?
"Missing property 'XChangesBatch.ChangeElement'\n"
:
""
+
originalElement
==
null
?
"Missing property 'XChangesBatch.OriginalElement'\n"
:
""
+
elementName
==
null
?
"Missing property 'XChangesBatch.PropertyName'\n"
:
""
+
xProp
==
null
?
"Missing property 'XChangesBatch.PropertySet'"
:
""
+
xNameReplace
==
null
?
"Missing property 'XChangesBatch.NameReplace'"
:
""
);
throw
new
StatusException
(
"Some needed object relations are missing."
,
new
Exception
());
}
}
public
void
_commitChanges
()
{
requiredMethod
(
"getPendingChanges()"
);
try
{
log
.
println
(
"Committing changes."
);
oObj
.
commitChanges
();
}
catch
(
com
.
sun
.
star
.
lang
.
WrappedTargetException
e
)
{
tRes
.
tested
(
"commitChanges()"
,
Status
.
exception
(
e
));
return
;
}
try
{
executeChange
(
originalElement
);
}
catch
(
StatusException
e
)
{
tRes
.
tested
(
"hasPendingChanges()"
,
Status
.
exception
(
e
));
return
;
}
try
{
log
.
println
(
"Commit changes back."
);
oObj
.
commitChanges
();
}
catch
(
com
.
sun
.
star
.
lang
.
WrappedTargetException
e
)
{
tRes
.
tested
(
"commitChanges()"
,
Status
.
exception
(
e
));
return
;
}
tRes
.
tested
(
"commitChanges()"
,
true
);
}
public
void
_getPendingChanges
()
{
requiredMethod
(
"hasPendingChanges()"
);
ElementChange
[]
changes
=
oObj
.
getPendingChanges
();
if
(
changes
==
null
)
{
log
.
println
(
"Returned changes was 'null'"
);
log
.
println
(
"It should have been 1 change."
);
tRes
.
tested
(
"getPendingChanges()"
,
false
);
}
else
if
(
changes
.
length
!=
1
)
{
int
amount
=
changes
.
length
;
log
.
println
(
"Found not the right number of changes: "
+
amount
);
log
.
println
(
"It should have been 1 change."
);
for
(
int
i
=
0
;
i
<
amount
;
i
++)
{
System
.
out
.
println
(
"Detailed Change "
+
i
+
" -> new Element: '"
+
changes
[
i
].
Element
.
toString
()
+
"' ReplacedElement: '"
+
changes
[
i
].
ReplacedElement
.
toString
()
+
"'"
);
}
tRes
.
tested
(
"getPendingChanges()"
,
false
);
}
else
{
boolean
result
=
changes
[
0
].
ReplacedElement
.
equals
(
originalElement
);
result
&=
changes
[
0
].
Element
.
equals
(
changeElement
);
tRes
.
tested
(
"getPendingChanges()"
,
result
);
}
}
public
void
_hasPendingChanges
()
{
try
{
executeChange
(
changeElement
);
}
catch
(
StatusException
e
)
{
tRes
.
tested
(
"hasPendingChanges()"
,
Status
.
exception
(
e
));
return
;
}
boolean
hasPendingChanges
=
oObj
.
hasPendingChanges
();
tRes
.
tested
(
"hasPendingChanges()"
,
hasPendingChanges
);
}
private
void
executeChange
(
Object
element
)
throws
StatusException
{
if
(
xProp
!=
null
)
{
try
{
xProp
.
setPropertyValue
(
elementName
,
element
);
}
catch
(
com
.
sun
.
star
.
uno
.
Exception
e
)
{
throw
new
StatusException
(
"Could not set property '"
+
elementName
+
"'."
,
e
);
}
}
else
if
(
xNameReplace
!=
null
)
{
try
{
xNameReplace
.
replaceByName
(
elementName
,
element
);
}
catch
(
com
.
sun
.
star
.
uno
.
Exception
e
)
{
throw
new
StatusException
(
"Could not replace '"
+
elementName
+
"' by name."
,
e
);
}
}
}
}
qadevOOo/tests/java/ifc/util/_XChangesNotifier.java
Dosyayı görüntüle @
fd4432ed
...
...
@@ -2,9 +2,9 @@
*
* $RCSfile: _XChangesNotifier.java,v $
*
* $Revision: 1.
2
$
* $Revision: 1.
3
$
*
* last change:$Date: 2003-
09-08 11:29:27
$
* last change:$Date: 2003-
12-11 11:49:03
$
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
...
...
@@ -61,23 +61,196 @@
package
ifc
.
util
;
import
lib.MultiMethodTest
;
import
com.sun.star.beans.XPropertySet
;
import
com.sun.star.container.XNameReplace
;
import
com.sun.star.util.XChangesBatch
;
import
com.sun.star.util.XChangesListener
;
import
com.sun.star.util.XChangesNotifier
;
import
java.io.PrintWriter
;
import
lib.StatusException
;
import
lib.MultiMethodTest
;
/**
*
* @author sw93809
* Test the XChangesNotifier interface. To produce some changes,
* XChangesBatch is used.
* @see com.sun.star.util.XChangesNotifier
* @see com.sun.star.util.XChangesBatch
*/
public
class
_XChangesNotifier
extends
MultiMethodTest
{
public
XChangesNotifier
oObj
;
public
XChangesNotifier
oObj
=
null
;
private
XChangesBatch
xBatch
=
null
;
private
Object
changeElement
=
null
;
private
Object
originalElement
=
null
;
private
String
elementName
=
null
;
private
XPropertySet
xProp
=
null
;
private
XNameReplace
xNameReplace
=
null
;
private
_XChangesNotifier
.
MyChangesListener
xListener
=
null
;
/**
* Own implementation of the XChangesListener interface
* @see com.sun.star.util.XChangesListener
*/
private
static
class
MyChangesListener
implements
XChangesListener
{
/** Just lo a call of the listener **/
boolean
bChangesOccured
=
false
;
/** A change did occur
* @param changesEvent The event.
**/
public
void
changesOccurred
(
com
.
sun
.
star
.
util
.
ChangesEvent
changesEvent
)
{
bChangesOccured
=
true
;
}
/** Disposing of the listener
* @param eventObject The event.
**/
public
void
disposing
(
com
.
sun
.
star
.
lang
.
EventObject
eventObject
)
{
bChangesOccured
=
true
;
}
/**
* Reset the listener
*/
public
void
reset
()
{
bChangesOccured
=
false
;
}
/**
* Has the listener been called?
* @return True, if the listener has been called.
*/
public
boolean
didChangesOccur
()
{
return
bChangesOccured
;
}
}
/**
* Before the test: get the 'XChangesNotifier.ChangesBatch' object relation
* and create the listener.
*/
protected
void
before
()
{
xBatch
=
(
XChangesBatch
)
tEnv
.
getObjRelation
(
"XChangesNotifier.ChangesBatch"
);
changeElement
=
tEnv
.
getObjRelation
(
"XChangesNotifier.ChangeElement"
);
originalElement
=
tEnv
.
getObjRelation
(
"XChangesNotifier.OriginalElement"
);
elementName
=
(
String
)
tEnv
.
getObjRelation
(
"XChangesNotifier.PropertyName"
);
xProp
=
(
XPropertySet
)
tEnv
.
getObjRelation
(
"XChangesNotifier.PropertySet"
);
try
{
if
(
originalElement
==
null
&&
xProp
!=
null
)
originalElement
=
xProp
.
getPropertyValue
(
elementName
);
}
catch
(
com
.
sun
.
star
.
uno
.
Exception
e
)
{
throw
new
StatusException
(
"Could not get property '"
+
elementName
+
"'."
,
e
);
}
// or get an XNameReplace
xNameReplace
=
(
XNameReplace
)
tEnv
.
getObjRelation
(
"XChangesNotifier.NameReplace"
);
try
{
if
(
originalElement
==
null
&&
xNameReplace
!=
null
)
originalElement
=
xNameReplace
.
getByName
(
elementName
);
}
catch
(
com
.
sun
.
star
.
uno
.
Exception
e
)
{
throw
new
StatusException
(
"Could not get element by name '"
+
elementName
+
"'."
,
e
);
}
if
(
changeElement
==
null
||
originalElement
==
null
||
elementName
==
null
||
(
xProp
==
null
&&
xNameReplace
==
null
)
||
xBatch
==
null
)
{
log
.
println
(
changeElement
==
null
?
"Missing property 'XChangesNotifier.ChangeElement'\n"
:
""
+
originalElement
==
null
?
"Missing property 'XChangesNotifier.OriginalElement'\n"
:
""
+
elementName
==
null
?
"Missing property 'XChangesNotifier.PropertyName'\n"
:
""
+
xProp
==
null
?
"Missing property 'XChangesNotifier.PropertySet'"
:
""
+
xNameReplace
==
null
?
"Missing property 'XChangesNotifier.NameReplace'"
:
""
+
xBatch
==
null
?
"Missing property 'XChangesNotifier.ChangesBatch'"
:
""
);
throw
new
StatusException
(
"Some needed object relations are missing."
,
new
Exception
());
}
xListener
=
new
_XChangesNotifier
.
MyChangesListener
();
}
/** test addChangesListener **/
public
void
_addChangesListener
()
{
oObj
.
addChangesListener
(
xListener
);
tRes
.
tested
(
"addChangesListener()"
,
true
);
}
/** test removeChangesListener **/
public
void
_removeChangesListener
()
{
requiredMethod
(
"addChangesListener()"
);
boolean
result
=
true
;
result
&=
commitChanges
();
result
&=
xListener
.
didChangesOccur
();
if
(!
result
)
log
.
println
(
"Listener has not been called."
);
oObj
.
removeChangesListener
(
xListener
);
xListener
.
reset
();
result
&=
redoChanges
();
boolean
result2
=
xListener
.
didChangesOccur
();
if
(
result2
)
log
.
println
(
"Removed listener has been called."
);
tRes
.
tested
(
"removeChangesListener()"
,
result
&&
!
result2
);
}
/**
* Commit a change, using an implementation of the XChangesBatch interface.
* @return true, if changing worked.
*/
private
boolean
commitChanges
()
{
if
(!
executeChange
(
changeElement
))
return
false
;
if
(!
xBatch
.
hasPendingChanges
())
return
false
;
try
{
xBatch
.
commitChanges
();
}
catch
(
com
.
sun
.
star
.
lang
.
WrappedTargetException
e
)
{
e
.
printStackTrace
((
PrintWriter
)
log
);
return
false
;
}
return
true
;
}
/**
* Redo the change, using an implementation of the XChangesBatch interface.
* @return true, if changing worked.
*/
private
boolean
redoChanges
()
{
if
(!
executeChange
(
originalElement
))
return
false
;
if
(!
xBatch
.
hasPendingChanges
())
return
false
;
try
{
xBatch
.
commitChanges
();
}
catch
(
com
.
sun
.
star
.
lang
.
WrappedTargetException
e
)
{
e
.
printStackTrace
((
PrintWriter
)
log
);
return
false
;
}
return
true
;
}
/**
* Execute the change, use XPropertySet or XNameReplace
* @return False, if changing did throw an exception.
*/
private
boolean
executeChange
(
Object
element
)
throws
StatusException
{
if
(
xProp
!=
null
)
{
try
{
xProp
.
setPropertyValue
(
elementName
,
element
);
}
catch
(
com
.
sun
.
star
.
uno
.
Exception
e
)
{
e
.
printStackTrace
((
PrintWriter
)
log
);
return
false
;
}
}
else
if
(
xNameReplace
!=
null
)
{
try
{
xNameReplace
.
replaceByName
(
elementName
,
element
);
}
catch
(
com
.
sun
.
star
.
uno
.
Exception
e
)
{
e
.
printStackTrace
((
PrintWriter
)
log
);
return
false
;
}
}
return
true
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment