XMultiComponentFactory xMCF = m_xContext.getServiceManager();
XCommandEnvironment xCE = (XCommandEnvironment) UnoRuntime.queryInterface(XCommandEnvironment.class, xMCF.createInstanceWithContext("com.sun.star.ucb.CommandEnvironment", m_xContext));
XPackageManagerFactory xPMF = (XPackageManagerFactory) UnoRuntime.queryInterface(XPackageManagerFactory.class, xNameAccess.getByName("/singletons/com.sun.star.deployment.thePackageManagerFactory"));
XPackageManager xPM = null;
XPackage xPackage = xEM.getDeployedExtension("user", "org.openoffice.extensions.diagrams.Diagrams", location, xCE);
if(xPackage != null){
xPM = xPMF.getPackageManager("user");
}else{
xPackage = xEM.getDeployedExtension("share", "org.openoffice.extensions.diagrams.Diagrams", location, xCE);
if(xPackage != null)
xPM = xPMF.getPackageManager("share");
}
XAbortChannel xACh = xPM.createAbortChannel();
//xEM.disableExtension(xPackage, xACh, xCE);
xEM.removeExtension("org.openoffice.extensions.diagrams.Diagrams", location, "user", xACh, xCE);
boolean isDiagramExtenisonExist = false;
String[][] str = m_xPIP.getExtensionList();