summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Bauer <mba@openoffice.org>2010-01-05 14:46:45 +0100
committerMathias Bauer <mba@openoffice.org>2010-01-05 14:46:45 +0100
commitf18f649faac191ddee68deb8c4d472a6b760614e (patch)
tree9c5e2f5ce774622cd8627d5f5cbb6a576a3787e6
parent767a28682b660fac209240e46d67e05120092f8f (diff)
parent680e0f04cd5ffb447d9525200e7a3fadb2a760d6 (diff)
merge commit for m68
-rw-r--r--basic/source/classes/sbunoobj.cxx13
-rw-r--r--basic/source/uno/namecont.cxx12
-rw-r--r--desktop/inc/app.hxx1
-rw-r--r--desktop/source/app/app.cxx33
-rw-r--r--desktop/source/app/copyright_ascii_ooo.c4
-rw-r--r--desktop/source/app/copyright_ascii_sun.c4
-rw-r--r--desktop/source/deployment/dp_persmap.cxx2
-rw-r--r--desktop/source/deployment/makefile.mk1
-rw-r--r--desktop/source/deployment/registry/help/dp_help.cxx7
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/BrowserSupport.java7
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/Installer.java9
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/LinuxSystemEnvironment.java146
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/RegistrationData.java1004
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java814
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/Registry.java7
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/ServiceTag.java7
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/SolarisServiceTag.java7
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/SolarisSystemEnvironment.java281
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/SunConnection.java7
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/SysnetRegistryHelper.java7
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java93
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/UnauthorizedAccessException.java7
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/Util.java9
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/WindowsSystemEnvironment.java100
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/resources/product_registration.xsd667
-rw-r--r--framework/inc/classes/fwktabwindow.hxx1
-rw-r--r--framework/inc/services/autorecovery.hxx7
-rw-r--r--framework/inc/services/sessionlistener.hxx22
-rw-r--r--framework/inc/services/tabwindowservice.hxx87
-rw-r--r--framework/source/classes/fwktabwindow.cxx6
-rw-r--r--framework/source/helper/titlebarupdate.cxx6
-rw-r--r--framework/source/services/autorecovery.cxx143
-rw-r--r--framework/source/services/sessionlistener.cxx159
-rw-r--r--framework/source/services/tabwindowservice.cxx32
-rw-r--r--framework/source/uielement/langselectionstatusbarcontroller.cxx2
-rw-r--r--framework/source/uielement/toolbarmanager.cxx6
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu2
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Recovery.xcs13
-rw-r--r--sfx2/inc/sfx2/dinfdlg.hxx66
-rw-r--r--sfx2/inc/sfx2/docfile.hxx3
-rw-r--r--sfx2/qa/complex/DocumentMetaData.java50
-rw-r--r--sfx2/source/appl/shutdownicon.cxx31
-rw-r--r--sfx2/source/control/makefile.mk6
-rw-r--r--sfx2/source/dialog/dialog.hrc2
-rw-r--r--sfx2/source/dialog/dinfdlg.cxx353
-rw-r--r--sfx2/source/dialog/dinfdlg.hrc22
-rw-r--r--sfx2/source/dialog/dinfdlg.src222
-rw-r--r--sfx2/source/doc/SfxDocumentMetaData.cxx132
-rw-r--r--sfx2/source/doc/docfile.cxx166
-rw-r--r--sfx2/source/doc/objmisc.cxx16
-rw-r--r--sfx2/source/doc/objstor.cxx14
-rwxr-xr-xsfx2/source/doc/sfxacldetect.cxx216
-rw-r--r--sfx2/source/inc/helpid.hrc3
-rw-r--r--sfx2/source/inc/sfxlocal.hrc5
-rw-r--r--shell/inc/internal/utilities.hxx1
-rw-r--r--shell/inc/internal/xml_parser.hxx11
-rw-r--r--shell/source/all/xml_parser.cxx14
-rw-r--r--shell/source/backends/gconfbe/gconfbackend.cxx3
-rw-r--r--shell/source/backends/gconfbe/gconfbackend.hxx5
-rw-r--r--shell/source/unix/sysshell/recently_used_file.cxx6
-rw-r--r--shell/source/unix/sysshell/recently_used_file.hxx3
-rw-r--r--shell/source/unix/sysshell/recently_used_file_handler.cxx20
-rw-r--r--svx/source/accessibility/AccessibleStaticTextBase.cxx4
-rw-r--r--svx/source/dialog/svxruler.cxx5
-rw-r--r--svx/source/sdr/primitive2d/sdrattributecreator.cxx2
-rw-r--r--svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.src4
-rw-r--r--svx/source/unodraw/UnoGraphicExporter.cxx4
-rw-r--r--svx/source/unodraw/unoshtxt.cxx3
-rw-r--r--ucb/source/ucp/gio/gio_mount.cxx2
-rw-r--r--xmlhelp/source/com/sun/star/help/MANIFEST.MF1
-rw-r--r--xmlhelp/source/com/sun/star/help/makefile.mk12
-rw-r--r--xmlhelp/source/treeview/tvread.cxx4
-rw-r--r--xmloff/inc/txtfldi.hxx5
-rw-r--r--xmloff/source/text/txtflde.cxx11
-rw-r--r--xmloff/source/text/txtfldi.cxx33
-rw-r--r--xmloff/source/text/txtimp.cxx10
76 files changed, 3450 insertions, 1755 deletions
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 240927e75a..06c29a5f2d 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -750,11 +750,11 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue )
// SbUnoObject instanzieren
String aName;
SbUnoObject* pSbUnoObject = new SbUnoObject( aName, aValue );
- //If this is called externally e.g. from the scripting
- //framework then there is no 'active' runtime the default property will not be set up
- //only a vba object will have XDefaultProp set anyway so... this
- //test seems a bit of overkill
- //if ( SbiRuntime::isVBAEnabled() )
+ //If this is called externally e.g. from the scripting
+ //framework then there is no 'active' runtime the default property will not be set up
+ //only a vba object will have XDefaultProp set anyway so... this
+ //test seems a bit of overkill
+ //if ( SbiRuntime::isVBAEnabled() )
{
String sDfltPropName;
@@ -3377,9 +3377,10 @@ SbxVariable* SbUnoService::Find( const String& rName, SbxClassType )
// Create and insert SbUnoServiceCtor
SbxVariableRef xSbCtorRef = new SbUnoServiceCtor( aName, xCtor );
QuickInsert( (SbxVariable*)xSbCtorRef );
- pRes = xSbCtorRef;
}
}
+
+ pRes = SbxObject::Find( rName, SbxCLASS_METHOD );
}
}
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index 8c89be33c5..71d1dc9e55 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -940,7 +940,17 @@ sal_Bool SfxLibraryContainer::init_Impl(
// #110009
if( !bStorage && meInitMode == DEFAULT )
- implScanExtensions();
+ {
+ try
+ {
+ implScanExtensions();
+ }
+ catch( uno::Exception& )
+ {
+ // TODO: error handling?
+ OSL_ASSERT( "Cannot access extensions!" );
+ }
+ }
// #110009 Preload?
{
diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index 432006a50a..8315658d45 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -186,6 +186,7 @@ class Desktop : public Application
static sal_Bool _bTasksSaved;
static void retrieveCrashReporterState();
+ static sal_Bool isUIOnSessionShutdownAllowed();
// on-demand acceptors
static void createAcceptor(const OUString& aDescription);
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 6da2b5db85..658212ec1d 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -938,6 +938,29 @@ void Desktop::retrieveCrashReporterState()
_bCrashReporterEnabled = bEnabled;
}
+sal_Bool Desktop::isUIOnSessionShutdownAllowed()
+{
+ static const ::rtl::OUString CFG_PACKAGE_RECOVERY = ::rtl::OUString::createFromAscii("org.openoffice.Office.Recovery/");
+ static const ::rtl::OUString CFG_PATH_SESSION = ::rtl::OUString::createFromAscii("SessionShutdown" );
+ static const ::rtl::OUString CFG_ENTRY_UIENABLED = ::rtl::OUString::createFromAscii("DocumentStoreUIEnabled" );
+
+ css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
+
+ sal_Bool bResult = sal_False;
+ if ( xSMGR.is() )
+ {
+ css::uno::Any aVal = ::comphelper::ConfigurationHelper::readDirectKey(
+ xSMGR,
+ CFG_PACKAGE_RECOVERY,
+ CFG_PATH_SESSION,
+ CFG_ENTRY_UIENABLED,
+ ::comphelper::ConfigurationHelper::E_READONLY);
+ aVal >>= bResult;
+ }
+
+ return bResult;
+}
+
//-----------------------------------------------
/** @short check if crash reporter feature is enabled or
disabled.
@@ -2457,7 +2480,15 @@ void Desktop::OpenClients()
{
xSessionListener = Reference< XInitialization >(::comphelper::getProcessServiceFactory()->createInstance(
OUString::createFromAscii("com.sun.star.frame.SessionListener")), UNO_QUERY_THROW);
- xSessionListener->initialize(Sequence< Any >(0));
+
+ // specifies whether the UI-interaction on Session shutdown is allowed
+ sal_Bool bAllowUI = isUIOnSessionShutdownAllowed();
+ css::beans::NamedValue aProperty( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AllowUserInteractionOnQuit" ) ),
+ css::uno::makeAny( bAllowUI ) );
+ css::uno::Sequence< css::uno::Any > aArgs( 1 );
+ aArgs[0] <<= aProperty;
+
+ xSessionListener->initialize( aArgs );
}
catch(const com::sun::star::uno::Exception& e)
{
diff --git a/desktop/source/app/copyright_ascii_ooo.c b/desktop/source/app/copyright_ascii_ooo.c
index f5b5cfa2ca..8d9d821e19 100644
--- a/desktop/source/app/copyright_ascii_ooo.c
+++ b/desktop/source/app/copyright_ascii_ooo.c
@@ -9,8 +9,8 @@ extern const char copyright_text_2[];
extern const char copyright_text_21[];
extern const char copyright_text_22[];
-const char copyright_text_1[] = "Copyright © 2008 Sun Microsystems, Inc., All rights reserved.";
+const char copyright_text_1[] = "Copyright © 2010 Sun Microsystems, Inc., All rights reserved.";
const char copyright_text_2[] = "Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is described in this document. In particular, and without limitation, these intellectual property rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or more additional patents or pending patent applications in the U.S. and in other countries.";
-const char copyright_text_21[] = "Copyright © 2008 Sun Microsystems, Tous droits réservés.";
+const char copyright_text_21[] = "Copyright © 2010 Sun Microsystems, Tous droits réservés.";
const char copyright_text_22[] = "Sun Microsystems, Inc. a les droits de propriété intellectuels relatants à la technologie incorporée dans ce produit. En particulier, et sans la limitation, ces droits de propriété intellectuels peuvent inclure un ou plus des brevets américains énumérés à http://www.sun.com/patents et un ou les brevets plus supplémentaires ou les applications de brevet en attente dans les États - Unis et les autres pays.";
diff --git a/desktop/source/app/copyright_ascii_sun.c b/desktop/source/app/copyright_ascii_sun.c
index d120e81c04..3d437af856 100644
--- a/desktop/source/app/copyright_ascii_sun.c
+++ b/desktop/source/app/copyright_ascii_sun.c
@@ -4,12 +4,12 @@
*
*/
-const char copyright_text_1[] = "Copyright © 2008 Sun Microsystems, Inc., All rights reserved.";
+const char copyright_text_1[] = "Copyright © 2010 Sun Microsystems, Inc., All rights reserved.";
const char copyright_text_2[] = "Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is described in this document. In particular, and without limitation, these intellectual property rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or more additional patents or pending patent applications in the U.S. and in other countries.";
const char copyright_text_3[] = "U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Use is subject to license terms.";
const char copyright_text_4[] = "This distribution may include materials developed by third parties.Sun, Sun Microsystems, the Sun logo, Java, Solaris and StarOffice are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the U.S. and other countries.";
const char copyright_text_5[] = "UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open Company, Ltd.";
-const char copyright_text_21[] = "Copyright © 2008 Sun Microsystems, Tous droits réservés.";
+const char copyright_text_21[] = "Copyright © 2010 Sun Microsystems, Tous droits réservés.";
const char copyright_text_22[] = "Sun Microsystems, Inc. a les droits de propriété intellectuels relatants à la technologie incorporée dans ce produit. En particulier, et sans la limitation, ces droits de propriété intellectuels peuvent inclure un ou plus des brevets américains énumérés à http://www.sun.com/patents et un ou les brevets plus supplémentaires ou les applications de brevet en attente dans les États - Unis et les autres pays.";
const char copyright_text_23[] = "Ce produit ou document est protégé par un copyright et distribué avec des licences qui en restreignent l'utilisation, la copie, la distribution, et la décompilation. Aucune partie de ce produit ou document ne peut être reproduite sous aucune forme, par quelque moyen que ce soit, sans l'autorisation préalable et écrite de Sun et de ses bailleurs de licence, s'il y ena.";
const char copyright_text_24[] = "L'utilisation est soumise aux termes du contrat de licence.";
diff --git a/desktop/source/deployment/dp_persmap.cxx b/desktop/source/deployment/dp_persmap.cxx
index 43fe8b87f3..04f3f19d2e 100644
--- a/desktop/source/deployment/dp_persmap.cxx
+++ b/desktop/source/deployment/dp_persmap.cxx
@@ -104,7 +104,7 @@ PersistentMap::PersistentMap( OUString const & url_, bool readOnly )
OSL_ASSERT( false );
}
OString cstr_sysPath(
- OUStringToOString( m_sysPath, osl_getThreadTextEncoding() ) );
+ OUStringToOString( m_sysPath, RTL_TEXTENCODING_UTF8 ) );
char const * pcstr_sysPath = cstr_sysPath.getStr();
u_int32_t flags = DB_CREATE;
diff --git a/desktop/source/deployment/makefile.mk b/desktop/source/deployment/makefile.mk
index 8ee3efd34f..f63661df4c 100644
--- a/desktop/source/deployment/makefile.mk
+++ b/desktop/source/deployment/makefile.mk
@@ -82,6 +82,7 @@ SHL1STDLIBS = \
$(TOOLSLIB) \
$(XMLSCRIPTLIB) \
$(SVLLIB) \
+ $(UNOTOOLSLIB) \
$(DEPLOYMENTMISCLIB) \
$(HELPLINKERLIB)
diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx
index 61636da1e2..10ef1a7001 100644
--- a/desktop/source/deployment/registry/help/dp_help.cxx
+++ b/desktop/source/deployment/registry/help/dp_help.cxx
@@ -39,6 +39,7 @@
#include "ucbhelper/content.hxx"
#include "comphelper/servicedecl.hxx"
#include "svl/inettype.hxx"
+#include "unotools/pathoptions.hxx"
#include <transex3/compilehelp.hxx>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
@@ -350,8 +351,12 @@ void BackendImpl::implProcessHelp
pXhpFiles[iXhp] = aXhpRelFile;
}
+ rtl::OUString aOfficeHelpPath( SvtPathOptions().GetHelpPath() );
+ rtl::OUString aOfficeHelpPathFileURL;
+ ::osl::File::getFileURLFromSystemPath( aOfficeHelpPath, aOfficeHelpPathFileURL );
+
HelpProcessingErrorInfo aErrorInfo;
- bool bSuccess = compileExtensionHelp( aHelpStr, aLangURL,
+ bool bSuccess = compileExtensionHelp( aOfficeHelpPathFileURL, aHelpStr, aLangURL,
nXhpFileCount, pXhpFiles, aErrorInfo );
if( bSuccess && xInvocation.is() )
diff --git a/desktop/source/registration/com/sun/star/servicetag/BrowserSupport.java b/desktop/source/registration/com/sun/star/servicetag/BrowserSupport.java
index 7623e7f2f6..b0e944a0f8 100644
--- a/desktop/source/registration/com/sun/star/servicetag/BrowserSupport.java
+++ b/desktop/source/registration/com/sun/star/servicetag/BrowserSupport.java
@@ -1,14 +1,13 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: BrowserSupport.java,v $
- *
- * $Revision: 1.2 $
+ * $RCSfile: Registration.java,v $
+ * $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
diff --git a/desktop/source/registration/com/sun/star/servicetag/Installer.java b/desktop/source/registration/com/sun/star/servicetag/Installer.java
index b8e6e34dfd..f3b0b9c3c3 100644
--- a/desktop/source/registration/com/sun/star/servicetag/Installer.java
+++ b/desktop/source/registration/com/sun/star/servicetag/Installer.java
@@ -1,14 +1,13 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: Installer.java,v $
- *
- * $Revision: 1.2 $
+ * $RCSfile: Registration.java,v $
+ * $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
@@ -794,7 +793,7 @@ public class Installer {
reader.close();
}
- String resourceFilename = "/com/sun/star/servicetag/resources/register";
+ String resourceFilename = "/com/sun/servicetag/resources/register";
for (Locale locale : supportedLocales) {
String name = REGISTRATION_HTML_NAME;
String resource = resourceFilename;
diff --git a/desktop/source/registration/com/sun/star/servicetag/LinuxSystemEnvironment.java b/desktop/source/registration/com/sun/star/servicetag/LinuxSystemEnvironment.java
index 88ccd453a1..a58072d363 100644
--- a/desktop/source/registration/com/sun/star/servicetag/LinuxSystemEnvironment.java
+++ b/desktop/source/registration/com/sun/star/servicetag/LinuxSystemEnvironment.java
@@ -1,14 +1,13 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: LinuxSystemEnvironment.java,v $
- *
- * $Revision: 1.2 $
+ * $RCSfile: Registration.java,v $
+ * $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
@@ -29,6 +28,7 @@
*
************************************************************************/
+
package com.sun.star.servicetag;
// The Service Tags team maintains the latest version of the implementation
@@ -40,6 +40,7 @@ package com.sun.star.servicetag;
// (e.g. NetBeans and SunStudio) will use the version in JDK.
import java.io.*;
+import java.util.*;
/**
* Linux implementation of the SystemEnvironment class.
@@ -47,16 +48,25 @@ import java.io.*;
class LinuxSystemEnvironment extends SystemEnvironment {
LinuxSystemEnvironment() {
setHostId(getLinuxHostId());
- setSystemModel(getCommandOutput("/bin/uname", "-i"));
+
+ setSystemModel(getLinuxModel());
setSystemManufacturer(getLinuxSystemManufacturer());
setCpuManufacturer(getLinuxCpuManufacturer());
setSerialNumber(getLinuxSN());
+ setPhysMem(getLinuxPhysMem());
+ setSockets(getLinuxSockets());
+ setCores(getLinuxCores());
+ setVirtCpus(getLinuxVirtCpus());
+ setCpuName(getLinuxCpuName());
+ setClockRate(getLinuxClockRate());
}
private String dmiInfo = null;
+ private String kstatCpuInfo = null;
- private static final int SN = 1;
+ private static final int SN = 1;
private static final int SYS = 2;
private static final int CPU = 3;
+ private static final int MODEL = 4;
private String getLinuxHostId() {
String output = getCommandOutput("/usr/bin/hostid");
@@ -91,6 +101,21 @@ class LinuxSystemEnvironment extends SystemEnvironment {
return getLinuxDMIInfo("dmi type 4", "manufacturer");
}
+ private String getLinuxModel() {
+ String tmp = getLinuxPSNInfo(MODEL);
+ if (tmp.length() > 0) {
+ return tmp + "::" + getCommandOutput("/bin/uname","-v");
+ }
+
+ tmp = getLinuxDMIInfo("dmi type 1", "product name");
+ if (tmp.length() > 0) {
+ return tmp + "::" + getCommandOutput("/bin/uname","-v");
+ }
+
+ return getCommandOutput("/bin/uname","-i")
+ + "::" + getCommandOutput("/bin/uname","-v");
+ }
+
/**
* Tries to obtain and return the system manufacturer.
@@ -158,7 +183,7 @@ class LinuxSystemEnvironment extends SystemEnvironment {
dmidecodeThread.start();
try {
- dmidecodeThread.join(2000);
+ dmidecodeThread.join(3000);
if (dmidecodeThread.isAlive()) {
dmidecodeThread.interrupt();
dmiInfo = "";
@@ -191,4 +216,111 @@ class LinuxSystemEnvironment extends SystemEnvironment {
return "";
}
+ private String getLinuxClockRate() {
+ String contents = getFileContent("/proc/cpuinfo");
+ String token = "cpu MHz";
+ for (String line : contents.split("\n")) {
+ if (line.contains(token)) {
+ String[] key = line.split(":", 2);
+ if (key.length > 1) {
+ return key[1].trim();
+ }
+ }
+ }
+ return "";
+ }
+
+ private String getLinuxCpuName() {
+ String contents = getFileContent("/proc/cpuinfo");
+ String token = "model name";
+ for (String line : contents.split("\n")) {
+ if (line.contains(token)) {
+ String[] key = line.split(":", 2);
+ if (key.length > 1) {
+ return key[1].trim();
+ }
+ }
+ }
+ return "";
+ }
+
+ private String getLinuxVirtCpus() {
+ Set<String> set = new HashSet<String>();
+ String contents = getFileContent("/proc/cpuinfo");
+ String token = "processor";
+ for (String line : contents.split("\n")) {
+ if (line.contains(token)) {
+ String[] key = line.split(":", 2);
+ if (key.length > 1) {
+ set.add(key[1].trim());
+ }
+ }
+ }
+ return "" + set.size();
+ }
+
+ private String getLinuxCores() {
+ Set<String> set = new HashSet<String>();
+ String contents = getFileContent("/proc/cpuinfo");
+ String token = "core id";
+ for (String line : contents.split("\n")) {
+ if (line.contains(token)) {
+ String[] key = line.split(":", 2);
+ if (key.length > 1) {
+ set.add(key[1].trim());
+ }
+ }
+ }
+ if (set.size() == 0) {
+ return "1";
+ }
+ return "" + set.size();
+ }
+
+ private String getLinuxPhysMem() {
+ String contents = getFileContent("/proc/meminfo");
+ for (String line : contents.split("\n")) {
+ if (line.contains("MemTotal")) {
+ String[] total = line.split(":", 2);
+ if (total.length > 1) {
+ String[] mem = total[1].trim().split(" ");
+ if (mem.length >= 1) {
+ return mem[0].trim();
+ } else {
+ return total[1].trim();
+ }
+ }
+ }
+ }
+
+ return "";
+ }
+
+ private String getLinuxSockets() {
+ Set<String> physIdSet = new HashSet<String>();
+ Set<String> procSet = new HashSet<String>();
+ String contents = getFileContent("/proc/cpuinfo");
+ String physIdToken = "physical id";
+ String procToken = "processor";
+
+ for (String line : contents.split("\n")) {
+ if (line.contains(physIdToken)) {
+ String[] key = line.split(":", 2);
+ if (key.length > 1) {
+ physIdSet.add(key[1].trim());
+ }
+ }
+
+ if (line.contains(procToken)) {
+ String[] key = line.split(":", 2);
+ if (key.length > 1) {
+ procSet.add(key[1].trim());
+ }
+ }
+ }
+ if (physIdSet.size() != 0) {
+ return "" + physIdSet.size();
+ }
+ return "" + procSet.size();
+ }
}
diff --git a/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java b/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java
index 44ce33dece..c58d83a33d 100644
--- a/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java
+++ b/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java
@@ -1,473 +1,531 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: RegistrationData.java,v $
- *
- * $Revision: 1.2 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.servicetag;
-
-import java.io.*;
-import java.net.UnknownHostException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-
-import static com.sun.star.servicetag.RegistrationDocument.*;
-
-/**
- * A {@code RegistrationData} object is a container of one or more
- * {@link #getServiceTags service tags} that identify the
- * components for product registration.
- * Each {@code RegistrationData} object has a {@link #getRegistrationURN
- * uniform resource name} (URN) as its identifier.
- * <a name="EnvMap"></a>
- * It also has an <i>environment map</i> with
- * the following elements:
- * <blockquote>
- * <table border=0>
- * <tr>
- * <td><tt>hostname</tt></td>
- * <td>Hostname of the system</td>
- * <td>e.g. woody</td>
- * </tr>
- * <tr>
- * <td><tt>hostId</tt></td>
- * <td>Host ID of the system</td>
- * <td>e.g. 83abc1ab</td>
- * </tr>
- * <tr>
- * <td><tt>osName</tt></td>
- * <td>Operating system name</td>
- * <td> e.g. SunOS</td>
- * </tr>
- * <tr>
- * <td><tt>osVersion</tt></td>
- * <td>Operating system version</td>
- * <td> e.g. 5.10</td>
- * </tr>
- * <tr>
- * <td><tt>osArchitecture</tt></td>
- * <td>Operating system architecture</td>
- * <td> e.g. sparc</td>
- * </tr>
- * <tr>
- * <td><tt>systemModel</tt></td>
- * <td>System model</td>
- * <td> e.g. SUNW,Sun-Fire-V440</td>
- * </tr>
- * <tr>
- * <td><tt>systemManufacturer</tt></td>
- * <td>System manufacturer</td>
- * <td> e.g. Sun Microsystems</td>
- * </tr>
- * <tr>
- * <td><tt>cpuManufacturer</tt></td>
- * <td>CPU manufacturer</td>
- * <td> e.g. Sun Microsystems</td>
- * </tr>
- * <tr>
- * <td><tt>serialNumber</tt></td>
- * <td>System serial number</td>
- * <td> e.g. BEL078932</td>
- * </tr>
- * </table>
- * </blockquote>
- * The <tt>hostname</tt> and <tt>osName</tt> element must have a non-empty value.
- * If an element is not available on a system and their value will be
- * empty.
- * <p>
- * <a name="XMLSchema">
- * <b>Registration XML Schema</b></a>
- * <p>
- * A {@code RegistrationData} object can be {@link #loadFromXML loaded} from
- * and {@link #storeToXML stored} into an XML file in the format described
- * by the
- * <a href="https://sn-tools.central.sun.com/twiki/pub/ServiceTags/RegistrationRelayService/product_registration.xsd">
- * registration data schema</a>. The registration data schema is defined by the
- * Service Tags Technology.
- * <p>
- * Typically the registration data is constructed at installation time
- * and stored in an XML file for later service tag lookup or registration.
- *
- * <p>
- * <b>Example Usage</b>
- * <p>
- * The examples below show how the {@code RegistrationData} can be
- * used for product registration.
- * Exception handling is not shown in these examples for clarity.
- * <ol>
- * <li>This example shows how the JDK creates a JDK service tag, installs it
- * in the system service tag registry and adds it to the registration data.
- * <br>
- * <blockquote><pre>
- * // create a service tag object with an instance_urn
- * ServiceTag st = ServiceTag.newInstance(ServiceTag.generateInstanceURN(),
- * ....);
- * // Adds to the system service tag registry if supported
- * if (Registry.isSupported()) {
- * Registry.getSystemRegistry().addServiceTag(st);
- * }
- *
- * // add to the registration data
- * RegistrationData registration = new RegistrationData();
- * registration.addServiceTag(st);
- * </pre></blockquote>
- * </li>
- * <li>At this point, the registration data is ready to
- * send to Sun Connection for registration. This example shows how to register
- * the JDK via the <i>Registration Relay Service</i>.
- * <p>
- * There are several registration services for Sun Connection. For example,
- * the <a href="https://sn-tools.central.sun.com/twiki/bin/view/ServiceTags/RegistrationRelayService">
- * Registration Relay Service</a> is a web application interface that
- * processes the registration data payload sent via HTTP post
- * and hosts the registration user interface for a specified
- * registration URL. Refer to the
- * Registration Relay Service Specification for details.
- * <p>
- * <blockquote><pre>
- * // Open the connection to the URL of the registration service
- * HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
- * con.setDoInput(true);
- * con.setDoOutput(true);
- * con.setUseCaches(false);
- * con.setAllowUserInteraction(false);
- * con.setRequestMethod("POST");
- * con.setRequestProperty("Content-Type", "text/xml;charset=\"utf-8\"");
- * con.connect();
- *
- * // send the registration data to the registration service
- * OutputStream out = con.getOutputStream();
- * registration.storeToXML(out);
- * out.close();
- * </pre></blockquote>
- * </li>
- * <li>This example shows how to store the registration data in an XML file.
- * for later service tag lookup or registration.
- * <br>
- * <blockquote><pre>
- * BufferedOutputStream out = new BufferedOutputStream(
- * new FileOutputStream(""&lt;JAVA_HOME&gt;/lib/servicetag/registration.xml"));
- * registration.storeToXML(out);
- * out.close();
- * </pre></blockquote>
- * </li>
- * <li>This example shows how to install service tags that are in the
- * registration data in the system service tag registry when determined
- * to be available. The system service tag registry might not have existed
- * when the registration data was constructed.
- * <br>
- * <blockquote><pre>
- * if (Registry.isSupported()) {
- * Set&lt;ServiceTag&gt; svctags = registration.getServiceTags();
- * for (ServiceTag st : svctags) {
- * Registry.getSystemRegistry().addServiceTag(st);
- * }
- * }
- * </pre></blockquote>
- * </li>
- * </ol>
- *
- * @see <a href="https://sunconnection.sun.com/inventory">Sun Connection Inventory Channel</a>
- */
-public class RegistrationData {
- private final Map<String, String> environment;
- private final Map<String, ServiceTag> svcTagMap;
- private final String urn;
-
- /**
- * Creates a {@code RegistrationData} object with a generated
- * {@link #getRegistrationURN registration URN}.
- * The following keys in the {@link #getEnvironmentMap environment map}
- * will be initialized for the configuration of the
- * running system:
- * <blockquote>
- * <tt>hostname</tt>, <tt>osName</tt>, <tt>osVersion</tt> and
- * <tt>osArchitecture</tt>
- * </blockquote>
- * and the value of other keys may be empty.
- */
- public RegistrationData() {
- this(Util.generateURN());
- }
-
- // package private
- RegistrationData(String urn) {
- this.urn = urn;
- this.environment = initEnvironment();
- this.svcTagMap = new LinkedHashMap<String, ServiceTag>();
- }
-
- private Map<String, String> initEnvironment() {
- Map<String, String> map = new LinkedHashMap<String, String>();
- SystemEnvironment sysEnv = SystemEnvironment.getSystemEnvironment();
- map.put(ST_NODE_HOSTNAME, sysEnv.getHostname());
- map.put(ST_NODE_HOST_ID, sysEnv.getHostId());
- map.put(ST_NODE_OS_NAME, sysEnv.getOsName());
- map.put(ST_NODE_OS_VERSION, sysEnv.getOsVersion());
- map.put(ST_NODE_OS_ARCH, sysEnv.getOsArchitecture());
- map.put(ST_NODE_SYSTEM_MODEL, sysEnv.getSystemModel());
- map.put(ST_NODE_SYSTEM_MANUFACTURER, sysEnv.getSystemManufacturer());
- map.put(ST_NODE_CPU_MANUFACTURER, sysEnv.getCpuManufacturer());
- map.put(ST_NODE_SERIAL_NUMBER, sysEnv.getSerialNumber());
- return map;
- }
-
- /**
- * Returns the uniform resource name of this registration data
- * in this format:
- * <tt>urn:st:&lt;32-char {@link java.util.UUID uuid}&gt;</tt>
- *
- * @return the URN of this registration data.
- */
- public String getRegistrationURN() {
- return urn;
- }
-
- /**
- * Returns a map containing the environment information for this
- * registration data. See the set of <a href="#EnvMap">keys</a>
- * in the environment map. Subsequent update to the environment
- * map via the {@link #setEnvironment setEnvironment} method will not be reflected
- * in the returned map.
- *
- * @return an environment map for this registration data.
- */
- public Map<String, String> getEnvironmentMap() {
- return new LinkedHashMap<String,String>(environment);
- }
-
- /**
- * Sets an element of the specified {@code name} in the environment map
- * with the given {@code value}.
- *
- * @throws IllegalArgumentException if {@code name} is not a valid key
- * in the environment map, or {@code value} is not valid.
- */
- public void setEnvironment(String name, String value) {
- if (name == null) {
- throw new NullPointerException("name is null");
- }
- if (value == null) {
- throw new NullPointerException("value is null");
- }
- if (environment.containsKey(name)) {
- if (name.equals(ST_NODE_HOSTNAME) || name.equals(ST_NODE_OS_NAME)) {
- if (value.length() == 0) {
- throw new IllegalArgumentException("\"" +
- name + "\" requires non-empty value.");
- }
- }
- environment.put(name, value);
- } else {
- throw new IllegalArgumentException("\"" +
- name + "\" is not an environment element.");
- }
- }
-
- /**
- * Returns all service tags in this registration data.
- *
- * @return a {@link Set Set} of the service tags
- * in this registration data.
- */
- public Set<ServiceTag> getServiceTags() {
- return new HashSet<ServiceTag>(svcTagMap.values());
- }
-
- /**
- * Adds a service tag to this registration data.
- * If the given service tag has an empty <tt>instance_urn</tt>,
- * this method will generate a URN and place it in the copy
- * of the service tag in this registration data.
- * This method will return the {@code ServiceTag} object
- * added to this registration data.
- *
- * @param st {@code ServiceTag} object to be added.
- * @return a {@code ServiceTag} object added to this registration data.
- *
- * @throws IllegalArgumentException if
- * a service tag of the same {@link ServiceTag#getInstanceURN
- * <tt>instance_urn</tt>} already exists in the registry.
- */
- public synchronized ServiceTag addServiceTag(ServiceTag st) {
- ServiceTag svcTag = ServiceTag.newInstanceWithUrnTimestamp(st);
-
- String instanceURN = svcTag.getInstanceURN();
- if (svcTagMap.containsKey(instanceURN)) {
- throw new IllegalArgumentException("Instance_urn = " + instanceURN +
- " already exists in the registration data.");
- } else {
- svcTagMap.put(instanceURN, svcTag);
- }
- return svcTag;
- }
-
- /**
- * Returns a service tag of the given <tt>instance_urn</tt> in this registration
- * data.
- *
- * @param instanceURN the <tt>instance_urn</tt> of the service tag
- * @return the {@code ServiceTag} object of the given <tt>instance_urn</tt>
- * if exists; otherwise return {@code null}.
- */
- public synchronized ServiceTag getServiceTag(String instanceURN) {
- if (instanceURN == null) {
- throw new NullPointerException("instanceURN is null");
- }
- return svcTagMap.get(instanceURN);
- }
-
- /**
- * Removes a service tag of the given <tt>instance_urn</tt> from this
- * registration data.
- *
- * @param instanceURN the <tt>instance_urn</tt> of
- * the service tag to be removed.
- *
- * @return the removed {@code ServiceTag} object;
- * or {@code null} if the service tag does not exist in this
- * registration data.
- */
- public synchronized ServiceTag removeServiceTag(String instanceURN) {
- if (instanceURN == null) {
- throw new NullPointerException("instanceURN is null");
- }
-
- ServiceTag svcTag = null;
- if (svcTagMap.containsKey(instanceURN)) {
- svcTag = svcTagMap.remove(instanceURN);
- }
- return svcTag;
- }
-
- /**
- * Updates the <tt>product_defined_instance_id</tt> in the service tag
- * of the given <tt>instance_urn</tt> in this registration data.
- *
- * @param instanceURN the <tt>instance_urn</tt> of the service tag to be updated.
- * @param productDefinedInstanceID the value of the
- * <tt>product_defined_instance_id</tt> to be set.
- *
- * @return the updated {@code ServiceTag} object;
- * or {@code null} if the service tag does not exist in this
- * registration data.
- */
- public synchronized ServiceTag updateServiceTag(String instanceURN,
- String productDefinedInstanceID) {
- ServiceTag svcTag = getServiceTag(instanceURN);
- if (svcTag == null) {
- return null;
- }
-
- svcTag = ServiceTag.newInstanceWithUrnTimestamp(svcTag);
- // update the product defined instance ID field
- svcTag.setProductDefinedInstanceID(productDefinedInstanceID);
- svcTagMap.put(instanceURN, svcTag);
- return svcTag;
- }
-
- /**
- * Reads the registration data from the XML document on the
- * specified input stream. The XML document must be
- * in the format described by the <a href="#XMLSchema">
- * registration data schema</a>.
- * The specified stream is closed after this method returns.
- *
- * @param in the input stream from which to read the XML document.
- * @return a {@code RegistrationData} object read from the input
- * stream.
- *
- * @throws IllegalArgumentException if the input stream
- * contains an invalid registration data.
- *
- * @throws IOException if an error occurred when reading from the input stream.
- */
- public static RegistrationData loadFromXML(InputStream in) throws IOException {
- try {
- return RegistrationDocument.load(in);
- } finally {
- in.close();
- }
- }
-
- /**
- * Writes the registration data to the specified output stream
- * in the format described by the <a href="#XMLSchema">
- * registration data schema</a> with "UTF-8" encoding.
- * The specified stream remains open after this method returns.
- *
- * @param os the output stream on which to write the XML document.
- *
- * @throws IOException if an error occurred when writing to the output stream.
- */
- public void storeToXML(OutputStream os) throws IOException {
- RegistrationDocument.store(os, this);
- os.flush();
- }
-
- /**
- * Returns a newly allocated byte array containing the registration
- * data in XML format.
- *
- * @return a newly allocated byte array containing the registration
- * data in XML format.
- */
- public byte[] toXML() {
- try {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- storeToXML(out);
- return out.toByteArray();
- } catch (IOException e) {
- // should not reach here
- return new byte[0];
- }
- }
-
- /**
- * Returns a string representation of this registration data in XML
- * format.
- *
- * @return a string representation of this registration data in XML
- * format.
- */
- @Override
- public String toString() {
- try {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- storeToXML(out);
- return out.toString("UTF-8");
- } catch (IOException e) {
- // should not reach here
- return "Error creating the return string.";
- }
- }
-}
+
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can obtain
+ * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
+ * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
+ * Sun designates this particular file as subject to the "Classpath" exception
+ * as provided by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the License
+ * Header, with the fields enclosed by brackets [] replaced by your own
+ * identifying information: "Portions Copyrighted [year]
+ * [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.star.servicetag;
+
+import java.io.*;
+import java.net.UnknownHostException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import static com.sun.star.servicetag.RegistrationDocument.*;
+
+/**
+ * A {@code RegistrationData} object is a container of one or more
+ * {@link #getServiceTags service tags} that identify the
+ * components for product registration.
+ * Each {@code RegistrationData} object has a {@link #getRegistrationURN
+ * uniform resource name} (URN) as its identifier.
+ * <a name="EnvMap"></a>
+ * It also has an <i>environment map</i> with
+ * the following elements:
+ * <blockquote>
+ * <table border=0>
+ * <tr>
+ * <td><tt>hostname</tt></td>
+ * <td>Hostname of the system</td>
+ * <td>e.g. woody</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hostId</tt></td>
+ * <td>Host ID of the system</td>
+ * <td>e.g. 83abc1ab</td>
+ * </tr>
+ * <tr>
+ * <td><tt>osName</tt></td>
+ * <td>Operating system name</td>
+ * <td> e.g. SunOS</td>
+ * </tr>
+ * <tr>
+ * <td><tt>osVersion</tt></td>
+ * <td>Operating system version</td>
+ * <td> e.g. 5.10</td>
+ * </tr>
+ * <tr>
+ * <td><tt>osArchitecture</tt></td>
+ * <td>Operating system architecture</td>
+ * <td> e.g. sparc</td>
+ * </tr>
+ * <tr>
+ * <td><tt>systemModel</tt></td>
+ * <td>System model</td>
+ * <td> e.g. SUNW,Sun-Fire-V440</td>
+ * </tr>
+ * <tr>
+ * <td><tt>systemManufacturer</tt></td>
+ * <td>System manufacturer</td>
+ * <td> e.g. Sun Microsystems</td>
+ * </tr>
+ * <tr>
+ * <td><tt>cpuManufacturer</tt></td>
+ * <td>CPU manufacturer</td>
+ * <td> e.g. Sun Microsystems</td>
+ * </tr>
+ * <tr>
+ * <td><tt>serialNumber</tt></td>
+ * <td>System serial number</td>
+ * <td> e.g. BEL078932</td>
+ * </tr>
+ * <tr>
+ * <td><tt>physmem</tt></td>
+ * <td>Physical memory for the system (in MB)</td>
+ * <td> e.g. 4096</td>
+ * </tr>
+ * </table>
+ * </blockquote>
+ * The <tt>hostname</tt> and <tt>osName</tt> element must have a non-empty value.
+ * If an element is not available on a system and their value will be
+ * empty.
+ * <p>
+ * <a name="XMLSchema">
+ * <b>Registration XML Schema</b></a>
+ * <p>
+ * A {@code RegistrationData} object can be {@link #loadFromXML loaded} from
+ * and {@link #storeToXML stored} into an XML file in the format described
+ * by the
+ * <a href="https://sn-tools.central.sun.com/twiki/pub/ServiceTags/RegistrationRelayService/product_registration.xsd">
+ * registration data schema</a>. The registration data schema is defined by the
+ * Service Tags Technology.
+ * <p>
+ * Typically the registration data is constructed at installation time
+ * and stored in an XML file for later service tag lookup or registration.
+ *
+ * <p>
+ * <b>Example Usage</b>
+ * <p>
+ * The examples below show how the {@code RegistrationData} can be
+ * used for product registration.
+ * Exception handling is not shown in these examples for clarity.
+ * <ol>
+ * <li>This example shows how the JDK creates a JDK service tag, installs it
+ * in the system service tag registry and adds it to the registration data.
+ * <br>
+ * <blockquote><pre>
+ * // create a service tag object with an instance_urn
+ * ServiceTag st = ServiceTag.newInstance(ServiceTag.generateInstanceURN(),
+ * ....);
+ * // Adds to the system service tag registry if supported
+ * if (Registry.isSupported()) {
+ * Registry.getSystemRegistry().addServiceTag(st);
+ * }
+ *
+ * // add to the registration data
+ * RegistrationData registration = new RegistrationData();
+ * registration.addServiceTag(st);
+ * </pre></blockquote>
+ * </li>
+ * <li>At this point, the registration data is ready to
+ * send to Sun Connection for registration. This example shows how to register
+ * the JDK via the <i>Registration Relay Service</i>.
+ * <p>
+ * There are several registration services for Sun Connection. For example,
+ * the <a href="https://sn-tools.central.sun.com/twiki/bin/view/ServiceTags/RegistrationRelayService">
+ * Registration Relay Service</a> is a web application interface that
+ * processes the registration data payload sent via HTTP post
+ * and hosts the registration user interface for a specified
+ * registration URL. Refer to the
+ * Registration Relay Service Specification for details.
+ * <p>
+ * <blockquote><pre>
+ * // Open the connection to the URL of the registration service
+ * HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
+ * con.setDoInput(true);
+ * con.setDoOutput(true);
+ * con.setUseCaches(false);
+ * con.setAllowUserInteraction(false);
+ * con.setRequestMethod("POST");
+ * con.setRequestProperty("Content-Type", "text/xml;charset=\"utf-8\"");
+ * con.connect();
+ *
+ * // send the registration data to the registration service
+ * OutputStream out = con.getOutputStream();
+ * registration.storeToXML(out);
+ * out.close();
+ * </pre></blockquote>
+ * </li>
+ * <li>This example shows how to store the registration data in an XML file.
+ * for later service tag lookup or registration.
+ * <br>
+ * <blockquote><pre>
+ * BufferedOutputStream out = new BufferedOutputStream(
+ * new FileOutputStream(""&lt;JAVA_HOME&gt;/lib/servicetag/registration.xml"));
+ * registration.storeToXML(out);
+ * out.close();
+ * </pre></blockquote>
+ * </li>
+ * <li>This example shows how to install service tags that are in the
+ * registration data in the system service tag registry when determined
+ * to be available. The system service tag registry might not have existed
+ * when the registration data was constructed.
+ * <br>
+ * <blockquote><pre>
+ * if (Registry.isSupported()) {
+ * Set&lt;ServiceTag&gt; svctags = registration.getServiceTags();
+ * for (ServiceTag st : svctags) {
+ * Registry.getSystemRegistry().addServiceTag(st);
+ * }
+ * }
+ * </pre></blockquote>
+ * </li>
+ * </ol>
+ *
+ * @see <a href="https://sunconnection.sun.com/inventory">Sun Connection Inventory Channel</a>
+ */
+public class RegistrationData {
+ private final Map<String, String> environment;
+ private final Map<String, String> cpuInfo;
+ private final Map<String, ServiceTag> svcTagMap;
+ private final String urn;
+
+ /**
+ * Creates a {@code RegistrationData} object with a generated
+ * {@link #getRegistrationURN registration URN}.
+ * The following keys in the {@link #getEnvironmentMap environment map}
+ * will be initialized for the configuration of the
+ * running system:
+ * <blockquote>
+ * <tt>hostname</tt>, <tt>osName</tt>, <tt>osVersion</tt> and
+ * <tt>osArchitecture</tt>
+ * </blockquote>
+ * and the value of other keys may be empty.
+ */
+ public RegistrationData() {
+ this(Util.generateURN());
+ }
+
+ // package private
+ RegistrationData(String urn) {
+ this.urn = urn;
+ SystemEnvironment sysEnv = SystemEnvironment.getSystemEnvironment();
+ this.environment = initEnvironment(sysEnv);
+ this.cpuInfo = initCpuInfo(sysEnv);
+ this.svcTagMap = new LinkedHashMap<String, ServiceTag>();
+ }
+
+ private Map<String, String> initEnvironment(SystemEnvironment sysEnv) {
+ Map<String, String> map = new LinkedHashMap<String, String>();
+ map.put(ST_NODE_HOSTNAME, sysEnv.getHostname());
+ map.put(ST_NODE_HOST_ID, sysEnv.getHostId());
+ map.put(ST_NODE_OS_NAME, sysEnv.getOsName());
+ map.put(ST_NODE_OS_VERSION, sysEnv.getOsVersion());
+ map.put(ST_NODE_OS_ARCH, sysEnv.getOsArchitecture());
+ map.put(ST_NODE_SYSTEM_MODEL, sysEnv.getSystemModel());
+ map.put(ST_NODE_SYSTEM_MANUFACTURER, sysEnv.getSystemManufacturer());
+ map.put(ST_NODE_CPU_MANUFACTURER, sysEnv.getCpuManufacturer());
+ map.put(ST_NODE_SERIAL_NUMBER, sysEnv.getSerialNumber());
+ map.put(ST_NODE_PHYS_MEM, sysEnv.getPhysMem());
+ return map;
+ }
+
+ private Map<String, String> initCpuInfo(SystemEnvironment sysEnv) {
+ Map<String, String> map = new LinkedHashMap<String, String>();
+ map.put(ST_NODE_SOCKETS, sysEnv.getSockets());
+ map.put(ST_NODE_CORES, sysEnv.getCores());
+ map.put(ST_NODE_VIRT_CPUS, sysEnv.getVirtCpus());
+ map.put(ST_NODE_CPU_NAME, sysEnv.getCpuName());
+ map.put(ST_NODE_CLOCK_RATE, sysEnv.getClockRate());
+ return map;
+ }
+
+ /**
+ * Returns the uniform resource name of this registration data
+ * in this format:
+ * <tt>urn:st:&lt;32-char {@link java.util.UUID uuid}&gt;</tt>
+ *
+ * @return the URN of this registration data.
+ */
+ public String getRegistrationURN() {
+ return urn;
+ }
+
+ /**
+ * Returns a map containing the environment information for this
+ * registration data. See the set of <a href="#EnvMap">keys</a>
+ * in the environment map. Subsequent update to the environment
+ * map via the {@link #setEnvironment setEnvironment} method will not be reflected
+ * in the returned map.
+ *
+ * @return an environment map for this registration data.
+ */
+ public Map<String, String> getEnvironmentMap() {
+ return new LinkedHashMap<String,String>(environment);
+ }
+
+ /**
+ * Returns a map containing the cpu information for this
+ * registration data. Subsequent update to the cpu info
+ * map via the {@link #setCpuInfo setCpuInfo} method will not be reflected
+ * in the returned map.
+ *
+ * @return a cpu info map for this registration data.
+ */
+ public Map<String, String> getCpuInfoMap() {
+ return new LinkedHashMap<String,String>(cpuInfo);
+ }
+
+ /**
+ * Sets an element of the specified {@code name} in the environment map
+ * with the given {@code value}.
+ *
+ * @throws IllegalArgumentException if {@code name} is not a valid key
+ * in the environment map, or {@code value} is not valid.
+ */
+ public void setEnvironment(String name, String value) {
+ if (name == null) {
+ throw new NullPointerException("name is null");
+ }
+ if (value == null) {
+ throw new NullPointerException("value is null");
+ }
+ if (environment.containsKey(name)) {
+ if (name.equals(ST_NODE_HOSTNAME) || name.equals(ST_NODE_OS_NAME)) {
+ if (value.length() == 0) {
+ throw new IllegalArgumentException("\"" +
+ name + "\" requires non-empty value.");
+ }
+ }
+ environment.put(name, value);
+ } else {
+ throw new IllegalArgumentException("\"" +
+ name + "\" is not an environment element.");
+ }
+ }
+
+ /**
+ * Sets an element of the specified {@code name} in the cpu info map
+ * with the given {@code value}.
+ *
+ * @throws IllegalArgumentException if {@code name} is not a valid key
+ * in the cpu info map, or {@code value} is not valid.
+ */
+ public void setCpuInfo(String name, String value) {
+ if (name == null) {
+ throw new NullPointerException("name is null");
+ }
+ if (value == null) {
+ throw new NullPointerException("value is null");
+ }
+ if (cpuInfo.containsKey(name)) {
+ cpuInfo.put(name, value);
+ } else {
+ throw new IllegalArgumentException("\"" +
+ name + "\" is not an cpuinfo element.");
+ }
+ }
+
+ /**
+ * Returns all service tags in this registration data.
+ *
+ * @return a {@link Set Set} of the service tags
+ * in this registration data.
+ */
+ public Set<ServiceTag> getServiceTags() {
+ return new HashSet<ServiceTag>(svcTagMap.values());
+ }
+
+ /**
+ * Adds a service tag to this registration data.
+ * If the given service tag has an empty <tt>instance_urn</tt>,
+ * this method will generate a URN and place it in the copy
+ * of the service tag in this registration data.
+ * This method will return the {@code ServiceTag} object
+ * added to this registration data.
+ *
+ * @param st {@code ServiceTag} object to be added.
+ * @return a {@code ServiceTag} object added to this registration data.
+ *
+ * @throws IllegalArgumentException if
+ * a service tag of the same {@link ServiceTag#getInstanceURN
+ * <tt>instance_urn</tt>} already exists in the registry.
+ */
+ public synchronized ServiceTag addServiceTag(ServiceTag st) {
+ ServiceTag svcTag = ServiceTag.newInstanceWithUrnTimestamp(st);
+
+ String instanceURN = svcTag.getInstanceURN();
+ if (svcTagMap.containsKey(instanceURN)) {
+ throw new IllegalArgumentException("Instance_urn = " + instanceURN +
+ " already exists in the registration data.");
+ } else {
+ svcTagMap.put(instanceURN, svcTag);
+ }
+ return svcTag;
+ }
+
+ /**
+ * Returns a service tag of the given <tt>instance_urn</tt> in this registration
+ * data.
+ *
+ * @param instanceURN the <tt>instance_urn</tt> of the service tag
+ * @return the {@code ServiceTag} object of the given <tt>instance_urn</tt>
+ * if exists; otherwise return {@code null}.
+ */
+ public synchronized ServiceTag getServiceTag(String instanceURN) {
+ if (instanceURN == null) {
+ throw new NullPointerException("instanceURN is null");
+ }
+ return svcTagMap.get(instanceURN);
+ }
+
+ /**
+ * Removes a service tag of the given <tt>instance_urn</tt> from this
+ * registration data.
+ *
+ * @param instanceURN the <tt>instance_urn</tt> of
+ * the service tag to be removed.
+ *
+ * @return the removed {@code ServiceTag} object;
+ * or {@code null} if the service tag does not exist in this
+ * registration data.
+ */
+ public synchronized ServiceTag removeServiceTag(String instanceURN) {
+ if (instanceURN == null) {
+ throw new NullPointerException("instanceURN is null");
+ }
+
+ ServiceTag svcTag = null;
+ if (svcTagMap.containsKey(instanceURN)) {
+ svcTag = svcTagMap.remove(instanceURN);
+ }
+ return svcTag;
+ }
+
+ /**
+ * Updates the <tt>product_defined_instance_id</tt> in the service tag
+ * of the given <tt>instance_urn</tt> in this registration data.
+ *
+ * @param instanceURN the <tt>instance_urn</tt> of the service tag to be updated.
+ * @param productDefinedInstanceID the value of the
+ * <tt>product_defined_instance_id</tt> to be set.
+ *
+ * @return the updated {@code ServiceTag} object;
+ * or {@code null} if the service tag does not exist in this
+ * registration data.
+ */
+ public synchronized ServiceTag updateServiceTag(String instanceURN,
+ String productDefinedInstanceID) {
+ ServiceTag svcTag = getServiceTag(instanceURN);
+ if (svcTag == null) {
+ return null;
+ }
+
+ svcTag = ServiceTag.newInstanceWithUrnTimestamp(svcTag);
+ // update the product defined instance ID field
+ svcTag.setProductDefinedInstanceID(productDefinedInstanceID);
+ svcTagMap.put(instanceURN, svcTag);
+ return svcTag;
+ }
+
+ /**
+ * Reads the registration data from the XML document on the
+ * specified input stream. The XML document must be
+ * in the format described by the <a href="#XMLSchema">
+ * registration data schema</a>.
+ * The specified stream is closed after this method returns.
+ *
+ * @param in the input stream from which to read the XML document.
+ * @return a {@code RegistrationData} object read from the input
+ * stream.
+ *
+ * @throws IllegalArgumentException if the input stream
+ * contains an invalid registration data.
+ *
+ * @throws IOException if an error occurred when reading from the input stream.
+ */
+ public static RegistrationData loadFromXML(InputStream in) throws IOException {
+ try {
+ return RegistrationDocument.load(in);
+ } finally {
+ in.close();
+ }
+ }
+
+ /**
+ * Writes the registration data to the specified output stream
+ * in the format described by the <a href="#XMLSchema">
+ * registration data schema</a> with "UTF-8" encoding.
+ * The specified stream remains open after this method returns.
+ *
+ * @param os the output stream on which to write the XML document.
+ *
+ * @throws IOException if an error occurred when writing to the output stream.
+ */
+ public void storeToXML(OutputStream os) throws IOException {
+ RegistrationDocument.store(os, this);
+ os.flush();
+ }
+
+ /**
+ * Returns a newly allocated byte array containing the registration
+ * data in XML format.
+ *
+ * @return a newly allocated byte array containing the registration
+ * data in XML format.
+ */
+ public byte[] toXML() {
+ try {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ storeToXML(out);
+ return out.toByteArray();
+ } catch (IOException e) {
+ // should not reach here
+ return new byte[0];
+ }
+ }
+
+ /**
+ * Returns a string representation of this registration data in XML
+ * format.
+ *
+ * @return a string representation of this registration data in XML
+ * format.
+ */
+ @Override
+ public String toString() {
+ try {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ storeToXML(out);
+ return out.toString("UTF-8");
+ } catch (IOException e) {
+ // should not reach here
+ return "Error creating the return string.";
+ }
+ }
+}
diff --git a/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java b/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java
index ae810d205f..93a1f25a6c 100644
--- a/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java
+++ b/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java
@@ -1,374 +1,440 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: RegistrationDocument.java,v $
- *
- * $Revision: 1.2 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.servicetag;
-
-import java.io.*;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-import org.xml.sax.InputSource;
-
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import javax.xml.validation.Validator;
-
-// For write operation
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-/**
- * XML Support Class for Product Registration.
- */
-class RegistrationDocument {
-
- private static final String REGISTRATION_DATA_SCHEMA =
- "/com/sun/star/servicetag/resources/product_registration.xsd";
- private static final String REGISTRATION_DATA_VERSION = "1.0";
- private static final String SERVICE_TAG_VERSION = "1.0";
- final static String ST_NODE_REGISTRATION_DATA = "registration_data";
- final static String ST_ATTR_REGISTRATION_VERSION = "version";
- final static String ST_NODE_ENVIRONMENT = "environment";
- final static String ST_NODE_HOSTNAME = "hostname";
- final static String ST_NODE_HOST_ID = "hostId";
- final static String ST_NODE_OS_NAME = "osName";
- final static String ST_NODE_OS_VERSION = "osVersion";
- final static String ST_NODE_OS_ARCH = "osArchitecture";
- final static String ST_NODE_SYSTEM_MODEL = "systemModel";
- final static String ST_NODE_SYSTEM_MANUFACTURER = "systemManufacturer";
- final static String ST_NODE_CPU_MANUFACTURER = "cpuManufacturer";
- final static String ST_NODE_SERIAL_NUMBER = "serialNumber";
- final static String ST_NODE_REGISTRY = "registry";
- final static String ST_ATTR_REGISTRY_URN = "urn";
- final static String ST_ATTR_REGISTRY_VERSION = "version";
- final static String ST_NODE_SERVICE_TAG = "service_tag";
- final static String ST_NODE_INSTANCE_URN = "instance_urn";
- final static String ST_NODE_PRODUCT_NAME = "product_name";
- final static String ST_NODE_PRODUCT_VERSION = "product_version";
- final static String ST_NODE_PRODUCT_URN = "product_urn";
- final static String ST_NODE_PRODUCT_PARENT_URN = "product_parent_urn";
- final static String ST_NODE_PRODUCT_PARENT = "product_parent";
- final static String ST_NODE_PRODUCT_DEFINED_INST_ID = "product_defined_inst_id";
- final static String ST_NODE_PRODUCT_VENDOR = "product_vendor";
- final static String ST_NODE_PLATFORM_ARCH = "platform_arch";
- final static String ST_NODE_TIMESTAMP = "timestamp";
- final static String ST_NODE_CONTAINER = "container";
- final static String ST_NODE_SOURCE = "source";
- final static String ST_NODE_INSTALLER_UID = "installer_uid";
-
- static RegistrationData load(InputStream in) throws IOException {
- Document document = initializeDocument(in);
-
- // Gets the registration URN
- Element root = getRegistrationDataRoot(document);
- Element registryRoot =
- getSingletonElementFromRoot(root, ST_NODE_REGISTRY);
- String urn = registryRoot.getAttribute(ST_ATTR_REGISTRY_URN);
-
- // Construct a new RegistrationData object from the DOM tree
- // Initialize the environment map and service tags
- RegistrationData regData = new RegistrationData(urn);
- addServiceTags(registryRoot, regData);
-
- Element envRoot = getSingletonElementFromRoot(root, ST_NODE_ENVIRONMENT);
- buildEnvironmentMap(envRoot, regData);
- return regData;
- }
-
- static void store(OutputStream os, RegistrationData registration)
- throws IOException {
- // create a new document with the root node
- Document document = initializeDocument();
-
- // create the nodes for the environment map and the service tags
- // in the registration data
- addEnvironmentNodes(document,
- registration.getEnvironmentMap());
- addServiceTagRegistry(document,
- registration.getRegistrationURN(),
- registration.getServiceTags());
- transform(document, os);
- }
-
- // initialize a document from an input stream
- private static Document initializeDocument(InputStream in) throws IOException {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- try {
- // XML schema for validation
- SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- URL xsdUrl = RegistrationDocument.class.getResource(REGISTRATION_DATA_SCHEMA);
- Schema schema = sf.newSchema(xsdUrl);
- Validator validator = schema.newValidator();
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.parse(new InputSource(in));
- validator.validate(new DOMSource(doc));
- return doc;
- } catch (SAXException sxe) {
- IllegalArgumentException e = new IllegalArgumentException("Error generated in parsing");
- e.initCause(sxe);
- throw e;
- } catch (ParserConfigurationException pce) {
- // Parser with specific options can't be built
- // should not reach here
- InternalError x = new InternalError("Error in creating the new document");
- x.initCause(pce);
- throw x;
- }
- }
-
- // initialize a new document for the registration data
- private static Document initializeDocument() throws IOException {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- try {
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.newDocument();
-
- // initialize the document with the registration_data root
- Element root = doc.createElement(ST_NODE_REGISTRATION_DATA);
- doc.appendChild(root);
- root.setAttribute(ST_ATTR_REGISTRATION_VERSION, REGISTRATION_DATA_VERSION);
-
- return doc;
- } catch (ParserConfigurationException pce) {
- // Parser with specified options can't be built
- // should not reach here
- InternalError x = new InternalError("Error in creating the new document");
- x.initCause(pce);
- throw x;
- }
- }
-
- // Transform the current DOM tree with the given output stream.
- private static void transform(Document document, OutputStream os) {
- try {
- // Use a Transformer for output
- TransformerFactory tFactory = TransformerFactory.newInstance();
- tFactory.setAttribute("indent-number", new Integer(3));
-
- Transformer transformer = tFactory.newTransformer();
-
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");
- transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
- transformer.setOutputProperty(OutputKeys.STANDALONE, "yes");
- transformer.transform(new DOMSource(document),
- new StreamResult(new BufferedWriter(new OutputStreamWriter(os, "UTF-8"))));
- } catch (UnsupportedEncodingException ue) {
- // Should not reach here
- InternalError x = new InternalError("Error generated during transformation");
- x.initCause(ue);
- throw x;
- } catch (TransformerConfigurationException tce) {
- // Error generated by the parser
- // Should not reach here
- InternalError x = new InternalError("Error in creating the new document");
- x.initCause(tce);
- throw x;
- } catch (TransformerException te) {
- // Error generated by the transformer
- InternalError x = new InternalError("Error generated during transformation");
- x.initCause(te);
- throw x;
- }
- }
-
- private static void addServiceTagRegistry(Document document,
- String registryURN,
- Set<ServiceTag> svcTags) {
- // add service tag registry node and its attributes
- Element reg = document.createElement(ST_NODE_REGISTRY);
- reg.setAttribute(ST_ATTR_REGISTRY_URN, registryURN);
- reg.setAttribute(ST_ATTR_REGISTRY_VERSION, SERVICE_TAG_VERSION);
-
- Element root = getRegistrationDataRoot(document);
- root.appendChild(reg);
-
- // adds the elements for the service tags
- for (ServiceTag st : svcTags) {
- addServiceTagElement(document, reg, st);
- }
- }
-
- private static void addServiceTagElement(Document document,
- Element registryRoot,
- ServiceTag st) {
- Element svcTag = document.createElement(ST_NODE_SERVICE_TAG);
- registryRoot.appendChild(svcTag);
- addChildElement(document, svcTag,
- ST_NODE_INSTANCE_URN, st.getInstanceURN());
- addChildElement(document, svcTag,
- ST_NODE_PRODUCT_NAME, st.getProductName());
- addChildElement(document, svcTag,
- ST_NODE_PRODUCT_VERSION, st.getProductVersion());
- addChildElement(document, svcTag,
- ST_NODE_PRODUCT_URN, st.getProductURN());
- addChildElement(document, svcTag,
- ST_NODE_PRODUCT_PARENT_URN, st.getProductParentURN());
- addChildElement(document, svcTag,
- ST_NODE_PRODUCT_PARENT, st.getProductParent());
- addChildElement(document, svcTag,
- ST_NODE_PRODUCT_DEFINED_INST_ID,
- st.getProductDefinedInstanceID());
- addChildElement(document, svcTag,
- ST_NODE_PRODUCT_VENDOR, st.getProductVendor());
- addChildElement(document, svcTag,
- ST_NODE_PLATFORM_ARCH, st.getPlatformArch());
- addChildElement(document, svcTag,
- ST_NODE_TIMESTAMP, Util.formatTimestamp(st.getTimestamp()));
- addChildElement(document, svcTag,
- ST_NODE_CONTAINER, st.getContainer());
- addChildElement(document, svcTag,
- ST_NODE_SOURCE, st.getSource());
- addChildElement(document, svcTag,
- ST_NODE_INSTALLER_UID,
- String.valueOf(st.getInstallerUID()));
- }
-
- private static void addChildElement(Document document, Element root,
- String element, String text) {
- Element node = document.createElement(element);
- node.appendChild(document.createTextNode(text));
- root.appendChild(node);
- }
-
- // Constructs service tags from the document
- private static void addServiceTags(Element registryRoot,
- RegistrationData registration) {
- NodeList children = registryRoot.getElementsByTagName(ST_NODE_SERVICE_TAG);
- int length = (children == null ? 0 : children.getLength());
- for (int i = 0; i < length; i++) {
- Element svcTagElement = (Element) children.item(i);
- ServiceTag st = getServiceTag(svcTagElement);
- registration.addServiceTag(st);
- }
- }
-
- // build environment map from the document
- private static void buildEnvironmentMap(Element envRoot,
- RegistrationData registration) {
- registration.setEnvironment(ST_NODE_HOSTNAME, getTextValue(envRoot, ST_NODE_HOSTNAME));
- registration.setEnvironment(ST_NODE_HOST_ID, getTextValue(envRoot, ST_NODE_HOST_ID));
- registration.setEnvironment(ST_NODE_OS_NAME, getTextValue(envRoot, ST_NODE_OS_NAME));
- registration.setEnvironment(ST_NODE_OS_VERSION, getTextValue(envRoot, ST_NODE_OS_VERSION));
- registration.setEnvironment(ST_NODE_OS_ARCH, getTextValue(envRoot, ST_NODE_OS_ARCH));
- registration.setEnvironment(ST_NODE_SYSTEM_MODEL, getTextValue(envRoot, ST_NODE_SYSTEM_MODEL));
- registration.setEnvironment(ST_NODE_SYSTEM_MANUFACTURER, getTextValue(envRoot, ST_NODE_SYSTEM_MANUFACTURER));
- registration.setEnvironment(ST_NODE_CPU_MANUFACTURER, getTextValue(envRoot, ST_NODE_CPU_MANUFACTURER));
- registration.setEnvironment(ST_NODE_SERIAL_NUMBER, getTextValue(envRoot, ST_NODE_SERIAL_NUMBER));
- }
-
- // add the nodes representing the environment map in the document
- private static void addEnvironmentNodes(Document document,
- Map<String, String> envMap) {
- Element root = getRegistrationDataRoot(document);
- Element env = document.createElement(ST_NODE_ENVIRONMENT);
- root.appendChild(env);
- Set<Map.Entry<String, String>> keys = envMap.entrySet();
- for (Map.Entry<String, String> entry : keys) {
- addChildElement(document, env, entry.getKey(), entry.getValue());
- }
- }
-
- private static Element getRegistrationDataRoot(Document doc) {
- Element root = doc.getDocumentElement();
- if (!root.getNodeName().equals(ST_NODE_REGISTRATION_DATA)) {
- throw new IllegalArgumentException("Not a " +
- ST_NODE_REGISTRATION_DATA +
- " node \"" + root.getNodeName() + "\"");
- }
- return root;
- }
-
- private static Element getSingletonElementFromRoot(Element root, String name) {
- NodeList children = root.getElementsByTagName(name);
- int length = (children == null ? 0 : children.getLength());
- if (length != 1) {
- throw new IllegalArgumentException("Invalid number of " + name +
- " nodes = " + length);
- }
- Element e = (Element) children.item(0);
- if (!e.getNodeName().equals(name)) {
- throw new IllegalArgumentException("Not a " + name +
- " node \"" + e.getNodeName() + "\"");
- }
- return e;
- }
-
- // Constructs one ServiceTag instance from a service tag element root
- private static ServiceTag getServiceTag(Element svcTagElement) {
- return new ServiceTag(
- getTextValue(svcTagElement, ST_NODE_INSTANCE_URN),
- getTextValue(svcTagElement, ST_NODE_PRODUCT_NAME),
- getTextValue(svcTagElement, ST_NODE_PRODUCT_VERSION),
- getTextValue(svcTagElement, ST_NODE_PRODUCT_URN),
- getTextValue(svcTagElement, ST_NODE_PRODUCT_PARENT),
- getTextValue(svcTagElement, ST_NODE_PRODUCT_PARENT_URN),
- getTextValue(svcTagElement, ST_NODE_PRODUCT_DEFINED_INST_ID),
- getTextValue(svcTagElement, ST_NODE_PRODUCT_VENDOR),
- getTextValue(svcTagElement, ST_NODE_PLATFORM_ARCH),
- getTextValue(svcTagElement, ST_NODE_CONTAINER),
- getTextValue(svcTagElement, ST_NODE_SOURCE),
- Util.getIntValue(getTextValue(svcTagElement, ST_NODE_INSTALLER_UID)),
- Util.parseTimestamp(getTextValue(svcTagElement, ST_NODE_TIMESTAMP))
- );
- }
-
- private static String getTextValue(Element e, String tagName) {
- String value = "";
- NodeList nl = e.getElementsByTagName(tagName);
- if (nl != null && nl.getLength() > 0) {
- Element el = (Element) nl.item(0);
- Node node = el.getFirstChild();
- if (node != null) {
- value = node.getNodeValue();
- }
- }
- return value;
- }
-}
+
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can obtain
+ * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
+ * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
+ * Sun designates this particular file as subject to the "Classpath" exception
+ * as provided by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the License
+ * Header, with the fields enclosed by brackets [] replaced by your own
+ * identifying information: "Portions Copyrighted [year]
+ * [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.star.servicetag;
+
+import java.io.*;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+import org.xml.sax.InputSource;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
+// For write operation
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+/**
+ * XML Support Class for Product Registration.
+ */
+class RegistrationDocument {
+
+ private static final String REGISTRATION_DATA_SCHEMA =
+ "/com/sun/star/servicetag/resources/product_registration.xsd";
+ private static final String REGISTRATION_DATA_VERSION = "1.0";
+ private static final String SERVICE_TAG_VERSION = "1.0";
+ final static String ST_NODE_REGISTRATION_DATA = "registration_data";
+ final static String ST_ATTR_REGISTRATION_VERSION = "version";
+ final static String ST_NODE_ENVIRONMENT = "environment";
+ final static String ST_NODE_HOSTNAME = "hostname";
+ final static String ST_NODE_HOST_ID = "hostId";
+ final static String ST_NODE_OS_NAME = "osName";
+ final static String ST_NODE_OS_VERSION = "osVersion";
+ final static String ST_NODE_OS_ARCH = "osArchitecture";
+ final static String ST_NODE_SYSTEM_MODEL = "systemModel";
+ final static String ST_NODE_SYSTEM_MANUFACTURER = "systemManufacturer";
+ final static String ST_NODE_CPU_MANUFACTURER = "cpuManufacturer";
+ final static String ST_NODE_SERIAL_NUMBER = "serialNumber";
+ final static String ST_NODE_PHYS_MEM = "physmem";
+ final static String ST_NODE_CPU_INFO = "cpuinfo";
+ final static String ST_NODE_SOCKETS = "sockets";
+ final static String ST_NODE_CORES = "cores";
+ final static String ST_NODE_VIRT_CPUS = "virtcpus";
+ final static String ST_NODE_CPU_NAME = "name";
+ final static String ST_NODE_CLOCK_RATE = "clockrate";
+ final static String ST_NODE_REGISTRY = "registry";
+ final static String ST_ATTR_REGISTRY_URN = "urn";
+ final static String ST_ATTR_REGISTRY_VERSION = "version";
+ final static String ST_NODE_SERVICE_TAG = "service_tag";
+ final static String ST_NODE_INSTANCE_URN = "instance_urn";
+ final static String ST_NODE_PRODUCT_NAME = "product_name";
+ final static String ST_NODE_PRODUCT_VERSION = "product_version";
+ final static String ST_NODE_PRODUCT_URN = "product_urn";
+ final static String ST_NODE_PRODUCT_PARENT_URN = "product_parent_urn";
+ final static String ST_NODE_PRODUCT_PARENT = "product_parent";
+ final static String ST_NODE_PRODUCT_DEFINED_INST_ID = "product_defined_inst_id";
+ final static String ST_NODE_PRODUCT_VENDOR = "product_vendor";
+ final static String ST_NODE_PLATFORM_ARCH = "platform_arch";
+ final static String ST_NODE_TIMESTAMP = "timestamp";
+ final static String ST_NODE_CONTAINER = "container";
+ final static String ST_NODE_SOURCE = "source";
+ final static String ST_NODE_INSTALLER_UID = "installer_uid";
+
+ static RegistrationData load(InputStream in) throws IOException {
+ Document document = initializeDocument(in);
+
+ // Gets the registration URN
+ Element root = getRegistrationDataRoot(document);
+ Element registryRoot =
+ getSingletonElementFromRoot(root, ST_NODE_REGISTRY);
+ String urn = registryRoot.getAttribute(ST_ATTR_REGISTRY_URN);
+
+ // Construct a new RegistrationData object from the DOM tree
+ // Initialize the environment map and service tags
+ RegistrationData regData = new RegistrationData(urn);
+ addServiceTags(registryRoot, regData);
+
+ Element envRoot = getSingletonElementFromRoot(root, ST_NODE_ENVIRONMENT);
+ buildEnvironmentMap(envRoot, regData);
+
+ Element cpuInfo = getSingletonElementFromRoot(envRoot, ST_NODE_CPU_INFO);
+ buildCpuInfoMap(cpuInfo, regData);
+ return regData;
+ }
+
+ static void store(OutputStream os, RegistrationData registration)
+ throws IOException {
+ // create a new document with the root node
+ Document document = initializeDocument();
+
+ // create the nodes for the environment map and the service tags
+ // in the registration data
+ addEnvironmentNodes(document,
+ registration.getEnvironmentMap(),
+ registration.getCpuInfoMap());
+ addServiceTagRegistry(document,
+ registration.getRegistrationURN(),
+ registration.getServiceTags());
+ transform(document, os);
+ }
+
+ // initialize a document from an input stream
+ private static Document initializeDocument(InputStream in) throws IOException {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ SchemaFactory sf = null;
+ try {
+ // Some Java versions (e.g., 1.5.0_06-b05) fail with a
+ // NullPointerException if SchemaFactory.newInstance is called with
+ // a null context class loader, so work around that here (and the
+ // class loader of this class hopefully is not the null bootstrap
+ // class loader):
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (cl == null) {
+ Thread.currentThread().setContextClassLoader(
+ RegistrationDocument.class.getClassLoader());
+ }
+ try {
+ sf = SchemaFactory.newInstance(
+ XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+
+ Schema schema = null;
+ try {
+ // Even using the workaround above is not enough on some
+ // Java versions. Therefore try to workaround the validation
+ // completely!
+ URL xsdUrl = RegistrationDocument.class.getResource(REGISTRATION_DATA_SCHEMA);
+ schema = sf.newSchema(xsdUrl);
+ }
+ catch (NullPointerException nex) {
+ }
+
+ Validator validator = null;
+ if (schema != null)
+ validator = schema.newValidator();
+
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.parse(new InputSource(in));
+
+ if (validator != null)
+ validator.validate(new DOMSource(doc));
+
+ return doc;
+ } catch (SAXException sxe) {
+ IllegalArgumentException e = new IllegalArgumentException("Error generated in parsing");
+ e.initCause(sxe);
+ throw e;
+ } catch (ParserConfigurationException pce) {
+ // Parser with specific options can't be built
+ // should not reach here
+ InternalError x = new InternalError("Error in creating the new document");
+ x.initCause(pce);
+ throw x;
+ }
+ }
+
+ // initialize a new document for the registration data
+ private static Document initializeDocument() throws IOException {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ try {
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.newDocument();
+
+ // initialize the document with the registration_data root
+ Element root = doc.createElement(ST_NODE_REGISTRATION_DATA);
+ doc.appendChild(root);
+ root.setAttribute(ST_ATTR_REGISTRATION_VERSION, REGISTRATION_DATA_VERSION);
+
+ return doc;
+ } catch (ParserConfigurationException pce) {
+ // Parser with specified options can't be built
+ // should not reach here
+ InternalError x = new InternalError("Error in creating the new document");
+ x.initCause(pce);
+ throw x;
+ }
+ }
+
+ // Transform the current DOM tree with the given output stream.
+ private static void transform(Document document, OutputStream os) {
+ try {
+ // Use a Transformer for output
+ TransformerFactory tFactory = TransformerFactory.newInstance();
+ tFactory.setAttribute("indent-number", new Integer(3));
+
+ Transformer transformer = tFactory.newTransformer();
+
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+ transformer.setOutputProperty(OutputKeys.STANDALONE, "yes");
+ transformer.transform(new DOMSource(document),
+ new StreamResult(new BufferedWriter(new OutputStreamWriter(os, "UTF-8"))));
+ } catch (UnsupportedEncodingException ue) {
+ // Should not reach here
+ InternalError x = new InternalError("Error generated during transformation");
+ x.initCause(ue);
+ throw x;
+ } catch (TransformerConfigurationException tce) {
+ // Error generated by the parser
+ // Should not reach here
+ InternalError x = new InternalError("Error in creating the new document");
+ x.initCause(tce);
+ throw x;
+ } catch (TransformerException te) {
+ // Error generated by the transformer
+ InternalError x = new InternalError("Error generated during transformation");
+ x.initCause(te);
+ throw x;
+ }
+ }
+
+ private static void addServiceTagRegistry(Document document,
+ String registryURN,
+ Set<ServiceTag> svcTags) {
+ // add service tag registry node and its attributes
+ Element reg = document.createElement(ST_NODE_REGISTRY);
+ reg.setAttribute(ST_ATTR_REGISTRY_URN, registryURN);
+ reg.setAttribute(ST_ATTR_REGISTRY_VERSION, SERVICE_TAG_VERSION);
+
+ Element root = getRegistrationDataRoot(document);
+ root.appendChild(reg);
+
+ // adds the elements for the service tags
+ for (ServiceTag st : svcTags) {
+ addServiceTagElement(document, reg, st);
+ }
+ }
+
+ private static void addServiceTagElement(Document document,
+ Element registryRoot,
+ ServiceTag st) {
+ Element svcTag = document.createElement(ST_NODE_SERVICE_TAG);
+ registryRoot.appendChild(svcTag);
+ addChildElement(document, svcTag,
+ ST_NODE_INSTANCE_URN, st.getInstanceURN());
+ addChildElement(document, svcTag,
+ ST_NODE_PRODUCT_NAME, st.getProductName());
+ addChildElement(document, svcTag,
+ ST_NODE_PRODUCT_VERSION, st.getProductVersion());
+ addChildElement(document, svcTag,
+ ST_NODE_PRODUCT_URN, st.getProductURN());
+ addChildElement(document, svcTag,
+ ST_NODE_PRODUCT_PARENT_URN, st.getProductParentURN());
+ addChildElement(document, svcTag,
+ ST_NODE_PRODUCT_PARENT, st.getProductParent());
+ addChildElement(document, svcTag,
+ ST_NODE_PRODUCT_DEFINED_INST_ID,
+ st.getProductDefinedInstanceID());
+ addChildElement(document, svcTag,
+ ST_NODE_PRODUCT_VENDOR, st.getProductVendor());
+ addChildElement(document, svcTag,
+ ST_NODE_PLATFORM_ARCH, st.getPlatformArch());
+ addChildElement(document, svcTag,
+ ST_NODE_TIMESTAMP, Util.formatTimestamp(st.getTimestamp()));
+ addChildElement(document, svcTag,
+ ST_NODE_CONTAINER, st.getContainer());
+ addChildElement(document, svcTag,
+ ST_NODE_SOURCE, st.getSource());
+ addChildElement(document, svcTag,
+ ST_NODE_INSTALLER_UID,
+ String.valueOf(st.getInstallerUID()));
+ }
+
+ private static void addChildElement(Document document, Element root,
+ String element, String text) {
+ Element node = document.createElement(element);
+ node.appendChild(document.createTextNode(text));
+ root.appendChild(node);
+ }
+
+ // Constructs service tags from the document
+ private static void addServiceTags(Element registryRoot,
+ RegistrationData registration) {
+ NodeList children = registryRoot.getElementsByTagName(ST_NODE_SERVICE_TAG);
+ int length = (children == null ? 0 : children.getLength());
+ for (int i = 0; i < length; i++) {
+ Element svcTagElement = (Element) children.item(i);
+ ServiceTag st = getServiceTag(svcTagElement);
+ registration.addServiceTag(st);
+ }
+ }
+
+ // build environment map from the document
+ private static void buildEnvironmentMap(Element envRoot,
+ RegistrationData registration) {
+ registration.setEnvironment(ST_NODE_HOSTNAME, getTextValue(envRoot, ST_NODE_HOSTNAME));
+ registration.setEnvironment(ST_NODE_HOST_ID, getTextValue(envRoot, ST_NODE_HOST_ID));
+ registration.setEnvironment(ST_NODE_OS_NAME, getTextValue(envRoot, ST_NODE_OS_NAME));
+ registration.setEnvironment(ST_NODE_OS_VERSION, getTextValue(envRoot, ST_NODE_OS_VERSION));
+ registration.setEnvironment(ST_NODE_OS_ARCH, getTextValue(envRoot, ST_NODE_OS_ARCH));
+ registration.setEnvironment(ST_NODE_SYSTEM_MODEL, getTextValue(envRoot, ST_NODE_SYSTEM_MODEL));
+ registration.setEnvironment(ST_NODE_SYSTEM_MANUFACTURER, getTextValue(envRoot, ST_NODE_SYSTEM_MANUFACTURER));
+ registration.setEnvironment(ST_NODE_CPU_MANUFACTURER, getTextValue(envRoot, ST_NODE_CPU_MANUFACTURER));
+ registration.setEnvironment(ST_NODE_SERIAL_NUMBER, getTextValue(envRoot, ST_NODE_SERIAL_NUMBER));
+ registration.setEnvironment(ST_NODE_PHYS_MEM, getTextValue(envRoot, ST_NODE_PHYS_MEM));
+ }
+
+ private static void buildCpuInfoMap(Element cpuInfoRoot,
+ RegistrationData registration) {
+ registration.setCpuInfo(ST_NODE_SOCKETS, getTextValue(cpuInfoRoot, ST_NODE_SOCKETS));
+ registration.setCpuInfo(ST_NODE_CORES, getTextValue(cpuInfoRoot, ST_NODE_CORES));
+ registration.setCpuInfo(ST_NODE_VIRT_CPUS, getTextValue(cpuInfoRoot, ST_NODE_VIRT_CPUS));
+ registration.setCpuInfo(ST_NODE_CPU_NAME, getTextValue(cpuInfoRoot, ST_NODE_CPU_NAME));
+ registration.setCpuInfo(ST_NODE_CLOCK_RATE, getTextValue(cpuInfoRoot, ST_NODE_CLOCK_RATE));
+ }
+
+ // add the nodes representing the environment map in the document
+ private static void addEnvironmentNodes(Document document,
+ Map<String, String> envMap,
+ Map<String, String> cpuInfoMap) {
+ Element root = getRegistrationDataRoot(document);
+
+ Element env = document.createElement(ST_NODE_ENVIRONMENT);
+ root.appendChild(env);
+ Set<Map.Entry<String, String>> keys = envMap.entrySet();
+ for (Map.Entry<String, String> entry : keys) {
+ addChildElement(document, env, entry.getKey(), entry.getValue());
+ }
+
+ Element cpuInfo = document.createElement(ST_NODE_CPU_INFO);
+ env.appendChild(cpuInfo);
+ keys = cpuInfoMap.entrySet();
+ for (Map.Entry<String, String> entry : keys) {
+ addChildElement(document, cpuInfo, entry.getKey(), entry.getValue());
+ }
+ }
+
+ private static Element getRegistrationDataRoot(Document doc) {
+ Element root = doc.getDocumentElement();
+ if (!root.getNodeName().equals(ST_NODE_REGISTRATION_DATA)) {
+ throw new IllegalArgumentException("Not a " +
+ ST_NODE_REGISTRATION_DATA +
+ " node \"" + root.getNodeName() + "\"");
+ }
+ return root;
+ }
+
+ private static Element getSingletonElementFromRoot(Element root, String name) {
+ NodeList children = root.getElementsByTagName(name);
+ int length = (children == null ? 0 : children.getLength());
+ if (length != 1) {
+ throw new IllegalArgumentException("Invalid number of " + name +
+ " nodes = " + length);
+ }
+ Element e = (Element) children.item(0);
+ if (!e.getNodeName().equals(name)) {
+ throw new IllegalArgumentException("Not a " + name +
+ " node \"" + e.getNodeName() + "\"");
+ }
+ return e;
+ }
+
+ // Constructs one ServiceTag instance from a service tag element root
+ private static ServiceTag getServiceTag(Element svcTagElement) {
+ return new ServiceTag(
+ getTextValue(svcTagElement, ST_NODE_INSTANCE_URN),
+ getTextValue(svcTagElement, ST_NODE_PRODUCT_NAME),
+ getTextValue(svcTagElement, ST_NODE_PRODUCT_VERSION),
+ getTextValue(svcTagElement, ST_NODE_PRODUCT_URN),
+ getTextValue(svcTagElement, ST_NODE_PRODUCT_PARENT),
+ getTextValue(svcTagElement, ST_NODE_PRODUCT_PARENT_URN),
+ getTextValue(svcTagElement, ST_NODE_PRODUCT_DEFINED_INST_ID),
+ getTextValue(svcTagElement, ST_NODE_PRODUCT_VENDOR),
+ getTextValue(svcTagElement, ST_NODE_PLATFORM_ARCH),
+ getTextValue(svcTagElement, ST_NODE_CONTAINER),
+ getTextValue(svcTagElement, ST_NODE_SOURCE),
+ Util.getIntValue(getTextValue(svcTagElement, ST_NODE_INSTALLER_UID)),
+ Util.parseTimestamp(getTextValue(svcTagElement, ST_NODE_TIMESTAMP))
+ );
+ }
+
+ private static String getTextValue(Element e, String tagName) {
+ String value = "";
+ NodeList nl = e.getElementsByTagName(tagName);
+ if (nl != null && nl.getLength() > 0) {
+ Element el = (Element) nl.item(0);
+ Node node = el.getFirstChild();
+ if (node != null) {
+ value = node.getNodeValue();
+ }
+ }
+ return value;
+ }
+}
diff --git a/desktop/source/registration/com/sun/star/servicetag/Registry.java b/desktop/source/registration/com/sun/star/servicetag/Registry.java
index 879db1fdec..51c90b9e94 100644
--- a/desktop/source/registration/com/sun/star/servicetag/Registry.java
+++ b/desktop/source/registration/com/sun/star/servicetag/Registry.java
@@ -1,14 +1,13 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: Registry.java,v $
- *
- * $Revision: 1.2 $
+ * $RCSfile: Registration.java,v $
+ * $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
diff --git a/desktop/source/registration/com/sun/star/servicetag/ServiceTag.java b/desktop/source/registration/com/sun/star/servicetag/ServiceTag.java
index 26a2bbdd60..cfaa04baca 100644
--- a/desktop/source/registration/com/sun/star/servicetag/ServiceTag.java
+++ b/desktop/source/registration/com/sun/star/servicetag/ServiceTag.java
@@ -1,14 +1,13 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: ServiceTag.java,v $
- *
- * $Revision: 1.2 $
+ * $RCSfile: Registration.java,v $
+ * $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
diff --git a/desktop/source/registration/com/sun/star/servicetag/SolarisServiceTag.java b/desktop/source/registration/com/sun/star/servicetag/SolarisServiceTag.java
index 45ff7b8f7d..1ce6790094 100644
--- a/desktop/source/registration/com/sun/star/servicetag/SolarisServiceTag.java
+++ b/desktop/source/registration/com/sun/star/servicetag/SolarisServiceTag.java
@@ -1,14 +1,13 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: SolarisServiceTag.java,v $
- *
- * $Revision: 1.2 $
+ * $RCSfile: Registration.java,v $
+ * $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
diff --git a/desktop/source/registration/com/sun/star/servicetag/SolarisSystemEnvironment.java b/desktop/source/registration/com/sun/star/servicetag/SolarisSystemEnvironment.java
index 35dcdba239..01420fba8a 100644
--- a/desktop/source/registration/com/sun/star/servicetag/SolarisSystemEnvironment.java
+++ b/desktop/source/registration/com/sun/star/servicetag/SolarisSystemEnvironment.java
@@ -1,14 +1,13 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: SolarisSystemEnvironment.java,v $
- *
- * $Revision: 1.2 $
+ * $RCSfile: Registration.java,v $
+ * $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
@@ -40,17 +39,180 @@ package com.sun.star.servicetag;
// (e.g. NetBeans and SunStudio) will use the version in JDK.
import java.io.*;
+import java.util.Set;
+import java.util.HashSet;
/**
* Solaris implementation of the SystemEnvironment class.
*/
class SolarisSystemEnvironment extends SystemEnvironment {
+ private static final int SN = 1;
+ private static final int SYS = 2;
+ private static final int CPU = 3;
+ private static final int MODEL = 4;
+ private String kstatCpuInfo = null;
+
SolarisSystemEnvironment() {
setHostId(getCommandOutput("/usr/bin/hostid"));
- setSystemModel(getCommandOutput("/usr/bin/uname", "-i"));
+ setSystemModel(getSolarisModel());
setSystemManufacturer(getSolarisSystemManufacturer());
setCpuManufacturer(getSolarisCpuManufacturer());
setSerialNumber(getSolarisSN());
+ setPhysMem(getSolarisPhysMem());
+ setSockets(getSolarisSockets());
+ setCores(getSolarisCores());
+ setVirtCpus(getSolarisVirtCpus());
+ setCpuName(getSolarisCpuName());
+ setClockRate(getSolarisClockRate());
+ }
+
+ private String getSolarisClockRate() {
+ String data = getSolarisKstatCpuInfo();
+
+ String lines[] = data.split("\n");
+ String token = "clock_MHz";
+ for (int i=0; i<lines.length; i++) {
+ String line = lines[i].trim();
+ if (line.startsWith(token)) {
+ return line.substring(line.indexOf(token) + token.length()).trim();
+ }
+ }
+ return "";
+ }
+
+ private String getSolarisCpuName() {
+ String data = getSolarisKstatCpuInfo();
+
+ String lines[] = data.split("\n");
+ String token = "brand";
+ for (int i=0; i<lines.length; i++) {
+ String line = lines[i].trim();
+ if (line.startsWith(token)) {
+ return line.substring(line.indexOf(token) + token.length()).trim();
+ }
+ }
+ return "";
+ }
+
+ private String getSolarisVirtCpus() {
+ String data = getSolarisKstatCpuInfo();
+
+ int cnt = 0;
+ String lines[] = data.split("\n");
+ String token = " cpu_info ";
+ for (int i=0; i<lines.length; i++) {
+ String line = lines[i].trim();
+ if (line.indexOf(token) != -1) {
+ cnt++;
+ }
+ }
+ return "" + cnt;
+ }
+
+ private String getSolarisCores() {
+ String data = getSolarisKstatCpuInfo();
+
+ Set<String> set = new HashSet<String>();
+ String lines[] = data.split("\n");
+ String coreIdToken = "core_id";
+ String coreId = "";
+ String chipIdToken = "chip_id";
+ String chipId = "";
+ for (int i=0; i<lines.length; i++) {
+ String line = lines[i].trim();
+ if (line.startsWith(chipIdToken)) {
+ chipId = line.substring(line.indexOf(chipIdToken) + chipIdToken.length()).trim();
+ }
+ if (line.startsWith(coreIdToken)) {
+ coreId = line.substring(line.indexOf(coreIdToken) + coreIdToken.length()).trim();
+ set.add(chipId + "," + coreId);
+ }
+ }
+ return "" + set.size();
+ }
+
+ private String getSolarisPhysMem() {
+ String data = getCommandOutput("/usr/sbin/prtconf");
+
+ int cnt = 0;
+ String lines[] = data.split("\n");
+ String token = "Memory size:";
+ for (int i=0; i<lines.length; i++) {
+ String line = lines[i].trim();
+ if (line.startsWith(token)) {
+ line = line.substring(line.indexOf(token) + token.length()).trim();
+ if (line.indexOf(" ") != -1) {
+ return line.substring(0, line.indexOf(" ")).trim();
+ }
+ }
+ }
+ return "";
+ }
+
+ private String getSolarisSockets() {
+ String data = getSolarisKstatCpuInfo();
+
+ Set<String> set = new HashSet<String>();
+ String lines[] = data.split("\n");
+ String token = "chip_id";
+ for (int i=0; i<lines.length; i++) {
+ String line = lines[i].trim();
+ if (line.startsWith(token)) {
+ String id = line.substring(line.indexOf(token) + token.length()).trim();
+ set.add(id);
+ }
+ }
+ return "" + set.size();
+ }
+
+ private synchronized String getSolarisKstatCpuInfo() {
+ // only try to get kstat cpu_info information once, after that, we can
+ // reuse the output
+ if (kstatCpuInfo == null) {
+ Thread thread = new Thread() {
+ public void run() {
+ kstatCpuInfo = getCommandOutput("/usr/bin/kstat", "cpu_info");
+ }
+ };
+ thread.start();
+
+ try {
+ thread.join(2000);
+ if (thread.isAlive()) {
+ thread.interrupt();
+ kstatCpuInfo = "";
+ }
+ } catch (InterruptedException ie) {
+ thread.interrupt();
+ }
+ }
+ return kstatCpuInfo;
+ }
+
+ private String getSolarisModel() {
+ String tmp = getFileContent("/var/run/psn");
+ if (tmp.length() > 0) {
+ String[] lines = tmp.split("\n");
+ if (MODEL <= lines.length) {
+ return lines[MODEL-1] + "::"
+ + getCommandOutput("/usr/bin/uname", "-v");
+ }
+ }
+
+ if ("sparc".equalsIgnoreCase(System.getProperty("os.arch"))) {
+ return getCommandOutput("/usr/bin/uname", "-i") + "::"
+ + getCommandOutput("/usr/bin/uname", "-v");
+ } else {
+ String model = getSmbiosData("1", "Product: ");
+ if (model == null || model.trim().equals("")) {
+ model = getCommandOutput("/usr/bin/uname", "-i");
+ }
+ if (model == null) {
+ model = "";
+ }
+ return model.trim() + "::"
+ + getCommandOutput("/usr/bin/uname", "-v");
+ }
}
/**
@@ -58,13 +220,21 @@ class SolarisSystemEnvironment extends SystemEnvironment {
* @return The cpu manufacturer (an empty string if not found or an error occurred)
*/
private String getSolarisCpuManufacturer() {
+ String tmp = getFileContent("/var/run/psn");
+ if (tmp.length() > 0) {
+ String[] lines = tmp.split("\n");
+ if (CPU <= lines.length) {
+ return lines[CPU-1];
+ }
+ }
+
// not fully accurate, this could be another manufacturer (fujitsu for example)
if ("sparc".equalsIgnoreCase(System.getProperty("os.arch"))) {
return "Sun Microsystems, Inc";
}
- // if we're here, then we'll try smbios (type 3)
- return getSmbiosData("3", "Manufacturer: ");
+ // if we're here, then we'll try smbios (type 4)
+ return getSmbiosData("4", "Manufacturer: ");
}
/**
@@ -72,8 +242,19 @@ class SolarisSystemEnvironment extends SystemEnvironment {
* @return The system manufacturer (an empty string if not found or an error occurred)
*/
private String getSolarisSystemManufacturer() {
+ String tmp = getFileContent("/var/run/psn");
+ if (tmp.length() > 0) {
+ String[] lines = tmp.split("\n");
+ if (SYS <= lines.length) {
+ return lines[SYS-1];
+ }
+ }
+
// not fully accurate, this could be another manufacturer (fujitsu for example)
if ("sparc".equalsIgnoreCase(System.getProperty("os.arch"))) {
+ if (getCommandOutput("/usr/bin/uname", "-m").equals("sun4us")) {
+ return "Fujitsu";
+ }
return "Sun Microsystems, Inc";
}
@@ -89,7 +270,10 @@ class SolarisSystemEnvironment extends SystemEnvironment {
// try to read from the psn file if it exists
String tmp = getFileContent("/var/run/psn");
if (tmp.length() > 0) {
- return tmp.trim();
+ String[] lines = tmp.split("\n");
+ if (SN <= lines.length) {
+ return lines[SN-1];
+ }
}
// if we're here, then we'll try sneep
@@ -110,6 +294,17 @@ class SolarisSystemEnvironment extends SystemEnvironment {
return tmpSN;
}
+ if ("sparc".equalsIgnoreCase(System.getProperty("os.arch"))) {
+ tmpSN = getSNViaPrtfruX();
+ if (tmpSN.length() > 0) {
+ return tmpSN;
+ }
+ tmpSN = getSNViaPrtfru();
+ if (tmpSN.length() > 0) {
+ return tmpSN;
+ }
+ }
+
// give up and return
return "";
}
@@ -156,4 +351,74 @@ class SolarisSystemEnvironment extends SystemEnvironment {
}
}
+ private String getSNViaPrtfruX() {
+ String data = getCommandOutput("/usr/sbin/prtfru", "-x");
+
+ boolean FRUTREE_FLAG = false;
+ boolean FRUNAME_FLAG = false;
+ boolean MB_LABEL_FLAG = false;
+ boolean SYSTEM_BOARD_FLAG = false;
+
+ String lines[] = data.split("\n");
+ for (int i=0; i<lines.length; i++) {
+ String line = lines[i];
+ if (SYSTEM_BOARD_FLAG) {
+ String tok = "<Sun_Serial_No value=\"";
+ int index = line.indexOf(tok);
+ if (index != -1) {
+ String val = line.substring(index+tok.length());
+ String vals[] = val.split("\"");
+ if (vals.length > 0) {
+ return vals[0].trim();
+ }
+ break;
+ }
+ }
+
+ if (line.indexOf("</ContainerData>") != -1) {
+ FRUTREE_FLAG = false;
+ FRUNAME_FLAG = false;
+ SYSTEM_BOARD_FLAG = false;
+ }
+
+ if (FRUNAME_FLAG && line.indexOf("<Container name=\"system-board\">") != -1 ) {
+ SYSTEM_BOARD_FLAG = true;
+ }
+
+ if (FRUTREE_FLAG && line.indexOf("<Fru name=\"chassis\">") != -1 ) {
+ FRUNAME_FLAG = true;
+ }
+
+ if (line.indexOf("<Location name=\"frutree\">") != -1) {
+ FRUTREE_FLAG = true;
+ }
+ }
+
+ return "";
+ }
+
+ private String getSNViaPrtfru() {
+ String data = getCommandOutput("/usr/sbin/prtfru");
+ boolean CHASSIS_FLAG = false;
+
+ String lines[] = data.split("\n");
+ for (int i=0; i<lines.length; i++) {
+ String line = lines[i];
+ if (CHASSIS_FLAG) {
+ String tok = "/ManR/Sun_Serial_No:";
+ int index = line.indexOf(tok);
+ if (index != -1) {
+ String val = line.substring(index+tok.length());
+ return val.trim();
+ }
+ }
+
+ if (line.indexOf("/frutree/chassis/system-board (container)") != -1) {
+ CHASSIS_FLAG = true;
+ } else if (line.indexOf("/frutree/chassis/MB?Label=MB/system-board (container)") != -1) {
+ CHASSIS_FLAG = true;
+ }
+ }
+ return "";
+ }
}
diff --git a/desktop/source/registration/com/sun/star/servicetag/SunConnection.java b/desktop/source/registration/com/sun/star/servicetag/SunConnection.java
index 36c527e018..5bc3396e1b 100644
--- a/desktop/source/registration/com/sun/star/servicetag/SunConnection.java
+++ b/desktop/source/registration/com/sun/star/servicetag/SunConnection.java
@@ -1,14 +1,13 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: SunConnection.java,v $
- *
- * $Revision: 1.2 $
+ * $RCSfile: Registration.java,v $
+ * $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
diff --git a/desktop/source/registration/com/sun/star/servicetag/SysnetRegistryHelper.java b/desktop/source/registration/com/sun/star/servicetag/SysnetRegistryHelper.java
index 3295a2d45d..2508565b51 100644
--- a/desktop/source/registration/com/sun/star/servicetag/SysnetRegistryHelper.java
+++ b/desktop/source/registration/com/sun/star/servicetag/SysnetRegistryHelper.java
@@ -1,14 +1,13 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: SysnetRegistryHelper.java,v $
- *
- * $Revision: 1.2 $
+ * $RCSfile: Registration.java,v $
+ * $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
diff --git a/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java b/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java
index 40151dfa4c..badf5bbbfd 100644
--- a/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java
+++ b/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java
@@ -1,14 +1,13 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: SystemEnvironment.java,v $
- *
- * $Revision: 1.2 $
+ * $RCSfile: Registration.java,v $
+ * $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
@@ -57,6 +56,12 @@ public class SystemEnvironment {
private String systemManufacturer;
private String cpuManufacturer;
private String serialNumber;
+ private String physmem;
+ private String sockets;
+ private String cores;
+ private String virtcpus;
+ private String cpuname;
+ private String clockrate;
private static SystemEnvironment sysEnv = null;
public static synchronized SystemEnvironment getSystemEnvironment() {
@@ -90,6 +95,12 @@ public class SystemEnvironment {
this.systemManufacturer = "";
this.cpuManufacturer = "";
this.serialNumber = "";
+ this.physmem = "";
+ this.sockets = "";
+ this.cores = "";
+ this.virtcpus = "";
+ this.cpuname = "";
+ this.clockrate = "";
}
@@ -158,6 +169,56 @@ public class SystemEnvironment {
}
/**
+ * Sets the physmem
+ * @param physmem The physmem to set.
+ */
+ public void setPhysMem(String physmem) {
+ this.physmem = physmem;
+ }
+
+ /**
+ * Sets the sockets
+ * @param sockets The sockets to set.
+ */
+ public void setSockets(String sockets) {
+ this.sockets = sockets;
+ }
+
+ /**
+ * Sets the cores
+ * @param cores The cores to set.
+ */
+ public void setCores(String cores) {
+ this.cores = cores;
+ }
+
+ /**
+ * Sets the virtcpus
+ * @param virtcpus The virtcpus to set.
+ */
+ public void setVirtCpus(String virtcpus) {
+ this.virtcpus = virtcpus;
+ }
+
+ /**
+ * Sets the cpuname
+ * @param cpuname The cpuname to set.
+ */
+ public void setCpuName(String cpuname) {
+ this.cpuname = cpuname;
+ }
+
+ /**
+ * Sets the clockrate
+ * @param clockrate The clockrate to set.
+ */
+ public void setClockRate(String clockrate) {
+ Float f = Float.parseFloat(clockrate);
+ Integer nClockrate = f.intValue();
+ this.clockrate = nClockrate.toString();
+ }
+
+ /**
* Sets the hostid. Truncates to a max length of 16 chars.
* @param hostId The hostid to set.
*/
@@ -227,6 +288,30 @@ public class SystemEnvironment {
return serialNumber;
}
+ public String getPhysMem() {
+ return physmem;
+ }
+
+ public String getSockets() {
+ return sockets;
+ }
+
+ public String getCores() {
+ return cores;
+ }
+
+ public String getVirtCpus() {
+ return virtcpus;
+ }
+
+ public String getCpuName() {
+ return cpuname;
+ }
+
+ public String getClockRate() {
+ return clockrate;
+ }
+
/**
* Returns the hostId.
* @return The hostId.
diff --git a/desktop/source/registration/com/sun/star/servicetag/UnauthorizedAccessException.java b/desktop/source/registration/com/sun/star/servicetag/UnauthorizedAccessException.java
index 196e987955..fd1e26643a 100644
--- a/desktop/source/registration/com/sun/star/servicetag/UnauthorizedAccessException.java
+++ b/desktop/source/registration/com/sun/star/servicetag/UnauthorizedAccessException.java
@@ -1,14 +1,13 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: UnauthorizedAccessException.java,v $
- *
- * $Revision: 1.2 $
+ * $RCSfile: Registration.java,v $
+ * $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
diff --git a/desktop/source/registration/com/sun/star/servicetag/Util.java b/desktop/source/registration/com/sun/star/servicetag/Util.java
index e8ae3fc6ed..7de1e832a5 100644
--- a/desktop/source/registration/com/sun/star/servicetag/Util.java
+++ b/desktop/source/registration/com/sun/star/servicetag/Util.java
@@ -1,14 +1,13 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: Util.java,v $
- *
- * $Revision: 1.2 $
+ * $RCSfile: Registration.java,v $
+ * $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
@@ -40,7 +39,7 @@ import java.util.UUID;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
-// Utility class for com.sun.star.servicetag package
+// Utility class for com.sun.servicetag package
class Util {
private static boolean verbose = (System.getProperty("servicetag.verbose") != null);
private static String jrepath = null;
diff --git a/desktop/source/registration/com/sun/star/servicetag/WindowsSystemEnvironment.java b/desktop/source/registration/com/sun/star/servicetag/WindowsSystemEnvironment.java
index 97ceeb5e7d..ec391d8270 100644
--- a/desktop/source/registration/com/sun/star/servicetag/WindowsSystemEnvironment.java
+++ b/desktop/source/registration/com/sun/star/servicetag/WindowsSystemEnvironment.java
@@ -1,14 +1,13 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: WindowsSystemEnvironment.java,v $
- *
- * $Revision: 1.2 $
+ * $RCSfile: Registration.java,v $
+ * $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
@@ -33,7 +32,7 @@ package com.sun.star.servicetag;
// The Service Tags team maintains the latest version of the implementation
// for system environment data collection. JDK will include a copy of
-// the most recent released version for a JDK release. We rename
+// the most recent released version for a JDK release. We rename
// the package to com.sun.servicetag so that the Sun Connection
// product always uses the latest version from the com.sun.scn.servicetags
// package. JDK and users of the com.sun.servicetag API
@@ -42,6 +41,8 @@ package com.sun.star.servicetag;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
/**
* Windows implementation of the SystemEnvironment class.
@@ -71,6 +72,13 @@ class WindowsSystemEnvironment extends SystemEnvironment {
}
setCpuManufacturer(cpuMfr);
+ setSockets(getWindowsSockets());
+ setCores(getWindowsCores());
+ setVirtCpus(getWindowsVirtCpus());
+ setPhysMem(getWindowsPhysMem());
+ setCpuName(getWmicResult("cpu", "get", "Name"));
+ setClockRate(getWmicResult("cpu", "get", "MaxClockSpeed"));
+
// try to remove the temp file that gets created from running wmic cmds
try {
// look in the current working directory
@@ -83,6 +91,44 @@ class WindowsSystemEnvironment extends SystemEnvironment {
}
}
+ private String getWindowsVirtCpus() {
+ String res = getWmicResult("cpu", "get", "NumberOfLogicalProcessors");
+ if (res == null || res.equals("")) {
+ res = "1";
+ }
+ return res;
+ }
+
+ private String getWindowsCores() {
+ String res = getWmicResult("cpu", "get", "NumberOfCores");
+ if (res == null || res.equals("")) {
+ res = "1";
+ }
+ return res;
+ }
+
+ private String getWindowsSockets() {
+ String res = getFullWmicResult("cpu", "get", "DeviceID");
+ Set<String> set = new HashSet<String>();
+ for (String line : res.split("\n")) {
+ line = line.trim();
+ if (line.equals("")) {
+ continue;
+ }
+ set.add(line);
+ }
+ if (set.size() == 0) {
+ return "1";
+ }
+ return "" + set.size();
+ }
+
+ private String getWindowsPhysMem() {
+ String mem = getWmicResult("computersystem", "get", "TotalPhysicalMemory");
+ long l = Long.parseLong(mem);
+ return "" + ((long) (l / (1024*1024)));
+ }
+
/**
* This method invokes wmic outside of the normal environment
@@ -142,4 +188,48 @@ class WindowsSystemEnvironment extends SystemEnvironment {
}
return res.trim();
}
+
+ private String getFullWmicResult(String alias, String verb, String property) {
+ String res = "";
+ BufferedReader in = null;
+ try {
+ ProcessBuilder pb = new ProcessBuilder("cmd", "/C", "WMIC", alias, verb, property);
+ Process p = pb.start();
+ // need this for executing windows commands (at least
+ // needed for executing wmic command)
+ BufferedWriter bw = new BufferedWriter(
+ new OutputStreamWriter(p.getOutputStream()));
+ bw.write(13);
+ bw.flush();
+ bw.close();
+
+ p.waitFor();
+ if (p.exitValue() == 0) {
+ in = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ String line = null;
+ while ((line = in.readLine()) != null) {
+ line = line.trim();
+ if (line.length() == 0) {
+ continue;
+ }
+ if (line.toLowerCase().indexOf(property.toLowerCase()) != -1) {
+ continue;
+ }
+ res += line + "\n";
+ }
+ }
+
+ } catch (Exception e) {
+ // ignore the exception
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ return res;
+ }
}
diff --git a/desktop/source/registration/com/sun/star/servicetag/resources/product_registration.xsd b/desktop/source/registration/com/sun/star/servicetag/resources/product_registration.xsd
index e9b34417d9..bb48ba9084 100644
--- a/desktop/source/registration/com/sun/star/servicetag/resources/product_registration.xsd
+++ b/desktop/source/registration/com/sun/star/servicetag/resources/product_registration.xsd
@@ -1,301 +1,366 @@
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
-
-<xs:element name="registration_data">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="environment"
- minOccurs="1"
- maxOccurs="1">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="hostname"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="hostId"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="osName"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="osVersion"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="osArchitecture"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="systemModel"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="systemManufacturer"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="cpuManufacturer"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="serialNumber"
- minOccurs='1'
- maxOccurs='1'/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="registry"
- minOccurs="1"
- maxOccurs="1">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="service_tag"
- minOccurs="0"
- maxOccurs="1024">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="instance_urn"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="product_name"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="product_version"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="product_urn"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="product_parent_urn"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="product_parent"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="product_defined_inst_id"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="product_vendor"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="platform_arch"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="timestamp"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="container"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="source"
- minOccurs='1'
- maxOccurs='1'/>
- <xs:element ref="installer_uid"
- minOccurs='1'
- maxOccurs='1'/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="urn"
- type="xs:string"
- use="required"/>
- <xs:attribute name="version"
- type="xs:string"
- use="required"/>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="version"
- type="xs:string"
- use="required"/>
- </xs:complexType>
-</xs:element>
-
- <!-- definition of simple elements -->
- <xs:element name="hostname">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="1"/>
- <xs:maxLength value="255"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="hostId">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="0"/>
- <xs:maxLength value="16"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="osName">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="1"/>
- <xs:maxLength value="256"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="osVersion">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="0"/>
- <xs:maxLength value="50"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="osArchitecture">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="0"/>
- <xs:maxLength value="256"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="systemModel">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="0"/>
- <xs:maxLength value="50"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="systemManufacturer">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="0"/>
- <xs:maxLength value="50"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="cpuManufacturer">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="0"/>
- <xs:maxLength value="50"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="serialNumber">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="0"/>
- <xs:maxLength value="256"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="instance_urn">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="1"/>
- <xs:maxLength value="255"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="product_name">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:maxLength value="255"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="product_version">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:maxLength value="63"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="product_urn">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="1"/>
- <xs:maxLength value="255"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="product_parent_urn">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="0"/>
- <xs:maxLength value="255"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="product_parent">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="1"/>
- <xs:maxLength value="255"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="product_defined_inst_id">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="0"/>
- <xs:maxLength value="255"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="product_vendor">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="1"/>
- <xs:maxLength value="63"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="platform_arch">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:minLength value="1"/>
- <xs:maxLength value="63"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="timestamp">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:maxLength value="24"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="container">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:maxLength value="63"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="source">
- <xs:simpleType>
- <xs:restriction base="xs:string">
- <xs:maxLength value="63"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
- <xs:element name="installer_uid">
- <xs:simpleType>
- <xs:restriction base="xs:integer">
- </xs:restriction>
- </xs:simpleType>
- </xs:element>
-
-</xs:schema>
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+<xs:element name="registration_data">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="environment"
+ minOccurs="1"
+ maxOccurs="1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="hostname"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="hostId"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="osName"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="osVersion"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="osArchitecture"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="systemModel"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="systemManufacturer"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="cpuManufacturer"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="serialNumber"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="physmem"
+ minOccurs='0'
+ maxOccurs='1'/>
+ <xs:element name="cpuinfo"
+ minOccurs='0'
+ maxOccurs='1'>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="sockets"
+ minOccurs='0'
+ maxOccurs='1'/>
+ <xs:element ref="cores"
+ minOccurs='0'
+ maxOccurs='1'/>
+ <xs:element ref="virtcpus"
+ minOccurs='0'
+ maxOccurs='1'/>
+ <xs:element ref="name"
+ minOccurs='0'
+ maxOccurs='1'/>
+ <xs:element ref="clockrate"
+ minOccurs='0'
+ maxOccurs='1'/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="registry"
+ minOccurs="1"
+ maxOccurs="1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="service_tag"
+ minOccurs="0"
+ maxOccurs="1024">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="instance_urn"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="product_name"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="product_version"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="product_urn"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="product_parent_urn"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="product_parent"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="product_defined_inst_id"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="product_vendor"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="platform_arch"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="timestamp"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="container"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="source"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="installer_uid"
+ minOccurs='1'
+ maxOccurs='1'/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="urn"
+ type="xs:string"
+ use="required"/>
+ <xs:attribute name="version"
+ type="xs:string"
+ use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="version"
+ type="xs:string"
+ use="required"/>
+ </xs:complexType>
+</xs:element>
+
+ <!-- definition of simple elements -->
+ <xs:element name="hostname">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="1"/>
+ <xs:maxLength value="255"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="hostId">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="16"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="osName">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="1"/>
+ <xs:maxLength value="256"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="osVersion">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="50"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="osArchitecture">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="256"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="systemModel">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="50"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="systemManufacturer">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="50"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="cpuManufacturer">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="50"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="serialNumber">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="256"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="instance_urn">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="1"/>
+ <xs:maxLength value="255"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="product_name">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:maxLength value="255"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="product_version">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:maxLength value="63"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="product_urn">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="1"/>
+ <xs:maxLength value="255"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="product_parent_urn">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="255"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="product_parent">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="255"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="product_defined_inst_id">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="255"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="product_vendor">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="63"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="platform_arch">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="63"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="timestamp">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:maxLength value="24"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="container">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:maxLength value="63"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="source">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:maxLength value="63"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="installer_uid">
+ <xs:simpleType>
+ <xs:restriction base="xs:integer">
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="physmem">
+ <xs:simpleType>
+ <xs:restriction base="xs:integer"/>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="sockets">
+ <xs:simpleType>
+ <xs:restriction base="xs:integer"/>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="cores">
+ <xs:simpleType>
+ <xs:restriction base="xs:integer"/>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="virtcpus">
+ <xs:simpleType>
+ <xs:restriction base="xs:integer"/>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="name">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:maxLength value="128"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="clockrate">
+ <xs:simpleType>
+ <xs:restriction base="xs:integer"/>
+ </xs:simpleType>
+ </xs:element>
+
+</xs:schema>
diff --git a/framework/inc/classes/fwktabwindow.hxx b/framework/inc/classes/fwktabwindow.hxx
index e9d7f0bd4b..84574282e8 100644
--- a/framework/inc/classes/fwktabwindow.hxx
+++ b/framework/inc/classes/fwktabwindow.hxx
@@ -125,6 +125,7 @@ public:
~FwkTabWindow();
void AddEventListener( const Link& rEventListener );
+ void RemoveEventListener( const Link& rEventListener );
FwkTabPage* AddTabPage( sal_Int32 nIndex, const css::uno::Sequence< css::beans::NamedValue >& rProperties );
void ActivatePage( sal_Int32 nIndex );
void RemovePage( sal_Int32 nIndex );
diff --git a/framework/inc/services/autorecovery.hxx b/framework/inc/services/autorecovery.hxx
index ab249fc5ba..55efef2335 100644
--- a/framework/inc/services/autorecovery.hxx
+++ b/framework/inc/services/autorecovery.hxx
@@ -239,7 +239,8 @@ class AutoRecovery : public css::lang::XTypeProvider
E_SESSION_SAVE = 64,
E_SESSION_RESTORE = 128,
E_DISABLE_AUTORECOVERY = 256,
- E_SET_AUTOSAVE_STATE = 512
+ E_SET_AUTOSAVE_STATE = 512,
+ E_SESSION_QUIET_QUIT = 1024
};
//---------------------------------------
@@ -884,6 +885,10 @@ class AutoRecovery : public css::lang::XTypeProvider
//---------------------------------------
// TODO document me
+ void implts_doSessionQuietQuit(const DispatchParams& aParams);
+
+ //---------------------------------------
+ // TODO document me
void implts_doSessionRestore(const DispatchParams& aParams);
//---------------------------------------
diff --git a/framework/inc/services/sessionlistener.hxx b/framework/inc/services/sessionlistener.hxx
index b78a0547b4..bc35993b79 100644
--- a/framework/inc/services/sessionlistener.hxx
+++ b/framework/inc/services/sessionlistener.hxx
@@ -49,7 +49,7 @@
#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/frame/XSessionManagerListener.hpp>
+#include <com/sun/star/frame/XSessionManagerListener2.hpp>
#include <com/sun/star/frame/XSessionManagerClient.hpp>
#include <com/sun/star/frame/XStatusListener.hpp>
#include <com/sun/star/frame/FeatureStateEvent.hpp>
@@ -98,7 +98,7 @@ namespace framework{
class SessionListener : // interfaces
public css::lang::XTypeProvider,
public css::lang::XInitialization,
- public css::frame::XSessionManagerListener,
+ public css::frame::XSessionManagerListener2,
public css::frame::XStatusListener,
public css::lang::XServiceInfo,
// baseclasses (order important for initialization!)
@@ -119,7 +119,19 @@ class SessionListener : // interfaces
// restore handling
sal_Bool m_bRestored;
+
+ sal_Bool m_bSessionStoreRequested;
+
+ sal_Bool m_bAllowUserInteractionOnQuit;
+ sal_Bool m_bTerminated;
+
+ // in case of synchronous call the caller should do saveDone() call himself!
+ void StoreSession( sal_Bool bAsync );
+
+ // let session quietly close the documents, remove lock files, store configuration and etc.
+ void QuitSessionQuietly();
+
public:
//---------------------------------------
@@ -146,7 +158,7 @@ class SessionListener : // interfaces
SessionListener( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR );
virtual ~SessionListener();
-
+
virtual void SAL_CALL disposing(const com::sun::star::lang::EventObject&) throw (css::uno::RuntimeException);
@@ -163,6 +175,10 @@ class SessionListener : // interfaces
virtual sal_Bool SAL_CALL doRestore()
throw (css::uno::RuntimeException);
+ // XSessionManagerListener2
+ virtual void SAL_CALL doQuit()
+ throw (::com::sun::star::uno::RuntimeException);
+
// XStatusListener
virtual void SAL_CALL statusChanged(const com::sun::star::frame::FeatureStateEvent& event)
throw (css::uno::RuntimeException);
diff --git a/framework/inc/services/tabwindowservice.hxx b/framework/inc/services/tabwindowservice.hxx
index 198d84be0b..0614397e21 100644
--- a/framework/inc/services/tabwindowservice.hxx
+++ b/framework/inc/services/tabwindowservice.hxx
@@ -48,13 +48,13 @@
#include <macros/xinterface.hxx>
#include <macros/xtypeprovider.hxx>
#include <macros/xserviceinfo.hxx>
-#include <general.h>
+#include <general.h>
#include <stdtypes.h>
-
+
//_________________________________________________________________________________________________________________
// interface includes
//_________________________________________________________________________________________________________________
-
+
#include <com/sun/star/awt/XSimpleTabController.hpp>
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -62,7 +62,7 @@
//_________________________________________________________________________________________________________________
// other includes
//_________________________________________________________________________________________________________________
-
+
#include <cppuhelper/weak.hxx>
#include <vcl/window.hxx>
@@ -81,31 +81,31 @@ namespace framework{
//_________________________________________________________________________________________________________________
struct TTabPageInfo
-{
- public:
+{
+ public:
- TTabPageInfo()
- : m_nIndex ( -1 )
- , m_bCreated (sal_False)
- , m_pPage ( NULL )
- , m_lProperties ( )
- {}
-
- TTabPageInfo(::sal_Int32 nID)
- : m_nIndex ( nID )
- , m_bCreated (sal_False)
- , m_pPage ( NULL )
- , m_lProperties ( )
- {}
-
- public:
+ TTabPageInfo()
+ : m_nIndex ( -1 )
+ , m_bCreated (sal_False)
+ , m_pPage ( NULL )
+ , m_lProperties ( )
+ {}
+
+ TTabPageInfo(::sal_Int32 nID)
+ : m_nIndex ( nID )
+ , m_bCreated (sal_False)
+ , m_pPage ( NULL )
+ , m_lProperties ( )
+ {}
+
+ public:
- ::sal_Int32 m_nIndex;
+ ::sal_Int32 m_nIndex;
::sal_Bool m_bCreated;
FwkTabPage* m_pPage;
css::uno::Sequence< css::beans::NamedValue > m_lProperties;
-};
-
+};
+
typedef ::std::hash_map< ::sal_Int32 ,
TTabPageInfo ,
Int32HashCode ,
@@ -118,10 +118,11 @@ typedef ::std::hash_map< ::sal_Int32 ,
class TabWindowService : public css::lang::XTypeProvider
, public css::lang::XServiceInfo
, public css::awt::XSimpleTabController
+ , public css::lang::XComponent
, public ThreadHelpBase
, public TransactionBase
- , public PropertySetHelper
- , public ::cppu::OWeakObject
+ , public PropertySetHelper
+ , public ::cppu::OWeakObject
{
//-------------------------------------------------------------------------------------------------------------
// public methods
@@ -132,7 +133,7 @@ class TabWindowService : public css::lang::XTypeProvider
//---------------------------------------------------------------------------------------------------------
// constructor / destructor
//---------------------------------------------------------------------------------------------------------
-
+
TabWindowService( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
virtual ~TabWindowService();
@@ -186,8 +187,8 @@ class TabWindowService : public css::lang::XTypeProvider
DECL_DLLPRIVATE_LINK( EventListener, VclSimpleEvent * );
- void impl_checkTabIndex (::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException);
- TTabPageInfoHash::iterator impl_getTabPageInfo(::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException);
+ void impl_checkTabIndex (::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException);
+ TTabPageInfoHash::iterator impl_getTabPageInfo(::sal_Int32 nID) throw (css::lang::IndexOutOfBoundsException);
FwkTabWindow* mem_TabWin ();
/*
::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
@@ -203,26 +204,26 @@ class TabWindowService : public css::lang::XTypeProvider
private:
/// reference to factory, which has created this instance
- css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory;
-
+ css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory;
+
/// the tab window as XWindow ( to hold window* alive !)
- css::uno::Reference< css::awt::XWindow > m_xTabWin;
-
- /// the VCL tab window
- FwkTabWindow* m_pTabWin;
-
- /// container of inserted tab pages
- TTabPageInfoHash m_lTabPageInfos;
-
+ css::uno::Reference< css::awt::XWindow > m_xTabWin;
+
+ /// the VCL tab window
+ FwkTabWindow* m_pTabWin;
+
+ /// container of inserted tab pages
+ TTabPageInfoHash m_lTabPageInfos;
+
/// container of the added TabListener
::cppu::OMultiTypeInterfaceContainerHelper m_lListener;
-
+
/// counter of the tabpage indexes
- ::sal_Int32 m_nPageIndexCounter;
-
+ ::sal_Int32 m_nPageIndexCounter;
+
/// index of the current active page
::sal_Int32 m_nCurrentPageIndex;
-
+
/// title of the tabcontrolled window
::rtl::OUString m_sTitle;
diff --git a/framework/source/classes/fwktabwindow.cxx b/framework/source/classes/fwktabwindow.cxx
index 8ffa00a492..af8319c193 100644
--- a/framework/source/classes/fwktabwindow.cxx
+++ b/framework/source/classes/fwktabwindow.cxx
@@ -65,7 +65,6 @@ namespace framework
{
// class FwkTabControl ---------------------------------------------------
-
FwkTabControl::FwkTabControl( Window* pParent, const ResId& rResId ) :
TabControl( pParent, rResId )
@@ -336,6 +335,11 @@ void FwkTabWindow::AddEventListener( const Link& rEventListener )
m_aTabCtrl.AddEventListener( rEventListener );
}
+void FwkTabWindow::RemoveEventListener( const Link& rEventListener )
+{
+ m_aTabCtrl.RemoveEventListener( rEventListener );
+}
+
// -----------------------------------------------------------------------
FwkTabPage* FwkTabWindow::AddTabPage( sal_Int32 nIndex, const uno::Sequence< beans::NamedValue >& rProperties )
diff --git a/framework/source/helper/titlebarupdate.cxx b/framework/source/helper/titlebarupdate.cxx
index 1db613237d..962bbbf0f1 100644
--- a/framework/source/helper/titlebarupdate.cxx
+++ b/framework/source/helper/titlebarupdate.cxx
@@ -371,6 +371,12 @@ void TitleBarUpdate::impl_updateIcon(const css::uno::Reference< css::frame::XFra
{
WorkWindow* pWorkWindow = (WorkWindow*)pWindow;
pWorkWindow->SetIcon( (sal_uInt16)nIcon );
+
+ css::uno::Reference< css::frame::XModel > xModel = xController->getModel();
+ rtl::OUString aURL;
+ if( xModel.is() )
+ aURL = xModel->getURL();
+ pWorkWindow->SetRepresentedURL( aURL );
}
aSolarLock.clear();
diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx
index 660846779e..c8731b0af5 100644
--- a/framework/source/services/autorecovery.cxx
+++ b/framework/source/services/autorecovery.cxx
@@ -170,6 +170,7 @@ static const ::rtl::OUString CMD_DO_RECOVERY = ::rtl::OUString::
static const ::rtl::OUString CMD_DO_ENTRY_BACKUP = ::rtl::OUString::createFromAscii("/doEntryBackup" ); // try to store a temp or original file to a user defined location
static const ::rtl::OUString CMD_DO_ENTRY_CLEANUP = ::rtl::OUString::createFromAscii("/doEntryCleanUp" ); // remove the specified entry from the recovery cache
static const ::rtl::OUString CMD_DO_SESSION_SAVE = ::rtl::OUString::createFromAscii("/doSessionSave" ); // save all open documents if e.g. a window manager closes an user session
+static const ::rtl::OUString CMD_DO_SESSION_QUIET_QUIT = ::rtl::OUString::createFromAscii("/doSessionQuietQuit" ); // let the current session be quietly closed ( the saving should be done using doSessionSave previously ) if e.g. a window manager closes an user session
static const ::rtl::OUString CMD_DO_SESSION_RESTORE = ::rtl::OUString::createFromAscii("/doSessionRestore" ); // restore a saved user session from disc
static const ::rtl::OUString CMD_DO_DISABLE_RECOVERY = ::rtl::OUString::createFromAscii("/disableRecovery" ); // disable recovery and auto save (!) temp. for this office session
static const ::rtl::OUString CMD_DO_SET_AUTOSAVE_STATE = ::rtl::OUString::createFromAscii("/setAutoSaveState" ); // disable/enable auto save (not crash save) for this office session
@@ -725,6 +726,16 @@ void AutoRecovery::implts_dispatch(const DispatchParams& aParams)
}
else
if (
+ ((eJob & AutoRecovery::E_SESSION_QUIET_QUIT ) == AutoRecovery::E_SESSION_QUIET_QUIT ) &&
+ ((eJob & AutoRecovery::E_DISABLE_AUTORECOVERY) != AutoRecovery::E_DISABLE_AUTORECOVERY)
+ )
+ {
+ LOG_RECOVERY("... do session quiet quit ...")
+ bAllowAutoSaveReactivation = sal_False;
+ implts_doSessionQuietQuit(aParams);
+ }
+ else
+ if (
((eJob & AutoRecovery::E_SESSION_RESTORE ) == AutoRecovery::E_SESSION_RESTORE ) &&
((eJob & AutoRecovery::E_DISABLE_AUTORECOVERY) != AutoRecovery::E_DISABLE_AUTORECOVERY)
)
@@ -1987,6 +1998,30 @@ void AutoRecovery::implts_changeAllDocVisibility(sal_Bool bVisible)
}
//-----------------------------------------------
+/* Currently the document is not closed in case of crash,
+ so the lock file must be removed explicitly
+*/
+void lc_removeLockFile(AutoRecovery::TDocumentInfo& rInfo)
+{
+ if ( rInfo.Document.is() )
+ {
+ try
+ {
+ css::uno::Reference< css::frame::XStorable > xStore(rInfo.Document, css::uno::UNO_QUERY_THROW);
+ ::rtl::OUString aURL = xStore->getLocation();
+ if ( aURL.getLength() )
+ {
+ ::svt::DocumentLockFile aLockFile( aURL );
+ aLockFile.RemoveFile();
+ }
+ }
+ catch( const css::uno::Exception& )
+ {}
+ }
+}
+
+
+//-----------------------------------------------
void AutoRecovery::implts_prepareSessionShutdown()
{
LOG_RECOVERY("AutoRecovery::implts_prepareSessionShutdown() starts ...")
@@ -2004,6 +2039,10 @@ void AutoRecovery::implts_prepareSessionShutdown()
{
AutoRecovery::TDocumentInfo& rInfo = *pIt;
+ // WORKAROUND... Since the documents are not closed the lock file must be removed explicitly
+ // it is not done on documents saving since shutdown can be cancelled
+ lc_removeLockFile( rInfo );
+
// Prevent us from deregistration of these documents.
// Because we close these documents by ourself (see XClosable below) ...
// it's fact, that we reach our deregistration method. There we
@@ -2014,31 +2053,38 @@ void AutoRecovery::implts_prepareSessionShutdown()
// reset modified flag of these documents (ignoring the notification about it!)
// Otherwise a message box is shown on closing these models.
implts_stopModifyListeningOnDoc(rInfo);
- css::uno::Reference< css::util::XModifiable > xModify(rInfo.Document, css::uno::UNO_QUERY);
- if (xModify.is())
- xModify->setModified(sal_False);
- // close the model.
- css::uno::Reference< css::util::XCloseable > xClose(rInfo.Document, css::uno::UNO_QUERY);
- if (xClose.is())
+ // if the session save is still running the documents should not be thrown away,
+ // actually that would be a bad sign, that means that the SessionManager tryes
+ // to kill the session before the saving is ready
+ if ((m_eJob & AutoRecovery::E_SESSION_SAVE) != AutoRecovery::E_SESSION_SAVE)
{
- try
+ css::uno::Reference< css::util::XModifiable > xModify(rInfo.Document, css::uno::UNO_QUERY);
+ if (xModify.is())
+ xModify->setModified(sal_False);
+
+ // close the model.
+ css::uno::Reference< css::util::XCloseable > xClose(rInfo.Document, css::uno::UNO_QUERY);
+ if (xClose.is())
{
- xClose->close(sal_False);
- }
- /*
- catch(const css::lang::DisposedException&)
- {
- // closed ... disposed ... always the same .-)
- }
- */
- catch(const css::uno::Exception&)
+ try
{
- // At least it's only a try to close these documents before anybody else it does.
- // So it seams to be possible to ignore any error here .-)
+ xClose->close(sal_False);
}
+ /*
+ catch(const css::lang::DisposedException&)
+ {
+ // closed ... disposed ... always the same .-)
+ }
+ */
+ catch(const css::uno::Exception&)
+ {
+ // At least it's only a try to close these documents before anybody else it does.
+ // So it seams to be possible to ignore any error here .-)
+ }
- rInfo.Document.clear();
+ rInfo.Document.clear();
+ }
}
}
@@ -2047,30 +2093,6 @@ void AutoRecovery::implts_prepareSessionShutdown()
}
//-----------------------------------------------
-/* Currently the document is not closed in case of crash,
- so the lock file must be removed explicitly
-*/
-void lc_removeLockFile(AutoRecovery::TDocumentInfo& rInfo)
-{
- if ( rInfo.Document.is() )
- {
- try
- {
- css::uno::Reference< css::frame::XStorable > xStore(rInfo.Document, css::uno::UNO_QUERY_THROW);
- ::rtl::OUString aURL = xStore->getLocation();
- if ( aURL.getLength() )
- {
- ::svt::DocumentLockFile aLockFile( aURL );
- aLockFile.RemoveFile();
- }
- }
- catch( const css::uno::Exception& )
- {}
- }
-}
-
-
-//-----------------------------------------------
/* TODO WORKAROUND:
#i64599#
@@ -2750,6 +2772,9 @@ void AutoRecovery::implts_informListener( sal_Int32 eJ
if ((eJob & AutoRecovery::E_SESSION_SAVE) == AutoRecovery::E_SESSION_SAVE)
sFeature.append(CMD_DO_SESSION_SAVE);
else
+ if ((eJob & AutoRecovery::E_SESSION_QUIET_QUIT) == AutoRecovery::E_SESSION_QUIET_QUIT)
+ sFeature.append(CMD_DO_SESSION_QUIET_QUIT);
+ else
if ((eJob & AutoRecovery::E_SESSION_RESTORE) == AutoRecovery::E_SESSION_RESTORE)
sFeature.append(CMD_DO_SESSION_RESTORE);
else
@@ -2792,6 +2817,9 @@ sal_Int32 AutoRecovery::implst_classifyJob(const css::util::URL& aURL)
if (aURL.Path.equals(CMD_DO_SESSION_SAVE))
return AutoRecovery::E_SESSION_SAVE;
else
+ if (aURL.Path.equals(CMD_DO_SESSION_QUIET_QUIT))
+ return AutoRecovery::E_SESSION_QUIET_QUIT;
+ else
if (aURL.Path.equals(CMD_DO_SESSION_RESTORE))
return AutoRecovery::E_SESSION_RESTORE;
else
@@ -2968,14 +2996,6 @@ void AutoRecovery::implts_doSessionSave(const DispatchParams& aParams)
{
LOG_RECOVERY("AutoRecovery::implts_doSessionSave()")
- // try to make sure next time office will be started user wont be
- // notified about any other might be running office instance
- // remove ".lock" file from disc !
- // it is done as a first action for session save since Gnome sessions
- // do not provide enough time for shutdown, and the dialog looks to be
- // confusing for the user
- AutoRecovery::st_impl_removeLockFile();
-
// Be sure to know all open documents realy .-)
implts_verifyCacheAgainstDesktopDocumentList();
@@ -2991,7 +3011,8 @@ void AutoRecovery::implts_doSessionSave(const DispatchParams& aParams)
AutoRecovery::ETimerType eSuggestedTimer = AutoRecovery::E_DONT_START_TIMER;
do
{
- eSuggestedTimer = implts_saveDocs(bAllowUserIdleLoop, sal_True, &aParams);
+ // do not remove lock files of the documents, it will be done on session quit
+ eSuggestedTimer = implts_saveDocs(bAllowUserIdleLoop, sal_False, &aParams);
}
while(eSuggestedTimer == AutoRecovery::E_CALL_ME_BACK);
@@ -3002,6 +3023,23 @@ void AutoRecovery::implts_doSessionSave(const DispatchParams& aParams)
// any "handle" state ...
implts_resetHandleStates(sal_False);
+ // flush config cached back to disc.
+ impl_flushALLConfigChanges();
+}
+
+//-----------------------------------------------
+void AutoRecovery::implts_doSessionQuietQuit(const DispatchParams& /*aParams*/)
+{
+ LOG_RECOVERY("AutoRecovery::implts_doSessionQuietQuit()")
+
+ // try to make sure next time office will be started user wont be
+ // notified about any other might be running office instance
+ // remove ".lock" file from disc !
+ // it is done as a first action for session save since Gnome sessions
+ // do not provide enough time for shutdown, and the dialog looks to be
+ // confusing for the user
+ AutoRecovery::st_impl_removeLockFile();
+
// reset all modified documents, so the dont show any UI on closing ...
// and close all documents, so we can shutdown the OS!
implts_prepareSessionShutdown();
@@ -3020,6 +3058,7 @@ void AutoRecovery::implts_doSessionSave(const DispatchParams& aParams)
impl_flushALLConfigChanges();
}
+
//-----------------------------------------------
void AutoRecovery::implts_doSessionRestore(const DispatchParams& aParams)
{
diff --git a/framework/source/services/sessionlistener.cxx b/framework/source/services/sessionlistener.cxx
index 81338c1cdb..eabcfcedf1 100644
--- a/framework/source/services/sessionlistener.cxx
+++ b/framework/source/services/sessionlistener.cxx
@@ -60,6 +60,7 @@
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
#include <com/sun/star/util/XModifiable.hpp>
#include <com/sun/star/util/XChangesBatch.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
@@ -103,12 +104,13 @@ namespace framework{
//***********************************************
// XInterface, XTypeProvider, XServiceInfo
-DEFINE_XINTERFACE_5(
+DEFINE_XINTERFACE_6(
SessionListener,
OWeakObject,
DIRECT_INTERFACE(css::lang::XTypeProvider),
DIRECT_INTERFACE(css::lang::XInitialization),
DIRECT_INTERFACE(css::frame::XSessionManagerListener),
+ DIRECT_INTERFACE(css::frame::XSessionManagerListener2),
DIRECT_INTERFACE(css::frame::XStatusListener),
DIRECT_INTERFACE(css::lang::XServiceInfo))
@@ -116,7 +118,7 @@ DEFINE_XTYPEPROVIDER_5(
SessionListener,
css::lang::XTypeProvider,
css::lang::XInitialization,
- css::frame::XSessionManagerListener,
+ css::frame::XSessionManagerListener2,
css::frame::XStatusListener,
css::lang::XServiceInfo)
@@ -137,8 +139,11 @@ SessionListener::SessionListener(const css::uno::Reference< css::lang::XMultiSer
: ThreadHelpBase (&Application::GetSolarMutex())
, OWeakObject ( )
, m_xSMGR (xSMGR )
- , m_bRestored( false )
-{
+ , m_bRestored( sal_False )
+ , m_bSessionStoreRequested( sal_False )
+ , m_bAllowUserInteractionOnQuit( sal_False )
+ , m_bTerminated( sal_False )
+{
}
SessionListener::~SessionListener()
@@ -150,6 +155,63 @@ SessionListener::~SessionListener()
}
}
+void SessionListener::StoreSession( sal_Bool bAsync )
+{
+ ResetableGuard aGuard(m_aLock);
+ try
+ {
+ // xd create SERVICENAME_AUTORECOVERY -> XDispatch
+ // xd->dispatch("vnd.sun.star.autorecovery:/doSessionSave, async=bAsync
+ // on stop event m_rSessionManager->saveDone(this); in case of asynchronous call
+ // in case of synchronous call the caller should do saveDone() call himself!
+
+ css::uno::Reference< XDispatch > xDispatch(m_xSMGR->createInstance(SERVICENAME_AUTORECOVERY), UNO_QUERY_THROW);
+ css::uno::Reference< XURLTransformer > xURLTransformer(m_xSMGR->createInstance(SERVICENAME_URLTRANSFORMER), UNO_QUERY_THROW);
+ URL aURL;
+ aURL.Complete = OUString::createFromAscii("vnd.sun.star.autorecovery:/doSessionSave");
+ xURLTransformer->parseStrict(aURL);
+
+ // in case of asynchronous call the notification will trigger saveDone()
+ if ( bAsync )
+ xDispatch->addStatusListener(this, aURL);
+
+ Sequence< PropertyValue > args(1);
+ args[0] = PropertyValue(OUString::createFromAscii("DispatchAsynchron"),-1,makeAny(bAsync),PropertyState_DIRECT_VALUE);
+ xDispatch->dispatch(aURL, args);
+ } catch (com::sun::star::uno::Exception& e) {
+ OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8);
+ OSL_ENSURE(sal_False, aMsg.getStr());
+ // save failed, but tell manager to go on if we havent yet dispatched the request
+ // in case of synchronous saving the notification is done by the caller
+ if ( bAsync && m_rSessionManager.is() )
+ m_rSessionManager->saveDone(this);
+ }
+}
+
+void SessionListener::QuitSessionQuietly()
+{
+ ResetableGuard aGuard(m_aLock);
+ try
+ {
+ // xd create SERVICENAME_AUTORECOVERY -> XDispatch
+ // xd->dispatch("vnd.sun.star.autorecovery:/doSessionQuietQuit, async=false
+ // it is done synchronously to avoid conflict with normal quit process
+
+ css::uno::Reference< XDispatch > xDispatch(m_xSMGR->createInstance(SERVICENAME_AUTORECOVERY), UNO_QUERY_THROW);
+ css::uno::Reference< XURLTransformer > xURLTransformer(m_xSMGR->createInstance(SERVICENAME_URLTRANSFORMER), UNO_QUERY_THROW);
+ URL aURL;
+ aURL.Complete = OUString::createFromAscii("vnd.sun.star.autorecovery:/doSessionQuietQuit");
+ xURLTransformer->parseStrict(aURL);
+
+ Sequence< PropertyValue > args(1);
+ args[0] = PropertyValue(OUString::createFromAscii("DispatchAsynchron"),-1,makeAny(sal_False),PropertyState_DIRECT_VALUE);
+ xDispatch->dispatch(aURL, args);
+ } catch (com::sun::star::uno::Exception& e) {
+ OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8);
+ OSL_ENSURE(sal_False, aMsg.getStr());
+ }
+}
+
void SAL_CALL SessionListener::disposing(const com::sun::star::lang::EventObject&) throw (RuntimeException)
{
}
@@ -170,6 +232,8 @@ void SAL_CALL SessionListener::initialize(const Sequence< Any >& args)
v.Value >>= aSMgr;
else if (v.Name.equalsAscii("SessionManager"))
v.Value >>= m_rSessionManager;
+ else if (v.Name.equalsAscii("AllowUserInteractionOnQuit"))
+ v.Value >>= m_bAllowUserInteractionOnQuit;
}
}
}
@@ -235,46 +299,73 @@ void SAL_CALL SessionListener::doSave( sal_Bool bShutdown, sal_Bool /*bCancelabl
{
if (bShutdown)
{
- sal_Bool bDispatched = sal_False;
- ResetableGuard aGuard(m_aLock);
- try
- {
- // xd create SERVICENAME_AUTORECOVERY -> XDispatch
- // xd->dispatch("vnd.sun.star.autorecovery:/doSessionSave, async=true
- // on stop event m_rSessionManager->saveDone(this);
-
- css::uno::Reference< XDispatch > xDispatch(m_xSMGR->createInstance(SERVICENAME_AUTORECOVERY), UNO_QUERY_THROW);
- css::uno::Reference< XURLTransformer > xURLTransformer(m_xSMGR->createInstance(SERVICENAME_URLTRANSFORMER), UNO_QUERY_THROW);
- URL aURL;
- aURL.Complete = OUString::createFromAscii("vnd.sun.star.autorecovery:/doSessionSave");
- xURLTransformer->parseStrict(aURL);
- xDispatch->addStatusListener(this, aURL);
- Sequence< PropertyValue > args(1);
- args[0] = PropertyValue(OUString::createFromAscii("DispatchAsynchron"),-1,makeAny(sal_True),PropertyState_DIRECT_VALUE);
- xDispatch->dispatch(aURL, args);
- bDispatched = sal_True;
- // on stop event set call m_rSessionManager->saveDone(this);
- } catch (com::sun::star::uno::Exception& e) {
- OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8);
- OSL_ENSURE(sal_False, aMsg.getStr());
- // save failed, but tell manager to go on if we havent yet dispatched the request
- if (m_rSessionManager.is() && !bDispatched)
- m_rSessionManager->saveDone(this);
- }
+ m_bSessionStoreRequested = sal_True; // there is no need to protect it with mutex
+ if ( m_bAllowUserInteractionOnQuit && m_rSessionManager.is() )
+ m_rSessionManager->queryInteraction( static_cast< css::frame::XSessionManagerListener* >( this ) );
+ else
+ StoreSession( sal_True );
}
// we don't have anything to do so tell the session manager we're done
else if( m_rSessionManager.is() )
m_rSessionManager->saveDone( this );
}
+void SAL_CALL SessionListener::approveInteraction( sal_Bool bInteractionGranted )
+ throw (RuntimeException)
+{
+ // do AutoSave as the first step
+ ResetableGuard aGuard(m_aLock);
+ if ( bInteractionGranted )
+ {
+ // close the office documents in normal way
+ try
+ {
+ // first of all let the session be stored to be sure that we lose no information
+ StoreSession( sal_False );
-void SAL_CALL SessionListener::approveInteraction( sal_Bool /*bInteractionGranted*/ )
- throw (RuntimeException)
-{}
+ css::uno::Reference< css::frame::XDesktop > xDesktop( m_xSMGR->createInstance(SERVICENAME_DESKTOP), css::uno::UNO_QUERY_THROW);
+ m_bTerminated = xDesktop->terminate();
+
+ if ( m_rSessionManager.is() )
+ {
+ // false means that the application closing has been cancelled
+ if ( !m_bTerminated )
+ m_rSessionManager->cancelShutdown();
+ else
+ m_rSessionManager->interactionDone( this );
+ }
+ }
+ catch( css::uno::Exception& )
+ {
+ StoreSession( sal_True );
+ m_rSessionManager->interactionDone( this );
+ }
+
+ if ( m_rSessionManager.is() )
+ m_rSessionManager->saveDone(this);
+ }
+ else
+ {
+ StoreSession( sal_True );
+ }
+}
void SessionListener::shutdownCanceled()
throw (RuntimeException)
-{}
+{
+ // set the state back
+ m_bSessionStoreRequested = sal_False; // there is no need to protect it with mutex
+}
+
+void SessionListener::doQuit()
+ throw (RuntimeException)
+{
+ if ( m_bSessionStoreRequested && !m_bTerminated )
+ {
+ // let the session be closed quietly in this case
+ QuitSessionQuietly();
+ }
+}
}
diff --git a/framework/source/services/tabwindowservice.cxx b/framework/source/services/tabwindowservice.cxx
index 6c78600aa9..71136a9ac4 100644
--- a/framework/source/services/tabwindowservice.cxx
+++ b/framework/source/services/tabwindowservice.cxx
@@ -75,18 +75,20 @@ namespace framework{
// css::uno::XInterface, XTypeProvider, XServiceInfo
//*****************************************************************************************************************
-DEFINE_XINTERFACE_5 ( TabWindowService ,
+DEFINE_XINTERFACE_6 ( TabWindowService ,
OWeakObject ,
DIRECT_INTERFACE(css::lang::XTypeProvider ),
DIRECT_INTERFACE(css::lang::XServiceInfo ),
+ DIRECT_INTERFACE(css::lang::XComponent),
DIRECT_INTERFACE(css::awt::XSimpleTabController),
DIRECT_INTERFACE(css::beans::XPropertySet ),
DIRECT_INTERFACE(css::beans::XPropertySetInfo )
)
-DEFINE_XTYPEPROVIDER_5 ( TabWindowService ,
+DEFINE_XTYPEPROVIDER_6 ( TabWindowService ,
css::lang::XTypeProvider ,
css::lang::XServiceInfo ,
+ css::lang::XComponent ,
css::awt::XSimpleTabController ,
css::beans::XPropertySet ,
css::beans::XPropertySetInfo
@@ -100,7 +102,7 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( TabWindowService ,
DEFINE_INIT_SERVICE ( TabWindowService,
{
- impl_initializePropInfo();
+ impl_initializePropInfo();
m_aTransactionManager.setWorkingMode( E_WORK );
}
)
@@ -141,7 +143,12 @@ TabWindowService::TabWindowService( const css::uno::Reference< css::lang::XMulti
// destructor
//*****************************************************************************************************************
TabWindowService::~TabWindowService()
-{
+{
+ // SAFE->
+ ResetableGuard aGuard(m_aLock);
+
+ if (m_pTabWin)
+ m_pTabWin->RemoveEventListener( LINK( this, TabWindowService, EventListener ) );
}
//*****************************************************************************************************************
@@ -286,8 +293,11 @@ void SAL_CALL TabWindowService::dispose()
m_lListener.disposeAndClear (aEvent);
+ if (m_pTabWin)
+ m_pTabWin->RemoveEventListener( LINK( this, TabWindowService, EventListener ) );
+
m_pTabWin = NULL;
- m_xTabWin.clear ();
+ m_xTabWin.clear();
}
//*****************************************************************************************************************
@@ -357,6 +367,7 @@ css::uno::Any SAL_CALL TabWindowService::impl_getPropertyValue(const ::rtl::OUSt
//*****************************************************************************************************************
IMPL_LINK( TabWindowService, EventListener, VclSimpleEvent*, pEvent )
{
+
if ( !pEvent && !pEvent->ISA(VclWindowEvent))
return 0;
@@ -369,6 +380,11 @@ IMPL_LINK( TabWindowService, EventListener, VclSimpleEvent*, pEvent )
if (nEventId == VCLEVENT_OBJECT_DYING)
{
m_lListener.disposeAndClear (aEvent);
+
+ m_pTabWin->RemoveEventListener( LINK( this, TabWindowService, EventListener ) );
+ m_pTabWin = NULL;
+ m_xTabWin.clear();
+
return 0;
}
@@ -454,9 +470,9 @@ FwkTabWindow* TabWindowService::mem_TabWin ()
FwkTabWindow* pWin = NULL;
if ( ! m_xTabWin.is ())
- {
- Window* pFakeParent = dynamic_cast< Window* >(Application::GetDefaultDevice ());
-
+ {
+ Window* pFakeParent = dynamic_cast< Window* >(Application::GetDefaultDevice ());
+
m_pTabWin = new FwkTabWindow (pFakeParent);
m_xTabWin = VCLUnoHelper::GetInterface (m_pTabWin);
diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx
index 00339698d9..d56a120c75 100644
--- a/framework/source/uielement/langselectionstatusbarcontroller.cxx
+++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx
@@ -337,7 +337,7 @@ void LangSelectionStatusbarController::LangMenu()throw (::com::sun::star::uno::R
mRectangle.Y = mMousePos.Y();
sal_Int16 nId = xPopupMenu->execute( xParent, mRectangle, com::sun::star::awt::PopupMenuDirection::EXECUTE_UP+16 );
//click "More..."
- if ( m_xFrame.is() )
+ if ( nId && m_xFrame.is() )
{
uno::Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
util::URL aURL;
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 476e7c8837..d9a35ede35 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -341,10 +341,12 @@ void ToolBarManager::Destroy()
delete static_cast< AddonsParams* >( m_pToolBar->GetItemData( nItemId ));
}
+ // Hide toolbar as lazy delete can destroy the toolbar much later.
+ m_pToolBar->Hide();
/* #i99167# removed change for i93173 since there is some weird crash */
// #i93173# delete toolbar lazily as we can still be in one of its handlers
- m_pToolBar->doLazyDelete();
-
+ m_pToolBar->doLazyDelete();
+
Link aEmpty;
m_pToolBar->SetSelectHdl( aEmpty );
m_pToolBar->SetActivateHdl( aEmpty );
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index fa69145371..0dced3ed2f 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -2713,7 +2713,7 @@
</node>
<node oor:name=".uno:ChineseConversion" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
- <value xml:lang="en-US">Chinese translation...</value>
+ <value xml:lang="en-US">Chinese Conversion...</value>
</prop>
</node>
<node oor:name=".uno:InsertListbox" oor:op="replace">
diff --git a/officecfg/registry/schema/org/openoffice/Office/Recovery.xcs b/officecfg/registry/schema/org/openoffice/Office/Recovery.xcs
index 41ceb993f8..b510709bb5 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Recovery.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Recovery.xcs
@@ -81,6 +81,19 @@
<desc>TODO</desc>
</info>
</set>
+ <group oor:name="SessionShutdown">
+ <info>
+ <author>MAV</author>
+ <desc>The session shutdown related information.</desc>
+ </info>
+ <prop oor:name="DocumentStoreUIEnabled" oor:type="xs:boolean">
+ <info>
+ <author>MAV</author>
+ <desc>Determines if the office is allowed to show request to store modified documents on session shutdown.</desc>
+ </info>
+ <value>false</value>
+ </prop>
+ </group>
<group oor:name="RecoveryInfo">
<info>
<desc>TODO</desc>
diff --git a/sfx2/inc/sfx2/dinfdlg.hxx b/sfx2/inc/sfx2/dinfdlg.hxx
index 3fb4174f57..27f7433929 100644
--- a/sfx2/inc/sfx2/dinfdlg.hxx
+++ b/sfx2/inc/sfx2/dinfdlg.hxx
@@ -46,7 +46,7 @@
#include <svtools/headbar.hxx>
#include <unotools/syslocale.hxx>
#include <svl/zforlist.hxx>
-
+#include <com/sun/star/util/Duration.hpp>
#include "tabdlg.hxx"
namespace com { namespace sun { namespace star {
@@ -358,6 +358,55 @@ public:
inline CustomPropertyLine* GetLine() const { return m_pLine; }
};
+class CustomPropertiesDateField : public DateField
+{
+private:
+ CustomPropertyLine* m_pLine;
+
+public:
+ inline CustomPropertiesDateField(
+ Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) :
+ DateField( pParent, rResId ), m_pLine( pLine ) {}
+
+ inline CustomPropertyLine* GetLine() const { return m_pLine; }
+};
+class CustomPropertiesTimeField : public TimeField
+{
+private:
+ CustomPropertyLine* m_pLine;
+
+public:
+ inline CustomPropertiesTimeField(
+ Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) :
+ TimeField( pParent, rResId ), m_pLine( pLine ) {}
+
+ inline CustomPropertyLine* GetLine() const { return m_pLine; }
+};
+class CustomPropertiesDurationField : public Edit
+{
+ CustomPropertyLine* m_pLine;
+ com::sun::star::util::Duration m_aDuration;
+protected:
+ virtual void RequestHelp(const HelpEvent& rEvt);
+public:
+ CustomPropertiesDurationField( Window* pParent, const ResId& rResId, CustomPropertyLine* pLine );
+ ~CustomPropertiesDurationField();
+
+ void SetDuration( const com::sun::star::util::Duration& rDuration );
+ const com::sun::star::util::Duration& GetDuration() const { return m_aDuration; }
+};
+
+class CustomPropertiesEditButton : public PushButton
+{
+ CustomPropertyLine* m_pLine;
+
+public:
+ CustomPropertiesEditButton( Window* pParent, const ResId& rResId, CustomPropertyLine* pLine );
+ ~CustomPropertiesEditButton();
+
+ DECL_LINK(ClickHdl, PushButton*);
+};
+
class CustomPropertiesRemoveButton : public ImageButton
{
private:
@@ -394,9 +443,18 @@ struct CustomPropertyLine
ComboBox m_aNameBox;
CustomPropertiesTypeBox m_aTypeBox;
CustomPropertiesEdit m_aValueEdit;
+ CustomPropertiesDateField m_aDateField;
+ CustomPropertiesTimeField m_aTimeField;
+ const String m_sDurationFormat;
+ CustomPropertiesDurationField m_aDurationField;
+ CustomPropertiesEditButton m_aEditButton;
CustomPropertiesYesNoButton m_aYesNoButton;
CustomPropertiesRemoveButton m_aRemoveButton;
+ Point m_aDatePos;
+ Point m_aTimePos;
+ Size m_aDateTimeSize;
+
bool m_bIsRemoved;
bool m_bTypeLostFocus;
@@ -413,6 +471,10 @@ private:
ComboBox m_aNameBox;
ListBox m_aTypeBox;
Edit m_aValueEdit;
+ DateField m_aDateField;
+ TimeField m_aTimeField;
+ Edit m_aDurationField;
+ PushButton m_aEditButton;
CustomPropertiesYesNoButton m_aYesNoButton;
ImageButton m_aRemoveButton;
@@ -430,6 +492,8 @@ private:
DECL_LINK( RemoveHdl, CustomPropertiesRemoveButton* );
DECL_LINK( EditLoseFocusHdl, CustomPropertiesEdit* );
DECL_LINK( BoxLoseFocusHdl, CustomPropertiesTypeBox* );
+ //add lose focus handlers of Date/TimeField?
+
DECL_LINK( EditTimeoutHdl, Timer* );
DECL_LINK( BoxTimeoutHdl, Timer* );
diff --git a/sfx2/inc/sfx2/docfile.hxx b/sfx2/inc/sfx2/docfile.hxx
index 38fba3e5b8..36a9caba89 100644
--- a/sfx2/inc/sfx2/docfile.hxx
+++ b/sfx2/inc/sfx2/docfile.hxx
@@ -229,7 +229,7 @@ public:
sal_Int8 ShowLockedDocumentDialog( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading, sal_Bool bOwnLock );
sal_Bool LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI );
- void UnlockFile();
+ void UnlockFile( sal_Bool bReleaseLockStream );
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetStorage( sal_Bool bCreateTempIfNo = sal_True );
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetOutputStorage();
@@ -290,6 +290,7 @@ public:
SAL_DLLPRIVATE void Init_Impl();
SAL_DLLPRIVATE void ForceSynchronStream_Impl( sal_Bool bSynchron );
+ SAL_DLLPRIVATE void GetLockingStream_Impl();
SAL_DLLPRIVATE void GetMedium_Impl();
SAL_DLLPRIVATE sal_Bool TryDirectTransfer( const ::rtl::OUString& aURL, SfxItemSet& aTargetSet );
SAL_DLLPRIVATE void Transfer_Impl();
diff --git a/sfx2/qa/complex/DocumentMetaData.java b/sfx2/qa/complex/DocumentMetaData.java
index 8a4c1a91bd..c08531a697 100644
--- a/sfx2/qa/complex/DocumentMetaData.java
+++ b/sfx2/qa/complex/DocumentMetaData.java
@@ -41,8 +41,10 @@ import com.sun.star.lang.XSingleServiceFactory;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.lang.Locale;
import com.sun.star.lang.EventObject;
-import com.sun.star.util.Time;
+import com.sun.star.util.Date;
import com.sun.star.util.DateTime;
+import com.sun.star.util.Time;
+import com.sun.star.util.Duration;
import com.sun.star.util.XModifyListener;
import com.sun.star.util.XModifyBroadcaster;
import com.sun.star.beans.XPropertyContainer;
@@ -351,14 +353,30 @@ public class DocumentMetaData extends ComplexTestCase
// differently some day...
boolean b = true;
double d = 3.1415;
+ // note that Time is only supported for backward compatibilty!
Time t = new Time();
t.Hours = 1;
t.Minutes = 16;
+ Date date = new Date();
+ date.Year = 2071;
+ date.Month = 2;
+ date.Day = 3;
dt.Year = 2065;
+ Duration dur = new Duration();
+ dur.Negative = true;
+ dur.Years = 1001;
+ dur.Months = 999;
+ dur.Days = 888;
+ dur.Hours = 777;
+ dur.Minutes = 666;
+ dur.Seconds = 555;
+ dur.HundredthSeconds = 444;
udpc.addProperty("Frobnicate", PropertyAttribute.REMOVEABLE,
new Boolean(b));
- udpc.addProperty("FrobDuration", PropertyAttribute.REMOVEABLE, t);
+ udpc.addProperty("FrobDuration", PropertyAttribute.REMOVEABLE, dur);
+ udpc.addProperty("FrobDuration2", PropertyAttribute.REMOVEABLE, t);
+ udpc.addProperty("FrobEndDate", PropertyAttribute.REMOVEABLE, date);
udpc.addProperty("FrobStartTime", PropertyAttribute.REMOVEABLE, dt);
udpc.addProperty("Pi", PropertyAttribute.REMOVEABLE, new Double(d));
udpc.addProperty("Foo", PropertyAttribute.REMOVEABLE, "bar");
@@ -383,9 +401,13 @@ public class DocumentMetaData extends ComplexTestCase
assure ("UserDefined bool", new Boolean(b).equals(
udps.getPropertyValue("Frobnicate")));
- assure ("UserDefined time", eqTime(t, (Time)
+ assure ("UserDefined duration", eqDuration(dur, (Duration)
udps.getPropertyValue("FrobDuration")));
- assure ("UserDefined date", eqDateTime(dt, (DateTime)
+ assure ("UserDefined time", eqTime(t, (Time)
+ udps.getPropertyValue("FrobDuration2")));
+ assure ("UserDefined date", eqDate(date, (Date)
+ udps.getPropertyValue("FrobEndDate")));
+ assure ("UserDefined datetime", eqDateTime(dt, (DateTime)
udps.getPropertyValue("FrobStartTime")));
assure ("UserDefined float", new Double(d).equals(
udps.getPropertyValue("Pi")));
@@ -423,9 +445,13 @@ public class DocumentMetaData extends ComplexTestCase
assure ("UserDefined bool", new Boolean(b).equals(
udps.getPropertyValue("Frobnicate")));
- assure ("UserDefined time", eqTime(t, (Time)
+ assure ("UserDefined duration", eqDuration(dur, (Duration)
udps.getPropertyValue("FrobDuration")));
- assure ("UserDefined date", eqDateTime(dt, (DateTime)
+ assure ("UserDefined time", eqTime(t, (Time)
+ udps.getPropertyValue("FrobDuration2")));
+ assure ("UserDefined date", eqDate(date, (Date)
+ udps.getPropertyValue("FrobEndDate")));
+ assure ("UserDefined datetime", eqDateTime(dt, (DateTime)
udps.getPropertyValue("FrobStartTime")));
assure ("UserDefined float", new Double(d).equals(
udps.getPropertyValue("Pi")));
@@ -474,12 +500,24 @@ public class DocumentMetaData extends ComplexTestCase
&& a.HundredthSeconds == b.HundredthSeconds;
}
+ boolean eqDate(Date a, Date b) {
+ return a.Year == b.Year && a.Month == b.Month && a.Day == b.Day;
+ }
+
boolean eqTime(Time a, Time b) {
return a.Hours == b.Hours && a.Minutes == b.Minutes
&& a.Seconds == b.Seconds
&& a.HundredthSeconds == b.HundredthSeconds;
}
+ boolean eqDuration(Duration a, Duration b) {
+ return a.Years == b.Years && a.Months == b.Months && a.Days == b.Days
+ && a.Hours == b.Hours && a.Minutes == b.Minutes
+ && a.Seconds == b.Seconds
+ && a.HundredthSeconds == b.HundredthSeconds
+ && a.Negative == b.Negative;
+ }
+
java.util.Collection fromArray(Object[] os) {
java.util.Collection ret = new java.util.HashSet();
for (int i = 0; i < os.length; ++i) {
diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx
index 693af2d0c0..985af75b1f 100644
--- a/sfx2/source/appl/shutdownicon.cxx
+++ b/sfx2/source/appl/shutdownicon.cxx
@@ -69,6 +69,7 @@
#include <unistd.h>
#include <errno.h>
#endif
+#include <vcl/timer.hxx>
#include "sfxresid.hxx"
@@ -186,6 +187,23 @@ bool ShutdownIcon::LoadModule( osl::Module **pModule,
return true;
}
+class IdleUnloader : Timer
+{
+ ::osl::Module *m_pModule;
+public:
+ IdleUnloader (::osl::Module **pModule) :
+ m_pModule (*pModule)
+ {
+ *pModule = NULL;
+ Start();
+ }
+ virtual void Timeout()
+ {
+ delete m_pModule;
+ delete this;
+ }
+};
+
void ShutdownIcon::initSystray()
{
if (m_bInitialized)
@@ -201,15 +219,15 @@ void ShutdownIcon::deInitSystray()
{
if (!m_bInitialized)
return;
+
if (m_pDeInitSystray)
m_pDeInitSystray();
m_bVeto = false;
m_pInitSystray = 0;
m_pDeInitSystray = 0;
- if (m_pPlugin)
- delete m_pPlugin;
- m_pPlugin = 0;
+ new IdleUnloader (&m_pPlugin);
+
delete m_pFileDlg;
m_pFileDlg = NULL;
m_bInitialized = false;
@@ -233,6 +251,7 @@ ShutdownIcon::ShutdownIcon( Reference< XMultiServiceFactory > aSMgr ) :
ShutdownIcon::~ShutdownIcon()
{
deInitSystray();
+ new IdleUnloader (&m_pPlugin);
}
// ---------------------------------------------------------------------------
@@ -853,9 +872,11 @@ void ShutdownIcon::SetAutostart( bool bActivate )
::osl::File::getFileURLFromSystemPath( aShortcut, aShortcutUrl );
::osl::File::remove( aShortcutUrl );
#ifdef UNX
- ShutdownIcon *pIcon = getInstance();
- if( pIcon )
+ if (pShutdownIcon)
+ {
+ ShutdownIcon *pIcon = getInstance();
pIcon->deInitSystray();
+ }
#endif
}
#elif defined OS2
diff --git a/sfx2/source/control/makefile.mk b/sfx2/source/control/makefile.mk
index 6de7b1e59a..a64cd08cd3 100644
--- a/sfx2/source/control/makefile.mk
+++ b/sfx2/source/control/makefile.mk
@@ -1,7 +1,7 @@
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
+#
# Copyright 2008 by Sun Microsystems, Inc.
#
# OpenOffice.org - a multi-platform office productivity suite
@@ -47,6 +47,10 @@ CFLAGS+=-Od
.ENDIF
.ENDIF
+.IF "$(COM)"=="GCC"
+CFLAGS+=-O0
+.ENDIF
+
# --- Files --------------------------------------------------------
SLOFILES = \
diff --git a/sfx2/source/dialog/dialog.hrc b/sfx2/source/dialog/dialog.hrc
index e41fbc0746..1d0e4c9066 100644
--- a/sfx2/source/dialog/dialog.hrc
+++ b/sfx2/source/dialog/dialog.hrc
@@ -109,6 +109,8 @@
#define STR_PDF_EXPORT_SEND ( RC_DIALOG_BEGIN + 120 )
#define STR_RECHECK_DOCUMENT ( RC_DIALOG_BEGIN + 121 )
#define IMG_INFO ( RC_DIALOG_BEGIN + 122 )
+#define RID_EDIT_DURATIONS ( RC_DIALOG_BEGIN + 123 )
+#define SFX_PB_EDIT ( RC_DIALOG_BEGIN + 124 )
#endif // #ifndef _SFX_DIALOG_HRC
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 9e6d974e3a..e5b555d977 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -54,7 +54,10 @@
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/beans/XPropertyContainer.hpp>
+#include <com/sun/star/util/DateTime.hpp>
#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/Duration.hpp>
#include <com/sun/star/document/XDocumentProperties.hpp>
#include <vcl/timer.hxx>
@@ -73,6 +76,8 @@
#include <sfx2/sfx.hrc>
#include "dinfdlg.hrc"
#include "sfxlocal.hrc"
+#include <dialog.hrc>
+#include <vcl/help.hxx>
#include <algorithm>
@@ -1577,7 +1582,168 @@ CustomPropertiesYesNoButton::CustomPropertiesYesNoButton( Window* pParent, const
m_aYesButton.SetBackground( aWall );
m_aNoButton.SetBackground( aWall );
}
+class DurationDialog_Impl : public ModalDialog
+{
+ FixedLine aDurationFL;
+
+ OKButton aOKPB;
+ CancelButton aCancelPB;
+ HelpButton aHelpPB;
+
+ CheckBox aNegativeCB;
+ FixedText aYearFT;
+ NumericField aYearNF;
+ FixedText aMonthFT;
+ NumericField aMonthNF;
+ FixedText aDayFT;
+ NumericField aDayNF;
+ FixedText aHourFT;
+ NumericField aHourNF;
+ FixedText aMinuteFT;
+ NumericField aMinuteNF;
+ FixedText aSecondFT;
+ NumericField aSecondNF;
+ FixedText aHSecondFT;
+ NumericField aHSecondNF;
+
+public:
+
+ DurationDialog_Impl( Window* pParent, const util::Duration& rDuration );
+ ~DurationDialog_Impl();
+
+ util::Duration GetDuration() const;
+};
+/*-- 20.11.2009 15:40:46---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+DurationDialog_Impl::DurationDialog_Impl( Window* pParent, const util::Duration& rDuration ) :
+ ModalDialog( pParent, SfxResId( RID_EDIT_DURATIONS ) ),
+ aDurationFL(this, SfxResId( FL_DURATION )),
+ aOKPB( this, SfxResId( PB_OK )),
+ aCancelPB( this, SfxResId( PB_CANCEL )),
+ aHelpPB( this, SfxResId( PB_HELP )),
+ aNegativeCB(this, SfxResId( CB_NEGATIVE )),
+ aYearFT( this, SfxResId( FT_YEAR )),
+ aYearNF( this, SfxResId( ED_YEAR )),
+ aMonthFT( this, SfxResId( FT_MONTH )),
+ aMonthNF( this, SfxResId( ED_MONTH )),
+ aDayFT( this, SfxResId( FT_DAY )),
+ aDayNF( this, SfxResId( ED_DAY )),
+ aHourFT( this, SfxResId( FT_HOUR )),
+ aHourNF( this, SfxResId( ED_HOUR )),
+ aMinuteFT( this, SfxResId( FT_MINUTE )),
+ aMinuteNF( this, SfxResId( ED_MINUTE )),
+ aSecondFT( this, SfxResId( FT_SECOND )),
+ aSecondNF( this, SfxResId( ED_SECOND )),
+ aHSecondFT( this, SfxResId( FT_HSECOND )),
+ aHSecondNF( this, SfxResId( ED_HSECOND ))
+{
+ FreeResource();
+ aNegativeCB.Check(rDuration.Negative);
+ aYearNF.SetValue(rDuration.Years);
+ aMonthNF.SetValue(rDuration.Months );
+ aDayNF.SetValue(rDuration.Days );
+ aHourNF.SetValue(rDuration.Hours );
+ aMinuteNF.SetValue(rDuration.Minutes);
+ aSecondNF.SetValue(rDuration.Seconds);
+ aHSecondNF.SetValue(rDuration.HundredthSeconds);
+}
+/*-- 20.11.2009 16:08:55---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+DurationDialog_Impl::~DurationDialog_Impl()
+{
+}
+/*-- 20.11.2009 15:41:47---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+util::Duration DurationDialog_Impl::GetDuration() const
+{
+ util::Duration aRet;
+ aRet.Negative = aNegativeCB.IsChecked();
+ aRet.Years = aYearNF.GetValue();
+ aRet.Months = aMonthNF.GetValue( );
+ aRet.Days = aDayNF.GetValue( );
+ aRet.Hours = aHourNF.GetValue( );
+ aRet.Minutes = aMinuteNF.GetValue();
+ aRet.Seconds = aSecondNF.GetValue();
+ aRet.HundredthSeconds = aHSecondNF.GetValue();
+ return aRet;
+}
+
+/*-- 20.11.2009 15:30:58---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+CustomPropertiesDurationField::CustomPropertiesDurationField( Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) :
+ Edit( pParent, rResId ), m_pLine( pLine )
+
+{
+ SetDuration( util::Duration(false, 0, 0, 0, 0, 0, 0, 0) );
+}
+/*-- 23.11.2009 08:46:02---------------------------------------------------
+ -----------------------------------------------------------------------*/
+CustomPropertiesDurationField::~CustomPropertiesDurationField()
+{
+}
+/*-- 23.11.2009 09:23:35---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void CustomPropertiesDurationField::RequestHelp( const HelpEvent& rHEvt )
+{
+ if( rHEvt.GetMode() & HELPMODE_QUICK )
+ {
+ Size aSize( GetSizePixel() );
+ Rectangle aItemRect( rHEvt.GetMousePosPixel(), aSize );
+ if(Help::IsBalloonHelpEnabled())
+ Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), GetText() );
+ else
+ Help::ShowQuickHelp( this, aItemRect, GetText(),
+ QUICKHELP_LEFT|QUICKHELP_VCENTER );
+ }
+}
+/*-- 20.11.2009 15:30:58---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void CustomPropertiesDurationField::SetDuration( const util::Duration& rDuration )
+{
+ m_aDuration = rDuration;
+ String sText(rDuration.Negative ? '-' : '+');
+ sText += m_pLine->m_sDurationFormat;
+ sText.SearchAndReplace(String::CreateFromAscii( "%1"), String::CreateFromInt32( rDuration.Years ) );
+ sText.SearchAndReplace(String::CreateFromAscii( "%2"), String::CreateFromInt32( rDuration.Months ) );
+ sText.SearchAndReplace(String::CreateFromAscii( "%3"), String::CreateFromInt32( rDuration.Days ) );
+ sText.SearchAndReplace(String::CreateFromAscii( "%4"), String::CreateFromInt32( rDuration.Hours ) );
+ sText.SearchAndReplace(String::CreateFromAscii( "%5"), String::CreateFromInt32( rDuration.Minutes) );
+ sText.SearchAndReplace(String::CreateFromAscii( "%6"), String::CreateFromInt32( rDuration.Seconds) );
+ SetText( sText );
+}
+/*-- 23.11.2009 08:51:15---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+CustomPropertiesEditButton::CustomPropertiesEditButton( Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) :
+ PushButton( pParent, rResId ), m_pLine( pLine )
+{
+ SetClickHdl( LINK( this, CustomPropertiesEditButton, ClickHdl ));
+}
+/*-- 23.11.2009 08:51:15---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+CustomPropertiesEditButton::~CustomPropertiesEditButton()
+{
+}
+/*-- 23.11.2009 08:47:37---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+IMPL_LINK( CustomPropertiesEditButton, ClickHdl, PushButton*, EMPTYARG )
+{
+ DurationDialog_Impl* pDurationDlg = new DurationDialog_Impl( this, m_pLine->m_aDurationField.GetDuration() );
+ if( RET_OK == pDurationDlg->Execute() )
+ m_pLine->m_aDurationField.SetDuration( pDurationDlg->GetDuration() );
+ delete pDurationDlg;
+ return 1;
+}
+//--------------------------------------------------------------------------
void CustomPropertiesYesNoButton::Resize()
{
const long nWidth = GetSizePixel().Width();
@@ -1598,12 +1764,20 @@ CustomPropertyLine::CustomPropertyLine( Window* pParent ) :
m_aNameBox ( pParent, SfxResId( SFX_CB_PROPERTY_NAME ) ),
m_aTypeBox ( pParent, SfxResId( SFX_LB_PROPERTY_TYPE ), this ),
m_aValueEdit ( pParent, SfxResId( SFX_ED_PROPERTY_VALUE ), this ),
+ m_aDateField ( pParent, SfxResId( SFX_FLD_DATE), this),
+ m_aTimeField ( pParent, SfxResId( SFX_FLD_TIME), this),
+ m_sDurationFormat( SfxResId( SFX_ST_DURATION_FORMAT )),
+ m_aDurationField( pParent, SfxResId( SFX_FLD_DURATION), this),
+ m_aEditButton( pParent, SfxResId( SFX_PB_EDIT ), this),
m_aYesNoButton ( pParent, SfxResId( SFX_WIN_PROPERTY_YESNO ) ),
m_aRemoveButton ( pParent, SfxResId( SFX_PB_PROPERTY_REMOVE ), this ),
m_bIsRemoved ( false ),
m_bTypeLostFocus( false )
{
+ m_aTimeField.SetExtFormat( EXTTIMEF_24H_LONG );
+ m_aDateField.SetExtDateFormat( XTDATEF_SYSTEM_SHORT_YYYY );
+
m_aRemoveButton.SetModeImage( SfxResId( SFX_IMG_PROPERTY_REMOVE ), BMP_COLOR_NORMAL );
m_aRemoveButton.SetModeImage( SfxResId( SFX_IMG_PROPERTY_REMOVE_HC ), BMP_COLOR_HIGHCONTRAST );
}
@@ -1615,6 +1789,10 @@ void CustomPropertyLine::SetRemoved()
m_aNameBox.Hide();
m_aTypeBox.Hide();
m_aValueEdit.Hide();
+ m_aDateField.Hide();
+ m_aTimeField.Hide();
+ m_aDurationField.Hide();
+ m_aEditButton.Hide();
m_aYesNoButton.Hide();
m_aRemoveButton.Hide();
}
@@ -1627,6 +1805,10 @@ CustomPropertiesWindow::CustomPropertiesWindow( Window* pParent, const ResId& rR
m_aNameBox ( this, SfxResId( SFX_CB_PROPERTY_NAME ) ),
m_aTypeBox ( this, SfxResId( SFX_LB_PROPERTY_TYPE ) ),
m_aValueEdit ( this, SfxResId( SFX_ED_PROPERTY_VALUE ) ),
+ m_aDateField ( this, SfxResId( SFX_FLD_DATE) ),
+ m_aTimeField ( this, SfxResId( SFX_FLD_TIME) ),
+ m_aDurationField( this, SfxResId( SFX_FLD_DURATION) ),
+ m_aEditButton( this, SfxResId( SFX_PB_EDIT )),
m_aYesNoButton ( this, SfxResId( SFX_WIN_PROPERTY_YESNO ) ),
m_aRemoveButton ( this, SfxResId( SFX_PB_PROPERTY_REMOVE ) ),
m_nScrollPos (0),
@@ -1651,9 +1833,23 @@ IMPL_LINK( CustomPropertiesWindow, TypeHdl, CustomPropertiesTypeBox*, pBox )
{
sal_Int64 nType = sal_Int64( (long)pBox->GetEntryData( pBox->GetSelectEntryPos() ) );
CustomPropertyLine* pLine = pBox->GetLine();
- BOOL bBooleanType = ( CUSTOM_TYPE_BOOLEAN == nType );
- pLine->m_aValueEdit.Show( !bBooleanType );
- pLine->m_aYesNoButton.Show( bBooleanType );
+ pLine->m_aValueEdit.Show( (CUSTOM_TYPE_TEXT == nType) || (CUSTOM_TYPE_NUMBER == nType) );
+ pLine->m_aDateField.Show( (CUSTOM_TYPE_DATE == nType) || (CUSTOM_TYPE_DATETIME == nType) );
+ pLine->m_aTimeField.Show( CUSTOM_TYPE_DATETIME == nType );
+ pLine->m_aDurationField.Show( CUSTOM_TYPE_DURATION == nType );
+ pLine->m_aEditButton.Show( CUSTOM_TYPE_DURATION == nType );
+ pLine->m_aYesNoButton.Show( CUSTOM_TYPE_BOOLEAN == nType );
+ //adjust positions of date and time controls
+ if( nType == CUSTOM_TYPE_DATE )
+ {
+ pLine->m_aDateField.SetPosSizePixel(pLine->m_aValueEdit.GetPosPixel(), pLine->m_aValueEdit.GetSizePixel());
+ }
+ else if( nType == CUSTOM_TYPE_DATETIME)
+ {
+ pLine->m_aDateField.SetPosSizePixel( pLine->m_aDatePos, pLine->m_aDateTimeSize );
+ pLine->m_aTimeField.SetPosSizePixel(pLine->m_aTimePos, pLine->m_aDateTimeSize );
+ }
+
return 0;
}
@@ -1675,6 +1871,8 @@ IMPL_LINK( CustomPropertiesWindow, RemoveHdl, CustomPropertiesRemoveButton*, pBu
continue;
Window* pWindows[] = { &pLine->m_aNameBox, &pLine->m_aTypeBox, &pLine->m_aValueEdit,
+ &pLine->m_aDateField, &pLine->m_aTimeField,
+ &pLine->m_aDurationField, &pLine->m_aEditButton,
&pLine->m_aYesNoButton, &pLine->m_aRemoveButton, NULL };
Window** pCurrent = pWindows;
while ( *pCurrent )
@@ -1784,6 +1982,10 @@ void CustomPropertiesWindow::InitControls( HeaderBar* pHeaderBar, const ScrollBa
m_aNameBox.Hide();
m_aTypeBox.Hide();
m_aValueEdit.Hide();
+ m_aDateField.Hide();
+ m_aTimeField.Hide();
+ m_aDurationField.Hide();
+ m_aEditButton.Hide();
m_aYesNoButton.Hide();
m_aRemoveButton.Hide();
@@ -1815,11 +2017,23 @@ void CustomPropertiesWindow::InitControls( HeaderBar* pHeaderBar, const ScrollBa
if ( *pCurrent == &m_aValueEdit )
{
+ Point aDurationPos( aPos );
+ m_aDurationField.SetPosPixel( aDurationPos );
+ Size aDurationSize(aSize);
+ aDurationSize.Width() -= (m_aEditButton.GetSizePixel().Width() + 3 );
+ m_aDurationField.SetSizePixel(aDurationSize);
+ aDurationPos.X() = aPos.X() - m_aEditButton.GetSizePixel().Width() + aSize.Width();
+ m_aEditButton.SetPosPixel(aDurationPos);
aSize = m_aYesNoButton.GetSizePixel();
aPos = m_aYesNoButton.GetPosPixel();
aSize.Width() = nWidth;
aPos.X() = aRect.getX() + ( nOffset / 2 );
m_aYesNoButton.SetPosSizePixel( aPos, aSize );
+ aSize.Width() /= 2;
+ aSize.Width() -= 2;
+ m_aDateField.SetPosSizePixel( aPos, aSize );
+ aPos.X() += aSize.Width() + 4;
+ m_aTimeField.SetPosSizePixel( aPos, aSize );
}
pCurrent++;
@@ -1849,13 +2063,19 @@ void CustomPropertiesWindow::AddLine( const ::rtl::OUString& sName, Any& rAny )
pNewLine->m_aTypeBox.SetSelectHdl( LINK( this, CustomPropertiesWindow, TypeHdl ) );
pNewLine->m_aRemoveButton.SetClickHdl( LINK( this, CustomPropertiesWindow, RemoveHdl ) );
pNewLine->m_aValueEdit.SetLoseFocusHdl( LINK( this, CustomPropertiesWindow, EditLoseFocusHdl ) );
+ //add lose focus handlers of date/time fields
+
pNewLine->m_aTypeBox.SetLoseFocusHdl( LINK( this, CustomPropertiesWindow, BoxLoseFocusHdl ) );
long nPos = GetVisibleLineCount() * GetLineHeight();
m_aCustomPropertiesLines.push_back( pNewLine );
Window* pWindows[] = { &m_aNameBox, &m_aTypeBox, &m_aValueEdit,
+ &m_aDateField, &m_aTimeField,
+ &m_aDurationField, &m_aEditButton,
&m_aYesNoButton, &m_aRemoveButton, NULL };
Window* pNewWindows[] =
{ &pNewLine->m_aNameBox, &pNewLine->m_aTypeBox, &pNewLine->m_aValueEdit,
+ &pNewLine->m_aDateField, &pNewLine->m_aTimeField,
+ &pNewLine->m_aDurationField, &pNewLine->m_aEditButton,
&pNewLine->m_aYesNoButton, &pNewLine->m_aRemoveButton, NULL };
Window** pCurrent = pWindows;
Window** pNewCurrent = pNewWindows;
@@ -1870,11 +2090,17 @@ void CustomPropertiesWindow::AddLine( const ::rtl::OUString& sName, Any& rAny )
pCurrent++;
pNewCurrent++;
}
+ //
+ pNewLine->m_aDatePos = pNewLine->m_aDateField.GetPosPixel();
+ pNewLine->m_aTimePos = pNewLine->m_aTimeField.GetPosPixel();
+ pNewLine->m_aDateTimeSize = pNewLine->m_aDateField.GetSizePixel();
double nTmpValue = 0;
bool bTmpValue = false;
::rtl::OUString sTmpValue;
- util::DateTime aTmpDate;
+ util::DateTime aTmpDateTime;
+ util::Date aTmpDate;
+ util::Duration aTmpDuration;
SvtSysLocale aSysLocale;
const LocaleDataWrapper& rLocaleWrapper = aSysLocale.GetLocaleData();
pNewLine->m_aNameBox.SetText( sName );
@@ -1885,6 +2111,7 @@ void CustomPropertiesWindow::AddLine( const ::rtl::OUString& sName, Any& rAny )
{
sal_uInt32 nIndex = m_aNumberFormatter.GetFormatIndex( NF_NUMBER_SYSTEM );
m_aNumberFormatter.GetInputLineString( nTmpValue, nIndex, sValue );
+ pNewLine->m_aValueEdit.SetText( sValue );
nType = CUSTOM_TYPE_NUMBER;
}
else if ( rAny >>= bTmpValue )
@@ -1894,50 +2121,26 @@ void CustomPropertiesWindow::AddLine( const ::rtl::OUString& sName, Any& rAny )
}
else if ( rAny >>= sTmpValue )
{
- sValue = String( sTmpValue );
+ pNewLine->m_aValueEdit.SetText( sTmpValue );
nType = CUSTOM_TYPE_TEXT;
}
else if ( rAny >>= aTmpDate )
{
- DateFormat eFormat = rLocaleWrapper.getDateFormat();
- sal_Unicode cDateSep = rLocaleWrapper.getDateSep().GetChar(0);
- switch ( eFormat )
- {
- case MDY :
- {
- sValue = String::CreateFromInt32( aTmpDate.Month );
- sValue += cDateSep;
- sValue += String::CreateFromInt32( aTmpDate.Day );
- sValue += cDateSep;
- if ( aTmpDate.Year < 10 )
- sValue += '0';
- sValue += String::CreateFromInt32( aTmpDate.Year );
- break;
- }
- case DMY :
- {
- sValue = String::CreateFromInt32( aTmpDate.Day );
- sValue += cDateSep;
- sValue += String::CreateFromInt32( aTmpDate.Month );
- sValue += cDateSep;
- if ( aTmpDate.Year < 10 )
- sValue += '0';
- sValue += String::CreateFromInt32( aTmpDate.Year );
- break;
- }
- case YMD :
- {
- if ( aTmpDate.Year < 10 )
- sValue += '0';
- sValue += String::CreateFromInt32( aTmpDate.Year );
- sValue += cDateSep;
- sValue += String::CreateFromInt32( aTmpDate.Month );
- sValue += cDateSep;
- sValue += String::CreateFromInt32( aTmpDate.Day );
- break;
- }
- }
nType = CUSTOM_TYPE_DATE;
+ pNewLine->m_aDateField.SetDate( Date( aTmpDate.Day, aTmpDate.Month, aTmpDate.Year ) );
+
+ }
+ else if ( rAny >>= aTmpDuration )
+ {
+ nType = CUSTOM_TYPE_DURATION;
+ pNewLine->m_aDurationField.SetDuration( aTmpDuration );
+ }
+ else if ( rAny >>= aTmpDateTime )
+ {
+ pNewLine->m_aDateField.SetDate( Date( aTmpDateTime.Day, aTmpDateTime.Month, aTmpDateTime.Year ) );
+ pNewLine->m_aTimeField.SetTime( Time( aTmpDateTime.Hours, aTmpDateTime.Minutes, aTmpDateTime.Seconds, aTmpDateTime.HundredthSeconds ) );
+
+ nType = CUSTOM_TYPE_DATETIME;
}
if ( nType != CUSTOM_TYPE_UNKNOWN )
@@ -1949,8 +2152,6 @@ void CustomPropertiesWindow::AddLine( const ::rtl::OUString& sName, Any& rAny )
else
pNewLine->m_aYesNoButton.CheckNo();
}
- else
- pNewLine->m_aValueEdit.SetText( sValue );
pNewLine->m_aTypeBox.SelectEntryPos( m_aTypeBox.GetEntryPos( (void*)nType ) );
}
@@ -2001,7 +2202,7 @@ void CustomPropertiesWindow::DoScroll( sal_Int32 nNewPos )
if ( pLine->m_bIsRemoved )
continue;
- Window* pWindows[] = { &pLine->m_aNameBox, &pLine->m_aTypeBox, &pLine->m_aValueEdit,
+ Window* pWindows[] = { &pLine->m_aNameBox, &pLine->m_aTypeBox, &pLine->m_aValueEdit, &pLine->m_aDurationField,
&pLine->m_aYesNoButton, &pLine->m_aRemoveButton, NULL };
Window** pCurrent = pWindows;
while ( *pCurrent )
@@ -2065,52 +2266,24 @@ Sequence< beans::PropertyValue > CustomPropertiesWindow::GetCustomProperties() c
bool bValue = pLine->m_aYesNoButton.IsYesChecked();
aPropertiesSeq[i].Value <<= makeAny( bValue );
}
+ else if ( CUSTOM_TYPE_DATETIME == nType )
+ {
+ Date aTmpDate = pLine->m_aDateField.GetDate();
+ Time aTmpTime = pLine->m_aTimeField.GetTime();
+ util::DateTime aDateTime(aTmpTime.Get100Sec(), aTmpTime.GetSec(), aTmpTime.GetMin(), aTmpTime.GetHour(),
+ aTmpDate.GetDay(), aTmpDate.GetMonth(), aTmpDate.GetYear() );
+ aPropertiesSeq[i].Value <<= aDateTime;
+ }
+ else if ( CUSTOM_TYPE_DURATION == nType )
+ {
+ aPropertiesSeq[i].Value <<= pLine->m_aDurationField.GetDuration();
+ }
else if ( CUSTOM_TYPE_DATE == nType )
{
- const LocaleDataWrapper& rLocaleWrapper = SvtSysLocale().GetLocaleData();
- DateFormat eFormat = rLocaleWrapper.getDateFormat();
- sal_Unicode cDateSep = rLocaleWrapper.getDateSep().GetChar(0);
- String sValue( pLine->m_aValueEdit.GetText() );
- if ( sValue.GetTokenCount( cDateSep ) == 3 )
- {
- xub_StrLen nTokenDay = STRING_NOTFOUND;
- xub_StrLen nTokenMonth = STRING_NOTFOUND;
- xub_StrLen nTokenYear = STRING_NOTFOUND;
-
- switch ( eFormat )
- {
- case MDY :
- {
- nTokenDay = 1;
- nTokenMonth = 0;
- nTokenYear = 2;
- break;
- }
- case DMY :
- {
- nTokenDay = 0;
- nTokenMonth = 1;
- nTokenYear = 2;
- break;
- }
- case YMD :
- {
- nTokenDay = 2;
- nTokenMonth = 1;
- nTokenYear = 0;
- break;
- }
- }
-
- if ( nTokenDay != STRING_NOTFOUND )
- {
- util::DateTime aDateTime( 0, 0, 0, 0,
- sal_uInt16( sValue.GetToken( nTokenDay, cDateSep ).ToInt32() ),
- sal_uInt16( sValue.GetToken( nTokenMonth, cDateSep ).ToInt32() ),
- sal_uInt16( sValue.GetToken( nTokenYear, cDateSep ).ToInt32() ) );
- aPropertiesSeq[i].Value <<= makeAny( aDateTime );
- }
- }
+ Date aTmpDate = pLine->m_aDateField.GetDate();
+ util::Date aDate(aTmpDate.GetDay(), aTmpDate.GetMonth(), aTmpDate.GetYear());
+ aPropertiesSeq[i].Value <<= aDate;
+
}
else
{
diff --git a/sfx2/source/dialog/dinfdlg.hrc b/sfx2/source/dialog/dinfdlg.hrc
index ba2b30ecc3..6f3be56b59 100644
--- a/sfx2/source/dialog/dinfdlg.hrc
+++ b/sfx2/source/dialog/dinfdlg.hrc
@@ -39,6 +39,8 @@
#define CUSTOM_TYPE_NUMBER 2
#define CUSTOM_TYPE_DATE 3
#define CUSTOM_TYPE_BOOLEAN 4
+#define CUSTOM_TYPE_DURATION 5
+#define CUSTOM_TYPE_DATETIME 6
// 4 TP_DOCINFORELOAD
#define PAGE_WIDTH 260
@@ -154,5 +156,25 @@
#define STR_HEADER_VALUE 92
#define STR_HEADER_ACTION 93
+#define PB_OK 100
+#define PB_CANCEL 101
+#define PB_HELP 102
+#define CB_NEGATIVE 103
+#define FT_YEAR 104
+#define ED_YEAR 105
+#define FT_MONTH 106
+#define ED_MONTH 107
+#define FT_DAY 108
+#define ED_DAY 109
+#define FT_HOUR 110
+#define ED_HOUR 111
+#define FT_MINUTE 112
+#define ED_MINUTE 113
+#define FT_SECOND 114
+#define ED_SECOND 115
+#define FT_HSECOND 116
+#define ED_HSECOND 117
+#define FL_DURATION 118
+
#endif
diff --git a/sfx2/source/dialog/dinfdlg.src b/sfx2/source/dialog/dinfdlg.src
index d5c57d56ab..429124b9bf 100644
--- a/sfx2/source/dialog/dinfdlg.src
+++ b/sfx2/source/dialog/dinfdlg.src
@@ -34,6 +34,7 @@
#include "helpid.hrc"
#include "sfxlocal.hrc"
#include "dinfdlg.hrc"
+#include <dialog.hrc>
// TP_DOCINFODESC --------------------------------------------------------
String STR_SFX_NEWOFFICEDOC
@@ -579,14 +580,16 @@ ComboBox SFX_CB_PROPERTY_NAME
ListBox SFX_LB_PROPERTY_TYPE
{
Pos = MAP_APPFONT ( 63 , 2 ) ;
- Size = MAP_APPFONT ( 60 , 50 ) ;
+ Size = MAP_APPFONT ( 60 , 80 ) ;
DropDown = TRUE;
Border = TRUE;
CurPos = 0;
StringList [ en-US ] =
{
< "Text" ; CUSTOM_TYPE_TEXT ; > ;
+ < "DateTime" ; CUSTOM_TYPE_DATETIME ; > ;
< "Date" ; CUSTOM_TYPE_DATE ; > ;
+ < "Duration" ; CUSTOM_TYPE_DURATION ; > ;
< "Number" ; CUSTOM_TYPE_NUMBER ; > ;
< "Yes or no" ; CUSTOM_TYPE_BOOLEAN ; > ;
};
@@ -599,6 +602,44 @@ Edit SFX_ED_PROPERTY_VALUE
TabStop = TRUE ;
Left = TRUE ;
};
+DateField SFX_FLD_DATE
+{
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 127 , 2 ) ;
+ Size = MAP_APPFONT ( 29 , RSC_CD_TEXTBOX_HEIGHT ) ;
+ TabStop = TRUE ;
+ Left = TRUE ;
+ Spin = TRUE;
+};
+TimeField SFX_FLD_TIME
+{
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 159 , 2 ) ;
+ Size = MAP_APPFONT ( 29 , RSC_CD_TEXTBOX_HEIGHT ) ;
+ TabStop = TRUE ;
+ Left = TRUE ;
+ Spin = TRUE;
+};
+
+Edit SFX_FLD_DURATION
+{
+ Readonly = TRUE;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 159 , 2 ) ;
+ Size = MAP_APPFONT ( 61 - RSC_CD_TEXTBOX_HEIGHT - 2, RSC_CD_TEXTBOX_HEIGHT ) ;
+ TabStop = TRUE ;
+};
+PushButton SFX_PB_EDIT
+{
+ Pos = MAP_APPFONT ( 159 , 2 ) ;
+ Size = MAP_APPFONT ( RSC_CD_TEXTBOX_HEIGHT , RSC_CD_TEXTBOX_HEIGHT ) ;
+ Text = "...";
+};
+String SFX_ST_DURATION_FORMAT
+{
+ Text [en-US] = " Y: %1 M: %2 D: %3 H: %4 M: %5 S: %6";
+};
+
Control SFX_WIN_PROPERTY_YESNO
{
HelpId = HID_CTRL_CUSTOMPROPS_YES_NO;
@@ -684,3 +725,182 @@ TabDialog SID_DOCINFO
};
};
+ModalDialog RID_EDIT_DURATIONS
+{
+ HelpId = HID_DLG_CUSTOMPROPS_DURATION;
+ OutputSize = TRUE ;
+ Size = MAP_APPFONT ( 176 , 140 ) ;
+ Text [ en-US ] = "Edit Duration" ;
+ Moveable = TRUE ;
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 120 , 7 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 120 , 24 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 120 , 48 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ FixedLine FL_DURATION
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 108 , 8 ) ;
+ Text [ en-US ] = "Duration" ;
+ };
+ CheckBox CB_NEGATIVE
+ {
+ Pos = MAP_APPFONT ( 6 , 21 ) ;
+ Size = MAP_APPFONT ( 60 , RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "~Negative" ;
+ };
+ FixedText FT_YEAR
+ {
+ Pos = MAP_APPFONT ( 6 , 38 ) ;
+ Size = MAP_APPFONT ( 60 , RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "~Years" ;
+ };
+ NumericField ED_YEAR
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 36 ) ;
+ Size = MAP_APPFONT ( 40, RSC_CD_TEXTBOX_HEIGHT ) ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 0 ;
+ First = 1 ;
+ Last = 100 ;
+ SpinSize = 1 ;
+ Value = 0 ;
+ };
+ FixedText FT_MONTH
+ {
+ Pos = MAP_APPFONT ( 6 , 52 ) ;
+ Size = MAP_APPFONT ( 60 , RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "~Months" ;
+ };
+ NumericField ED_MONTH
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 50 ) ;
+ Size = MAP_APPFONT ( 40, RSC_CD_TEXTBOX_HEIGHT ) ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 0 ;
+ First = 1 ;
+ Last = 100 ;
+ SpinSize = 1 ;
+ Value = 0 ;
+ };
+ FixedText FT_DAY
+ {
+ Pos = MAP_APPFONT ( 6 , 66 ) ;
+ Size = MAP_APPFONT ( 60 , RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "~Days" ;
+ };
+ NumericField ED_DAY
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 64 ) ;
+ Size = MAP_APPFONT ( 40, RSC_CD_TEXTBOX_HEIGHT ) ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 0 ;
+ First = 1 ;
+ Last = 100 ;
+ SpinSize = 1 ;
+ Value = 0 ;
+ };
+ FixedText FT_HOUR
+ {
+ Pos = MAP_APPFONT ( 6 , 80 ) ;
+ Size = MAP_APPFONT ( 60 , RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "H~ours" ;
+ };
+ NumericField ED_HOUR
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 78 ) ;
+ Size = MAP_APPFONT ( 40, RSC_CD_TEXTBOX_HEIGHT ) ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 0 ;
+ First = 1 ;
+ Last = 100 ;
+ SpinSize = 1 ;
+ Value = 0 ;
+ };
+ FixedText FT_MINUTE
+ {
+ Pos = MAP_APPFONT ( 6 , 94 ) ;
+ Size = MAP_APPFONT ( 60 , RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "Min~utes" ;
+ };
+ NumericField ED_MINUTE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 70, 92) ;
+ Size = MAP_APPFONT ( 40, RSC_CD_TEXTBOX_HEIGHT ) ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 0 ;
+ First = 1 ;
+ Last = 100 ;
+ SpinSize = 1 ;
+ Value = 0 ;
+ };
+ FixedText FT_SECOND
+ {
+ Pos = MAP_APPFONT ( 6, 108 ) ;
+ Size = MAP_APPFONT ( 60 , RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "~Seconds" ;
+ };
+ NumericField ED_SECOND
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 106 ) ;
+ Size = MAP_APPFONT ( 40, RSC_CD_TEXTBOX_HEIGHT ) ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 0 ;
+ First = 1 ;
+ Last = 100 ;
+ SpinSize = 1 ;
+ Value = 0 ;
+ };
+ FixedText FT_HSECOND
+ {
+ Pos = MAP_APPFONT ( 6 , 122 ) ;
+ Size = MAP_APPFONT ( 60 , RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "1/100 se~conds" ;
+ };
+ NumericField ED_HSECOND
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 120 ) ;
+ Size = MAP_APPFONT ( 40, RSC_CD_TEXTBOX_HEIGHT ) ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 0 ;
+ First = 1 ;
+ Last = 100 ;
+ SpinSize = 1 ;
+ Value = 0 ;
+ };
+
+
+
+};
diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx
index c30cbd4dbc..b3e446a34c 100644
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -66,6 +66,7 @@
#include "com/sun/star/xml/xpath/XXPathAPI.hpp"
#include "com/sun/star/util/Date.hpp"
#include "com/sun/star/util/Time.hpp"
+#include "com/sun/star/util/Duration.hpp"
#include "SfxDocumentMetaData.hxx"
#include "rtl/ustrbuf.hxx"
@@ -469,6 +470,11 @@ const char* s_nsODFMeta = "urn:oasis:names:tc:opendocument:xmlns:meta:1.0";
const char* s_metaXml = "meta.xml";
+bool isValidDate(const css::util::Date & i_rDate)
+{
+ return i_rDate.Month > 0;
+}
+
bool isValidDateTime(const css::util::DateTime & i_rDateTime)
{
return i_rDateTime.Month > 0;
@@ -500,16 +506,25 @@ getQualifier(const char* i_name) {
return ::rtl::OUString::createFromAscii(ns);
}
+bool SAL_CALL
+textToDateOrDateTime(css::util::Date & io_rd, css::util::DateTime & io_rdt,
+ bool & o_rIsDateTime, ::rtl::OUString i_text) throw ()
+{
+ if (::sax::Converter::convertDateOrDateTime(
+ io_rd, io_rdt, o_rIsDateTime, i_text)) {
+ return true;
+ } else {
+ DBG_WARNING1("SfxDocumentMetaData: invalid date: %s",
+ OUStringToOString(i_text, RTL_TEXTENCODING_UTF8).getStr());
+ return false;
+ }
+}
+
// convert string to date/time
bool SAL_CALL
textToDateTime(css::util::DateTime & io_rdt, ::rtl::OUString i_text) throw ()
{
if (::sax::Converter::convertDateTime(io_rdt, i_text)) {
- // NB: there may be rounding errors; handle these here
- if (io_rdt.HundredthSeconds > 0) {
- io_rdt.Seconds++;
- io_rdt.HundredthSeconds = 0;
- }
return true;
} else {
DBG_WARNING1("SfxDocumentMetaData: invalid date: %s",
@@ -528,6 +543,20 @@ textToDateTimeDefault(::rtl::OUString i_text) throw ()
return dt;
}
+// convert date to string
+::rtl::OUString SAL_CALL
+dateToText(css::util::Date const& i_rd) throw ()
+{
+ if (isValidDate(i_rd)) {
+ ::rtl::OUStringBuffer buf;
+ ::sax::Converter::convertDate(buf, i_rd);
+ return buf.makeStringAndClear();
+ } else {
+ return ::rtl::OUString();
+ }
+}
+
+
// convert date/time to string
::rtl::OUString SAL_CALL
dateTimeToText(css::util::DateTime const& i_rdt) throw ()
@@ -542,60 +571,48 @@ dateTimeToText(css::util::DateTime const& i_rdt) throw ()
}
// convert string to duration
-bool SAL_CALL
-textToDuration(css::util::Time& io_rut, ::rtl::OUString i_text) throw ()
+bool
+textToDuration(css::util::Duration& io_rDur, ::rtl::OUString const& i_rText)
+throw ()
{
- css::util::DateTime dt;
- if (::sax::Converter::convertTime(dt, i_text)) {
- // NB: there may be rounding errors; handle these here
- if (dt.HundredthSeconds > 0) {
- dt.Seconds++;
- dt.HundredthSeconds = 0;
- }
- io_rut.Hours = dt.Hours;
- io_rut.Minutes = dt.Minutes;
- io_rut.Seconds = dt.Seconds;
- io_rut.HundredthSeconds = dt.HundredthSeconds;
+ if (::sax::Converter::convertDuration(io_rDur, i_rText)) {
return true;
} else {
DBG_WARNING1("SfxDocumentMetaData: invalid duration: %s",
- OUStringToOString(i_text, RTL_TEXTENCODING_UTF8).getStr());
+ OUStringToOString(i_rText, RTL_TEXTENCODING_UTF8).getStr());
return false;
}
}
-sal_Int32 SAL_CALL textToDuration(::rtl::OUString i_text) throw ()
+sal_Int32 textToDuration(::rtl::OUString const& i_rText) throw ()
{
- css::util::Time t;
- if (textToDuration(t, i_text)) {
- return t.Hours * 3600 + t.Minutes * 60 + t.Seconds;
+ css::util::Duration d;
+ if (textToDuration(d, i_rText)) {
+ return (d.Days * (24*3600))
+ + (d.Hours * 3600) + (d.Minutes * 60) + d.Seconds;
} else {
return 0; // default
}
}
// convert duration to string
-::rtl::OUString SAL_CALL durationToText(css::util::Time const& i_rut) throw ()
+::rtl::OUString durationToText(css::util::Duration const& i_rDur) throw ()
{
- css::util::DateTime dt;
- dt.Hours = i_rut.Hours;
- dt.Minutes = i_rut.Minutes;
- dt.Seconds = i_rut.Seconds;
- dt.HundredthSeconds = i_rut.HundredthSeconds;
::rtl::OUStringBuffer buf;
- ::sax::Converter::convertTime(buf, dt);
+ ::sax::Converter::convertDuration(buf, i_rDur);
return buf.makeStringAndClear();
}
// convert duration to string
::rtl::OUString SAL_CALL durationToText(sal_Int32 i_value) throw ()
{
- css::util::Time ut;
- ut.Hours = static_cast<sal_Int16>(i_value / 3600);
- ut.Minutes = static_cast<sal_Int16>((i_value % 3600) / 60);
- ut.Seconds = static_cast<sal_Int16>(i_value % 60);
- ut.HundredthSeconds = 0;
- return durationToText(ut);
+ css::util::Duration ud;
+ ud.Days = static_cast<sal_Int16>(i_value / (24 * 3600));
+ ud.Hours = static_cast<sal_Int16>((i_value % (24 * 3600)) / 3600);
+ ud.Minutes = static_cast<sal_Int16>((i_value % 3600) / 60);
+ ud.Seconds = static_cast<sal_Int16>(i_value % 60);
+ ud.HundredthSeconds = 0;
+ return durationToText(ud);
}
// extract base URL (necessary for converting relative links)
@@ -922,17 +939,26 @@ propsToStrings(css::uno::Reference<css::beans::XPropertySet> const & i_xPropSet)
} else if (type == ::cppu::UnoType<css::util::Date>::get()) {
css::util::Date d;
any >>= d;
- css::util::DateTime dt;
- dt.Year = d.Year;
- dt.Month = d.Month;
- dt.Day = d.Day;
- values.push_back(dateTimeToText(dt));
+ values.push_back(dateToText(d));
as.push_back(std::make_pair(vt,
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("date"))));
} else if (type == ::cppu::UnoType<css::util::Time>::get()) {
+ // #i97029#: replaced by Duration
+ // Time is supported for backward compatibility with OOo 3.x, x<=2
css::util::Time ut;
any >>= ut;
- values.push_back(durationToText(ut));
+ css::util::Duration ud;
+ ud.Hours = ut.Hours;
+ ud.Minutes = ut.Minutes;
+ ud.Seconds = ut.Seconds;
+ ud.HundredthSeconds = ut.HundredthSeconds;
+ values.push_back(durationToText(ud));
+ as.push_back(std::make_pair(vt,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time"))));
+ } else if (type == ::cppu::UnoType<css::util::Duration>::get()) {
+ css::util::Duration ud;
+ any >>= ud;
+ values.push_back(durationToText(ud));
as.push_back(std::make_pair(vt,
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time"))));
} else if (::cppu::UnoType<double>::get().isAssignableFrom(type)) {
@@ -1250,18 +1276,24 @@ void SAL_CALL SfxDocumentMetaData::init(
continue;
}
} else if (type.equalsAscii("date")) {
+ bool isDateTime;
+ css::util::Date d;
css::util::DateTime dt;
- if (textToDateTime(dt, text)) {
- any <<= dt;
+ if (textToDateOrDateTime(d, dt, isDateTime, text)) {
+ if (isDateTime) {
+ any <<= dt;
+ } else {
+ any <<= d;
+ }
} else {
DBG_WARNING1("SfxDocumentMetaData: invalid date: %s",
OUStringToOString(text, RTL_TEXTENCODING_UTF8).getStr());
continue;
}
} else if (type.equalsAscii("time")) {
- css::util::Time ut;
- if (textToDuration(ut, text)) {
- any <<= ut;
+ css::util::Duration ud;
+ if (textToDuration(ud, text)) {
+ any <<= ud;
} else {
DBG_WARNING1("SfxDocumentMetaData: invalid time: %s",
OUStringToOString(text, RTL_TEXTENCODING_UTF8).getStr());
@@ -2251,17 +2283,19 @@ void SfxDocumentMetaData::createUserDefined()
// values of allowed types
if ( !m_xUserDefined.is() )
{
- css::uno::Sequence<css::uno::Type> types(10);
+ css::uno::Sequence<css::uno::Type> types(11);
types[0] = ::cppu::UnoType<bool>::get();
types[1] = ::cppu::UnoType< ::rtl::OUString>::get();
types[2] = ::cppu::UnoType<css::util::DateTime>::get();
types[3] = ::cppu::UnoType<css::util::Date>::get();
- types[4] = ::cppu::UnoType<css::util::Time>::get();
+ types[4] = ::cppu::UnoType<css::util::Duration>::get();
types[5] = ::cppu::UnoType<float>::get();
types[6] = ::cppu::UnoType<double>::get();
types[7] = ::cppu::UnoType<sal_Int16>::get();
types[8] = ::cppu::UnoType<sal_Int32>::get();
types[9] = ::cppu::UnoType<sal_Int64>::get();
+ // Time is supported for backward compatibility with OOo 3.x, x<=2
+ types[10] = ::cppu::UnoType<css::util::Time>::get();
css::uno::Sequence<css::uno::Any> args(2);
args[0] <<= css::beans::NamedValue(
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllowedTypes")),
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 493675771e..7ec181492c 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -383,6 +383,8 @@ public:
Reference < XInputStream > xInputStream;
Reference < XStream > xStream;
+ uno::Reference< io::XStream > m_xLockingStream;
+
sal_uInt32 nLastStorageError;
::rtl::OUString aCharset;
@@ -590,11 +592,14 @@ sal_Bool SfxMedium::DocNeedsFileDateCheck()
//------------------------------------------------------------------
util::DateTime SfxMedium::GetInitFileDate( sal_Bool bIgnoreOldValue )
{
- if ( ( bIgnoreOldValue || !pImp->m_bGotDateTime ) && GetContent().is() )
+ if ( ( bIgnoreOldValue || !pImp->m_bGotDateTime ) && aLogicName.Len() )
{
try
{
- pImp->aContent.getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "DateModified" )) ) >>= pImp->m_aDateTime;
+ uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > xDummyEnv;
+ ::ucbhelper::Content aContent( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv );
+
+ aContent.getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "DateModified" )) ) >>= pImp->m_aDateTime;
pImp->m_bGotDateTime = sal_True;
}
catch ( ::com::sun::star::uno::Exception& )
@@ -1111,6 +1116,13 @@ sal_Bool SfxMedium::LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI )
// otherwise the document should be opened readonly
// if user cancel the loading the ERROR_ABORT is set
+ if ( pImp->m_bLocked && bLoading && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) )
+ {
+ // if the document is already locked the system locking might be temporarely off after storing
+ // check whether the system file locking should be taken again
+ GetLockingStream_Impl();
+ }
+
sal_Bool bResult = pImp->m_bLocked;
if ( !bResult )
@@ -1122,21 +1134,18 @@ sal_Bool SfxMedium::LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI )
if ( !bResult && !IsReadOnly() )
{
- // check whether the file is readonly in fs
- // the check is only necessary if
- // do it only for loading, some contents still might have problems with this property, let them not affect the saving
sal_Bool bContentReadonly = sal_False;
- if ( bLoading && ::utl::LocalFileHelper::IsLocalFile( aLogicName ) )
+ if ( bLoading && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) )
{
- // let the stream be opened to check the possibility to open it for editing
- GetMedium_Impl();
+ // let the original document be opened to check the possibility to open it for editing
+ // and to let the writable stream stay open to hold the lock on the document
+ GetLockingStream_Impl();
}
// "IsReadOnly" property does not allow to detect whether the file is readonly always
// so we try always to open the file for editing
// the file is readonly only in case the read-write stream can not be opened
- SFX_ITEMSET_ARG( pSet, pWriteStreamItem, SfxUnoAnyItem, SID_STREAM, sal_False);
- if ( bLoading && !pWriteStreamItem )
+ if ( bLoading && !pImp->m_xLockingStream.is() )
{
try
{
@@ -2267,6 +2276,45 @@ void SfxMedium::ClearBackup_Impl()
}
//----------------------------------------------------------------
+void SfxMedium::GetLockingStream_Impl()
+{
+ if ( ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) )
+ && !pImp->m_xLockingStream.is() )
+ {
+ SFX_ITEMSET_ARG( pSet, pWriteStreamItem, SfxUnoAnyItem, SID_STREAM, sal_False);
+ if ( pWriteStreamItem )
+ pWriteStreamItem->GetValue() >>= pImp->m_xLockingStream;
+
+ if ( !pImp->m_xLockingStream.is() )
+ {
+ // open the original document
+ uno::Sequence< beans::PropertyValue > xProps;
+ TransformItems( SID_OPENDOC, *GetItemSet(), xProps );
+ comphelper::MediaDescriptor aMedium( xProps );
+
+ aMedium.addInputStreamOwnLock();
+
+ uno::Reference< io::XInputStream > xInputStream;
+ aMedium[comphelper::MediaDescriptor::PROP_STREAM()] >>= pImp->m_xLockingStream;
+ aMedium[comphelper::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream;
+
+ if ( !pImp->pTempFile && !aName.Len() )
+ {
+ // the medium is still based on the original file, it makes sence to initialize the streams
+ if ( pImp->m_xLockingStream.is() )
+ pImp->xStream = pImp->m_xLockingStream;
+
+ if ( xInputStream.is() )
+ pImp->xInputStream = xInputStream;
+
+ if ( !pImp->xInputStream.is() && pImp->xStream.is() )
+ pImp->xInputStream = pImp->xStream->getInputStream();
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------
void SfxMedium::GetMedium_Impl()
{
if ( !pInStream )
@@ -2332,27 +2380,36 @@ void SfxMedium::GetMedium_Impl()
TransformItems( SID_OPENDOC, *GetItemSet(), xProps );
comphelper::MediaDescriptor aMedium( xProps );
- if ( bFromTempFile )
- {
- aMedium[comphelper::MediaDescriptor::PROP_URL()] <<= ::rtl::OUString( aFileName );
- aMedium.erase( comphelper::MediaDescriptor::PROP_READONLY() );
- aMedium.addInputStream();
- }
- else if ( ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) )
+ if ( pImp->m_xLockingStream.is() && !bFromTempFile )
{
- // use the special locking approach only for file URLs
- aMedium.addInputStreamOwnLock();
+ // the medium is not based on the temporary file, so the original stream can be used
+ pImp->xStream = pImp->m_xLockingStream;
}
else
- aMedium.addInputStream();
+ {
+ if ( bFromTempFile )
+ {
+ aMedium[comphelper::MediaDescriptor::PROP_URL()] <<= ::rtl::OUString( aFileName );
+ aMedium.erase( comphelper::MediaDescriptor::PROP_READONLY() );
+ aMedium.addInputStream();
+ }
+ else if ( ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) )
+ {
+ // use the special locking approach only for file URLs
+ aMedium.addInputStreamOwnLock();
+ }
+ else
+ aMedium.addInputStream();
+
+ // the ReadOnly property set in aMedium is ignored
+ // the check is done in LockOrigFileOnDemand() for file and non-file URLs
- // the ReadOnly property set in aMedium is ignored
- // the check is done in LockOrigFileOnDemand() for file and non-file URLs
+ //TODO/MBA: what happens if property is not there?!
+ aMedium[comphelper::MediaDescriptor::PROP_STREAM()] >>= pImp->xStream;
+ aMedium[comphelper::MediaDescriptor::PROP_INPUTSTREAM()] >>= pImp->xInputStream;
+ }
- //TODO/MBA: what happens if property is not there?!
GetContent();
- aMedium[comphelper::MediaDescriptor::PROP_STREAM()] >>= pImp->xStream;
- aMedium[comphelper::MediaDescriptor::PROP_INPUTSTREAM()] >>= pImp->xInputStream;
if ( !pImp->xInputStream.is() && pImp->xStream.is() )
pImp->xInputStream = pImp->xStream->getInputStream();
}
@@ -2661,7 +2718,7 @@ void SfxMedium::Close()
CloseStreams_Impl();
- UnlockFile();
+ UnlockFile( sal_False );
}
void SfxMedium::CloseAndRelease()
@@ -2694,11 +2751,31 @@ void SfxMedium::CloseAndRelease()
CloseAndReleaseStreams_Impl();
- UnlockFile();
+ UnlockFile( sal_True );
}
-void SfxMedium::UnlockFile()
+void SfxMedium::UnlockFile( sal_Bool bReleaseLockStream )
{
+ if ( pImp->m_xLockingStream.is() )
+ {
+ if ( bReleaseLockStream )
+ {
+ try
+ {
+ uno::Reference< io::XInputStream > xInStream = pImp->m_xLockingStream->getInputStream();
+ uno::Reference< io::XOutputStream > xOutStream = pImp->m_xLockingStream->getOutputStream();
+ if ( xInStream.is() )
+ xInStream->closeInput();
+ if ( xOutStream.is() )
+ xOutStream->closeOutput();
+ }
+ catch( uno::Exception& )
+ {}
+ }
+
+ pImp->m_xLockingStream = uno::Reference< io::XStream >();
+ }
+
if ( pImp->m_bLocked )
{
try
@@ -2720,8 +2797,14 @@ void SfxMedium::CloseAndReleaseStreams_Impl()
uno::Reference< io::XInputStream > xInToClose = pImp->xInputStream;
uno::Reference< io::XOutputStream > xOutToClose;
if ( pImp->xStream.is() )
+ {
xOutToClose = pImp->xStream->getOutputStream();
+ // if the locking stream is closed here the related member should be cleaned
+ if ( pImp->xStream == pImp->m_xLockingStream )
+ pImp->m_xLockingStream = uno::Reference< io::XStream >();
+ }
+
// The probably exsisting SvStream wrappers should be closed first
CloseStreams_Impl();
@@ -3433,13 +3516,14 @@ void SfxMedium::CreateTempFile( sal_Bool bReplace )
if ( !( nStorOpenMode & STREAM_TRUNC ) )
{
+ sal_Bool bTransferSuccess = sal_False;
+
if ( GetContent().is()
&& ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) )
&& ::utl::UCBContentHelper::IsDocument( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) )
{
// if there is already such a document, we should copy it
// if it is a file system use OS copy process
- sal_Bool bTransferSuccess = sal_False;
try
{
uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > xComEnv;
@@ -3460,16 +3544,14 @@ void SfxMedium::CreateTempFile( sal_Bool bReplace )
catch( uno::Exception& )
{}
- if ( !bTransferSuccess )
+ if ( bTransferSuccess )
{
- SetError( ERRCODE_IO_CANTWRITE, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
- return;
+ CloseOutStream();
+ CloseInStream();
}
-
- CloseOutStream();
- CloseInStream();
}
- else if ( pInStream )
+
+ if ( !bTransferSuccess && pInStream )
{
// the case when there is no URL-access available or this is a remote protocoll
// but there is an input stream
@@ -3489,13 +3571,25 @@ void SfxMedium::CreateTempFile( sal_Bool bReplace )
pOutStream->Write( pBuf, nRead );
}
+ bTransferSuccess = sal_True;
delete[] pBuf;
CloseInStream();
}
CloseOutStream_Impl();
}
else
+ {
+ // Quite strange design, but currently it is expected that in this case no transfer happens
+ // TODO/LATER: get rid of this inconsistent part of the call design
+ bTransferSuccess = sal_True;
CloseInStream();
+ }
+
+ if ( !bTransferSuccess )
+ {
+ SetError( ERRCODE_IO_CANTWRITE, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+ return;
+ }
}
CloseStorage();
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index e5657fd29b..b0a7b23855 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -2538,12 +2538,20 @@ void SfxObjectShell::StoreLog()
if ( pImp->m_xLogRing.is() )
{
- ::rtl::OUString aFileURL =
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "${$BRAND_BASE_DIR/program/bootstrap.ini:UserInstallation}" ) );
+#ifdef WNT
+ ::rtl::OUString aFileURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "${$BRAND_BASE_DIR/program/bootstrap.ini:UserInstallation}" ) );
+#else
+ ::rtl::OUString aFileURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "${$BRAND_BASE_DIR/program/bootstraprc:UserInstallation}" ) );
+#endif
+
::rtl::Bootstrap::expandMacros( aFileURL );
- ::rtl::OUString aBuildID =
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "${$BRAND_BASE_DIR/program/setup.ini:buildid}" ) );
+#ifdef WNT
+ ::rtl::OUString aBuildID = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "${$BRAND_BASE_DIR/program/setup.ini:buildid}" ) );
+#else
+ ::rtl::OUString aBuildID = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "${$BRAND_BASE_DIR/program/setuprc:buildid}" ) );
+#endif
+
::rtl::Bootstrap::expandMacros( aBuildID );
if ( aFileURL.getLength() )
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 8f9da20970..98afd75354 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -1871,7 +1871,19 @@ sal_Bool SfxObjectShell::DisconnectStorage_Impl( SfxMedium& rSrcMedium, SfxMediu
{
uno::Reference< embed::XOptimizedStorage > xOptStorage( xStorage, uno::UNO_QUERY_THROW );
::rtl::OUString aBackupURL = rTargetMedium.GetBackup_Impl();
- if ( aBackupURL.getLength() )
+ if ( !aBackupURL.getLength() )
+ {
+ // the backup could not be created, try to disconnect the storage and close the source SfxMedium
+ // in this case the optimization is not possible, connect storage to a temporary file
+ rTargetMedium.ResetError();
+ xOptStorage->writeAndAttachToStream( uno::Reference< io::XStream >() );
+ rSrcMedium.CanDisposeStorage_Impl( sal_False );
+ rSrcMedium.Close();
+
+ // now try to create the backup
+ rTargetMedium.GetBackup_Impl();
+ }
+ else
{
// the following call will only compare stream sizes
// TODO/LATER: this is a very risky part, since if the URL contents are different from the storage
diff --git a/sfx2/source/doc/sfxacldetect.cxx b/sfx2/source/doc/sfxacldetect.cxx
index 94370e9a1c..45d0dc9a77 100755
--- a/sfx2/source/doc/sfxacldetect.cxx
+++ b/sfx2/source/doc/sfxacldetect.cxx
@@ -1,108 +1,108 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: shutdowniconw32.cxx,v $
- * $Revision: 1.48 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifdef WNT
-
-// necessary to include system headers without warnings
-#ifdef _MSC_VER
-#pragma warning(disable:4668 4917)
-#endif
-
-#include <windows.h>
-#include <lmaccess.h>
-#include <sal/types.h>
-
-sal_Bool IsReadonlyAccordingACL( const sal_Unicode* pFilePath )
-{
- sal_Bool bResult = sal_False;
-
- sal_uInt32 nFDSize = 0;
- GetFileSecurityW( pFilePath, DACL_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|OWNER_SECURITY_INFORMATION, NULL, 0, &nFDSize );
- if ( nFDSize )
- {
- PSECURITY_DESCRIPTOR pFileDescr = reinterpret_cast< PSECURITY_DESCRIPTOR >( malloc( nFDSize ) );
- if ( GetFileSecurityW( pFilePath, DACL_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|OWNER_SECURITY_INFORMATION, pFileDescr, nFDSize, &nFDSize ) )
- {
- HANDLE hToken = NULL;
- if ( OpenThreadToken( GetCurrentThread(), TOKEN_DUPLICATE|TOKEN_QUERY, TRUE, &hToken )
- || OpenProcessToken( GetCurrentProcess(), TOKEN_DUPLICATE|TOKEN_QUERY, &hToken) )
- {
- HANDLE hImpersonationToken = NULL;
- if ( DuplicateToken( hToken, SecurityImpersonation, &hImpersonationToken) )
- {
- sal_uInt32 nDesiredAccess = ACCESS_WRITE;
- GENERIC_MAPPING aGenericMapping = { ACCESS_READ, ACCESS_WRITE, 0, ACCESS_READ | ACCESS_WRITE };
- MapGenericMask( &nDesiredAccess, &aGenericMapping );
-
- PRIVILEGE_SET aPrivilegeSet;
- sal_uInt32 nPrivilegeSetSize = sizeof( PRIVILEGE_SET );
-
- sal_uInt32 nGrantedAccess;
- BOOL bAccessible = TRUE;
- if ( AccessCheck( pFileDescr,
- hImpersonationToken,
- nDesiredAccess,
- &aGenericMapping,
- &aPrivilegeSet,
- &nPrivilegeSetSize,
- &nGrantedAccess,
- &bAccessible ) )
- {
- bResult = !bAccessible;
- }
-
- CloseHandle( hImpersonationToken );
- }
-
- CloseHandle( hToken );
- }
- }
-
- free( pFileDescr );
- }
-
- return bResult;
-}
-
-#else // this is UNX
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sfx2.hxx"
-
-
-#include <sal/types.h>
-
-sal_Bool IsReadonlyAccordingACL( const sal_Unicode* )
-{
- // to be implemented
- return sal_False;
-}
-
-#endif
-
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: shutdowniconw32.cxx,v $
+ * $Revision: 1.48 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifdef WNT
+
+// necessary to include system headers without warnings
+#ifdef _MSC_VER
+#pragma warning(disable:4668 4917)
+#endif
+
+#include <windows.h>
+#include <lmaccess.h>
+#include <sal/types.h>
+
+sal_Bool IsReadonlyAccordingACL( const sal_Unicode* pFilePath )
+{
+ sal_Bool bResult = sal_False;
+
+ sal_uInt32 nFDSize = 0;
+ GetFileSecurityW( reinterpret_cast< LPCWSTR >(pFilePath), DACL_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|OWNER_SECURITY_INFORMATION, NULL, 0, &nFDSize );
+ if ( nFDSize )
+ {
+ PSECURITY_DESCRIPTOR pFileDescr = reinterpret_cast< PSECURITY_DESCRIPTOR >( malloc( nFDSize ) );
+ if ( GetFileSecurityW( reinterpret_cast< LPCWSTR >(pFilePath), DACL_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|OWNER_SECURITY_INFORMATION, pFileDescr, nFDSize, &nFDSize ) )
+ {
+ HANDLE hToken = NULL;
+ if ( OpenThreadToken( GetCurrentThread(), TOKEN_DUPLICATE|TOKEN_QUERY, TRUE, &hToken )
+ || OpenProcessToken( GetCurrentProcess(), TOKEN_DUPLICATE|TOKEN_QUERY, &hToken) )
+ {
+ HANDLE hImpersonationToken = NULL;
+ if ( DuplicateToken( hToken, SecurityImpersonation, &hImpersonationToken) )
+ {
+ sal_uInt32 nDesiredAccess = ACCESS_WRITE;
+ GENERIC_MAPPING aGenericMapping = { ACCESS_READ, ACCESS_WRITE, 0, ACCESS_READ | ACCESS_WRITE };
+ MapGenericMask( &nDesiredAccess, &aGenericMapping );
+
+ PRIVILEGE_SET aPrivilegeSet;
+ sal_uInt32 nPrivilegeSetSize = sizeof( PRIVILEGE_SET );
+
+ sal_uInt32 nGrantedAccess;
+ BOOL bAccessible = TRUE;
+ if ( AccessCheck( pFileDescr,
+ hImpersonationToken,
+ nDesiredAccess,
+ &aGenericMapping,
+ &aPrivilegeSet,
+ &nPrivilegeSetSize,
+ &nGrantedAccess,
+ &bAccessible ) )
+ {
+ bResult = !bAccessible;
+ }
+
+ CloseHandle( hImpersonationToken );
+ }
+
+ CloseHandle( hToken );
+ }
+ }
+
+ free( pFileDescr );
+ }
+
+ return bResult;
+}
+
+#else // this is UNX
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sfx2.hxx"
+
+
+#include <sal/types.h>
+
+sal_Bool IsReadonlyAccordingACL( const sal_Unicode* )
+{
+ // to be implemented
+ return sal_False;
+}
+
+#endif
+
diff --git a/sfx2/source/inc/helpid.hrc b/sfx2/source/inc/helpid.hrc
index eae960fc7a..9185f0c114 100644
--- a/sfx2/source/inc/helpid.hrc
+++ b/sfx2/source/inc/helpid.hrc
@@ -346,8 +346,9 @@
#define HID_TP_CUSTOMPROPERTIES (HID_SFX_START + 324)
#define HID_CTRL_CUSTOMPROPERTIES (HID_SFX_START + 325)
#define HID_CTRL_CUSTOMPROPS_YES_NO (HID_SFX_START + 326)
+#define HID_DLG_CUSTOMPROPS_DURATION (HID_SFX_START + 327)
-#define ACT_SFX_HID_END HID_CTRL_CUSTOMPROPS_YES_NO
+#define ACT_SFX_HID_END HID_DLG_CUSTOMPROPS_DURATION
// "Uberlaufpr"ufung --------------------------------------------------------
diff --git a/sfx2/source/inc/sfxlocal.hrc b/sfx2/source/inc/sfxlocal.hrc
index 0c0c8a4250..932204440a 100644
--- a/sfx2/source/inc/sfxlocal.hrc
+++ b/sfx2/source/inc/sfxlocal.hrc
@@ -60,6 +60,11 @@
#define SFX_QB_WRONG_TYPE (RID_SFX_SFXLOCAL_START + 7)
#define SFX_IMG_PROPERTY_REMOVE (RID_SFX_SFXLOCAL_START + 8)
#define SFX_IMG_PROPERTY_REMOVE_HC (RID_SFX_SFXLOCAL_START + 9)
+#define SFX_FLD_DATE (RID_SFX_SFXLOCAL_START + 10)
+#define SFX_FLD_TIME (RID_SFX_SFXLOCAL_START + 11)
+#define SFX_FLD_DURATION (RID_SFX_SFXLOCAL_START + 12)
+#define SFX_ST_DURATION_FORMAT (RID_SFX_SFXLOCAL_START + 13)
+
#endif
diff --git a/shell/inc/internal/utilities.hxx b/shell/inc/internal/utilities.hxx
index ebdf60519f..aed96260c3 100644
--- a/shell/inc/internal/utilities.hxx
+++ b/shell/inc/internal/utilities.hxx
@@ -47,6 +47,7 @@
#include "internal/types.hxx"
#include <string>
+#define STRSAFE_NO_DEPRECATE
#include <strsafe.h>
//---------------------------------
diff --git a/shell/inc/internal/xml_parser.hxx b/shell/inc/internal/xml_parser.hxx
index 6080d4c5fd..7e47195f08 100644
--- a/shell/inc/internal/xml_parser.hxx
+++ b/shell/inc/internal/xml_parser.hxx
@@ -31,11 +31,7 @@
#ifndef _XML_PARSER_HXX_
#define _XML_PARSER_HXX_
-#ifdef SYSTEM_EXPAT
#include <expat.h>
-#else
-#include <external/expat/xmlparse.h>
-#endif
#include <stdexcept>
//-----------------------------------------------------
@@ -76,9 +72,6 @@ public:
xml_parser(const XML_Char* EncodingName = 0);
//########################################################
- xml_parser(const XML_Char* EncodingName, XML_Char NamespaceSeparator);
-
- //########################################################
~xml_parser();
//########################################################
@@ -126,10 +119,6 @@ public:
/** Returns the currently used document handler or null if
no document handler was set before. */
i_xml_parser_event_handler* get_document_handler() const;
-
- //############################################
- void set_encoding(const XML_Char* Encoding);
-
private:
void init();
diff --git a/shell/source/all/xml_parser.cxx b/shell/source/all/xml_parser.cxx
index 5dcb351682..6236b1db27 100644
--- a/shell/source/all/xml_parser.cxx
+++ b/shell/source/all/xml_parser.cxx
@@ -90,14 +90,6 @@ xml_parser::xml_parser(const XML_Char* EncodingName) :
}
//###################################################
-xml_parser::xml_parser(const XML_Char* EncodingName, XML_Char /*NamespaceSeparator*/) :
- document_handler_(0),
- xml_parser_(XML_ParserCreate(EncodingName))
-{
- init();
-}
-
-//###################################################
xml_parser::~xml_parser()
{
XML_ParserFree(xml_parser_);
@@ -224,9 +216,3 @@ i_xml_parser_event_handler* xml_parser::get_document_handler() const
{
return document_handler_;
}
-
-//###################################################
-void xml_parser::set_encoding(const XML_Char* Encoding)
-{
- XML_SetEncoding(xml_parser_, Encoding);
-}
diff --git a/shell/source/backends/gconfbe/gconfbackend.cxx b/shell/source/backends/gconfbe/gconfbackend.cxx
index d5ae5915b2..4918eeadba 100644
--- a/shell/source/backends/gconfbe/gconfbackend.cxx
+++ b/shell/source/backends/gconfbe/gconfbackend.cxx
@@ -763,7 +763,6 @@ keyChangedCallback(GConfClient* aClient,
aGconfBe->notifyListeners(aGconfKey);
}
-#endif
//------------------------------------------------------------------------------
@@ -827,7 +826,7 @@ void GconfBackend::notifyListeners(const rtl::OUString& /*aGconfKey*/)
}
*/
}
-
+#endif
//------------------------------------------------------------------------------
void SAL_CALL GconfBackend::addChangesListener(
diff --git a/shell/source/backends/gconfbe/gconfbackend.hxx b/shell/source/backends/gconfbe/gconfbackend.hxx
index 2177eb99b6..e469fe10a4 100644
--- a/shell/source/backends/gconfbe/gconfbackend.hxx
+++ b/shell/source/backends/gconfbe/gconfbackend.hxx
@@ -174,10 +174,11 @@ class GconfBackend : public BackendBase {
const uno::Reference<backend::XBackendChangesListener>& xListener,
const rtl::OUString& aComponent)
throw (::com::sun::star::uno::RuntimeException);
-
+// currently not used
+#if 0
//Notify all listener of component change
void notifyListeners(const rtl::OUString& aGconfKey);
-
+#endif
protected:
/**
Service constructor from a service factory.
diff --git a/shell/source/unix/sysshell/recently_used_file.cxx b/shell/source/unix/sysshell/recently_used_file.cxx
index 9763ea8417..37a4ca7e2a 100644
--- a/shell/source/unix/sysshell/recently_used_file.cxx
+++ b/shell/source/unix/sysshell/recently_used_file.cxx
@@ -115,12 +115,6 @@ void recently_used_file::reset() const
}
//------------------------------------------------
-void recently_used_file::flush()
-{
- fflush(file_);
-}
-
-//------------------------------------------------
void recently_used_file::truncate(off_t length)
{
ftruncate(fileno(file_), length);
diff --git a/shell/source/unix/sysshell/recently_used_file.hxx b/shell/source/unix/sysshell/recently_used_file.hxx
index 596f047d83..8fe8477bb2 100644
--- a/shell/source/unix/sysshell/recently_used_file.hxx
+++ b/shell/source/unix/sysshell/recently_used_file.hxx
@@ -54,9 +54,6 @@ public:
void truncate(off_t length = 0);
//----------------------------
- void flush();
-
- //----------------------------
size_t read(
char* buffer,
size_t size) const;
diff --git a/shell/source/unix/sysshell/recently_used_file_handler.cxx b/shell/source/unix/sysshell/recently_used_file_handler.cxx
index d468a507a3..14ba26a773 100644
--- a/shell/source/unix/sysshell/recently_used_file_handler.cxx
+++ b/shell/source/unix/sysshell/recently_used_file_handler.cxx
@@ -49,18 +49,6 @@
#include <string.h>
namespace /* private */ {
-
- const rtl::OUString ENVV_UPDATE_RECENTLY_USED =
- rtl::OUString::createFromAscii("ENABLE_UPDATE_RECENTLY_USED");
-
- //########################################
- inline rtl::OString get_file_extension(const rtl::OString& file_url)
- {
- sal_Int32 index = file_url.lastIndexOf('.');
- OSL_ENSURE((index != -1) && ((index + 1) < file_url.getLength()), "Invalid file url");
- return file_url.copy(index + 1);
- }
-
//########################################
typedef std::vector<string_t> string_container_t;
@@ -475,14 +463,6 @@ namespace /* private */ {
greater_recently_used_item());
}
- //##############################
- bool update_recently_used_enabled()
- {
- rtl::OUString tmp;
- osl_getEnvironment(ENVV_UPDATE_RECENTLY_USED.pData, &tmp.pData);
- return (tmp.getLength() > 0);
- }
-
//------------------------------------------------
struct cleanup_guard
{
diff --git a/svx/source/accessibility/AccessibleStaticTextBase.cxx b/svx/source/accessibility/AccessibleStaticTextBase.cxx
index c5681a4f0e..c0227e63cb 100644
--- a/svx/source/accessibility/AccessibleStaticTextBase.cxx
+++ b/svx/source/accessibility/AccessibleStaticTextBase.cxx
@@ -1016,9 +1016,9 @@ namespace accessibility
const beans::PropertyValue* pItr = aIntersectionSeq.getConstArray();
const beans::PropertyValue* pEnd = pItr + aIntersectionSeq.getLength();
const beans::PropertyValue* pFind = ::std::find_if( pItr, pEnd, ::std::bind2nd( PropertyValueEqualFunctor(), boost::cref( pDefAttr[i] ) ) );
- if ( pFind == pEnd && pFind->Handle != 0)
+ if ( pFind == pEnd && pDefAttr[i].Handle != 0)
{
- aDiffVec.push_back( *pFind );
+ aDiffVec.push_back( pDefAttr[i] );
}
}
diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx
index 66c437c7ad..50c3b5a64d 100644
--- a/svx/source/dialog/svxruler.cxx
+++ b/svx/source/dialog/svxruler.cxx
@@ -2761,8 +2761,9 @@ void SvxRuler::EvalModifier()
case KEY_MOD1: {
const RulerType eType = GetDragType();
nDragType = DRAG_OBJECT_SIZE_PROPORTIONAL;
- if(RULER_TYPE_BORDER == eType || RULER_TYPE_TAB == eType||
- RULER_TYPE_MARGIN1&&pColumnItem)
+ if( RULER_TYPE_TAB == eType ||
+ ( ( RULER_TYPE_BORDER == eType || RULER_TYPE_MARGIN1 == eType ) &&
+ pColumnItem ) )
PrepareProportional_Impl(eType);
break;
}
diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
index 0e8d85f8ac..ee43fb9dc9 100644
--- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx
+++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
@@ -556,7 +556,7 @@ namespace drawinglayer
const XGradient& rGradient = ((XFillFloatTransparenceItem*)pGradientItem)->GetGradientValue();
const sal_uInt8 nStartLuminance(rGradient.GetStartColor().GetLuminance());
const sal_uInt8 nEndLuminance(rGradient.GetEndColor().GetLuminance());
- const bool bCompletelyTransparent(0xff == nStartLuminance == nEndLuminance);
+ const bool bCompletelyTransparent(0xff == nStartLuminance && 0xff == nEndLuminance);
if(!bCompletelyTransparent)
{
diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.src b/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.src
index dcc74b99e7..49376d2ef7 100644
--- a/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.src
+++ b/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.src
@@ -68,13 +68,13 @@ ModalDialog DLG_CHINESETRANSLATION
Moveable = TRUE ;
SVLook = TRUE;
- Text [ en-US ] = "Chinese Translation";
+ Text [ en-US ] = "Chinese Conversion";
FixedLine FL_DIRECTION
{
Pos = MAP_APPFONT ( COL_1 , ROW_1 ) ;
Size = MAP_APPFONT ( FULL_WIDTH - COL_1 - RSC_SP_DLG_INNERBORDER_RIGHT, RSC_CD_FIXEDLINE_HEIGHT ) ;
- Text [ en-US ] = "Translation direction";
+ Text [ en-US ] = "Conversion direction";
};
DIRECTION_RADIOBUTTONS( COL_2, ROW_2, (FULL_WIDTH - COL_2 - RSC_SP_DLG_INNERBORDER_RIGHT) )
diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx
index 92c4bb77fb..b75a2c6f1d 100644
--- a/svx/source/unodraw/UnoGraphicExporter.cxx
+++ b/svx/source/unodraw/UnoGraphicExporter.cxx
@@ -837,7 +837,9 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic,
if ( aGraphic.GetType() == GRAPHIC_BITMAP )
{
Size aSizePixel( aGraphic.GetSizePixel() );
- if ( rSettings.mnWidth && rSettings.mnHeight && ( rSettings.mnWidth != aSizePixel.Width() ) || ( rSettings.mnHeight != aSizePixel.Height() ) )
+ if( rSettings.mnWidth && rSettings.mnHeight &&
+ ( ( rSettings.mnWidth != aSizePixel.Width() ) ||
+ ( rSettings.mnHeight != aSizePixel.Height() ) ) )
{
BitmapEx aBmpEx( aGraphic.GetBitmapEx() );
aBmpEx.Scale( Size( rSettings.mnWidth, rSettings.mnHeight ) );
diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx
index 35ee19a150..9fa674012e 100644
--- a/svx/source/unodraw/unoshtxt.cxx
+++ b/svx/source/unodraw/unoshtxt.cxx
@@ -350,6 +350,9 @@ void SvxTextEditSourceImpl::ChangeModel( SdrModel* pNewModel )
void SvxTextEditSourceImpl::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
+ // #i105988 keep reference to this object
+ rtl::Reference< SvxTextEditSourceImpl > xThis( this );
+
const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
const SvxViewHint* pViewHint = PTR_CAST( SvxViewHint, &rHint );
diff --git a/ucb/source/ucp/gio/gio_mount.cxx b/ucb/source/ucp/gio/gio_mount.cxx
index 3d1611bd50..4166366c09 100644
--- a/ucb/source/ucp/gio/gio_mount.cxx
+++ b/ucb/source/ucp/gio/gio_mount.cxx
@@ -68,7 +68,7 @@ static void ooo_mount_operation_class_init (OOoMountOperationClass *klass)
using namespace com::sun::star;
static void ooo_mount_operation_ask_password (GMountOperation *op,
- const char *message, const char *default_user,
+ const char * /*message*/, const char *default_user,
const char *default_domain, GAskPasswordFlags flags)
{
uno::Reference< task::XInteractionHandler > xIH;
diff --git a/xmlhelp/source/com/sun/star/help/MANIFEST.MF b/xmlhelp/source/com/sun/star/help/MANIFEST.MF
index bf0e4ab46c..a4c5d50fde 100644
--- a/xmlhelp/source/com/sun/star/help/MANIFEST.MF
+++ b/xmlhelp/source/com/sun/star/help/MANIFEST.MF
@@ -1,2 +1 @@
RegistrationClassName: com.sun.star.help.HelpComponent
-Class-Path: lucene-core-2.3.jar lucene-analyzers-2.3.jar
diff --git a/xmlhelp/source/com/sun/star/help/makefile.mk b/xmlhelp/source/com/sun/star/help/makefile.mk
index db6e619b31..eab2a6a08a 100644
--- a/xmlhelp/source/com/sun/star/help/makefile.mk
+++ b/xmlhelp/source/com/sun/star/help/makefile.mk
@@ -36,6 +36,7 @@ LIBBASENAME = helplinker
PACKAGE = com$/sun$/star$/help
TARGETTYPE=CUI
+.IF "$(SOLAR_JAVA)"!=""
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
@@ -76,14 +77,15 @@ ADDFILES = $(subst,$(SOLARBINDIR)$/help,$(CLASSDIR) $(TRANSEX3FILES))
JARFILES = ridl.jar jurt.jar unoil.jar juh.jar
.IF "$(SYSTEM_LUCENE)" == "YES"
XCLASSPATH!:=$(XCLASSPATH)$(PATH_SEPERATOR)$(LUCENE_CORE_JAR)$(PATH_SEPERATOR)$(LUCENE_ANALYZERS_JAR)
-COMP=fix_system_lucene
+JARCLASSPATH = file://$(LUCENE_CORE_JAR) file://$(LUCENE_ANALYZERS_JAR)
.ELSE
JARFILES += lucene-core-2.3.jar lucene-analyzers-2.3.jar
+JARCLASSPATH = lucene-core-2.3.jar lucene-analyzers-2.3.jar
.ENDIF
JARTARGET = LuceneHelpWrapper.jar
JARCOMPRESS = TRUE
-CUSTOMMANIFESTFILE = MANIFEST.MF
+CUSTOMMANIFESTFILE = MANIFEST.MF
# --- Targets ------------------------------------------------------
@@ -94,15 +96,17 @@ ALLTAR : $(ADDFILES)
.IF "$(JARTARGETN)"!=""
$(JAVATARGET) : $(ADDFILES)
$(JARTARGETN) : $(ADDFILES)
-$(JARTARGETN) : $(COMP)
.ENDIF
$(CLASSDIR)$/$(PACKAGE)$/%.class : $(SOLARBINDIR)$/help$/$(PACKAGE)$/%.class
$(MKDIRHIER) $(@:d)
$(COPY) $< $@
-
fix_system_lucene:
@echo "Fix Java Class-Path entry for Lucene libraries from system."
@$(SED) -r -e "s#^(Class-Path:).*#\1 file://$(LUCENE_CORE_JAR) file://$(LUCENE_ANALYZERS_JAR)#" \
-i ../../../../../$(INPATH)/class/HelpLinker/META-INF/MANIFEST.MF
+.ELSE
+all:
+ @echo java disabled
+.ENDIF
diff --git a/xmlhelp/source/treeview/tvread.cxx b/xmlhelp/source/treeview/tvread.cxx
index 6ee93cd3dc..f8a85c2ee9 100644
--- a/xmlhelp/source/treeview/tvread.cxx
+++ b/xmlhelp/source/treeview/tvread.cxx
@@ -38,11 +38,7 @@
#include <vos/diagnose.hxx>
#endif
#include "tvread.hxx"
-#ifdef SYSTEM_EXPAT
#include <expat.h>
-#else
-#include <expat/xmlparse.h>
-#endif
#include <osl/file.hxx>
#include <com/sun/star/frame/XConfigManager.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
diff --git a/xmloff/inc/txtfldi.hxx b/xmloff/inc/txtfldi.hxx
index 4ced397688..c014b694c6 100644
--- a/xmloff/inc/txtfldi.hxx
+++ b/xmloff/inc/txtfldi.hxx
@@ -745,6 +745,11 @@ class XMLUserDocInfoImportContext : public XMLSimpleDocInfoImportContext
{
rtl::OUString aName;
const ::rtl::OUString sPropertyName;
+ const ::rtl::OUString sPropertyNumberFormat;
+ const ::rtl::OUString sPropertyIsFixedLanguage;
+ sal_Int32 nFormat;
+ sal_Bool bFormatOK;
+ sal_Bool bIsDefaultLanguage;
public:
diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx
index 159974d19d..08aeb7828d 100644
--- a/xmloff/source/text/txtflde.cxx
+++ b/xmloff/source/text/txtflde.cxx
@@ -707,6 +707,7 @@ sal_Bool XMLTextFieldExport::IsStringField(
case FIELD_ID_PAGENUMBER:
case FIELD_ID_REFPAGE_SET:
case FIELD_ID_REFPAGE_GET:
+ case FIELD_ID_DOCINFO_CUSTOM:
// always number
return sal_False;
@@ -727,7 +728,6 @@ sal_Bool XMLTextFieldExport::IsStringField(
case FIELD_ID_HIDDEN_PARAGRAPH:
case FIELD_ID_DOCINFO_CREATION_AUTHOR:
case FIELD_ID_DOCINFO_DESCRIPTION:
- case FIELD_ID_DOCINFO_CUSTOM:
case FIELD_ID_DOCINFO_PRINT_AUTHOR:
case FIELD_ID_DOCINFO_TITLE:
case FIELD_ID_DOCINFO_SUBJECT:
@@ -880,6 +880,7 @@ void XMLTextFieldExport::ExportFieldAutoStyle(
case FIELD_ID_USER_GET:
case FIELD_ID_EXPRESSION:
case FIELD_ID_TABLE_FORMULA:
+ case FIELD_ID_DOCINFO_CUSTOM:
// register number format, if this is a numeric field
if (! IsStringField(nToken, xPropSet)) {
@@ -943,7 +944,6 @@ void XMLTextFieldExport::ExportFieldAutoStyle(
case FIELD_ID_HIDDEN_PARAGRAPH:
case FIELD_ID_DOCINFO_CREATION_AUTHOR:
case FIELD_ID_DOCINFO_DESCRIPTION:
- case FIELD_ID_DOCINFO_CUSTOM:
case FIELD_ID_DOCINFO_PRINT_AUTHOR:
case FIELD_ID_DOCINFO_TITLE:
case FIELD_ID_DOCINFO_SUBJECT:
@@ -1503,6 +1503,13 @@ void XMLTextFieldExport::ExportFieldHelper(
case FIELD_ID_DOCINFO_CUSTOM:
{
+ ProcessValueAndType(sal_False, // doesn't happen for text
+ GetIntProperty(sPropertyNumberFormat,rPropSet),
+ sEmpty, sEmpty, 0.0, // not used
+ sal_False, sal_False, sal_True,
+ ! GetOptionalBoolProperty(
+ sPropertyIsFixedLanguage,
+ rPropSet, xPropSetInfo, sal_False ));
uno::Any aAny = rPropSet->getPropertyValue( sPropertyName );
::rtl::OUString sName;
aAny >>= sName;
diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx
index 3b8b551b92..d47e813c34 100644
--- a/xmloff/source/text/txtfldi.cxx
+++ b/xmloff/source/text/txtfldi.cxx
@@ -2048,6 +2048,11 @@ XMLUserDocInfoImportContext::XMLUserDocInfoImportContext(
sLocalName, nToken,
sal_False, sal_False)
, sPropertyName(RTL_CONSTASCII_USTRINGPARAM(sAPI_name))
+ , sPropertyNumberFormat(RTL_CONSTASCII_USTRINGPARAM(sAPI_number_format))
+ , sPropertyIsFixedLanguage(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_fixed_language))
+ , nFormat(0)
+ , bFormatOK(sal_False)
+ , bIsDefaultLanguage( sal_True )
{
bValid = sal_False;
}
@@ -2058,6 +2063,17 @@ void XMLUserDocInfoImportContext::ProcessAttribute(
{
switch (nAttrToken)
{
+ case XML_TOK_TEXTFIELD_DATA_STYLE_NAME:
+ {
+ sal_Int32 nKey = GetImportHelper().GetDataStyleKey(
+ sAttrValue, &bIsDefaultLanguage);
+ if (-1 != nKey)
+ {
+ nFormat = nKey;
+ bFormatOK = sal_True;
+ }
+ break;
+ }
case XML_TOK_TEXTFIELD_NAME:
{
if (!bValid)
@@ -2080,12 +2096,27 @@ void XMLUserDocInfoImportContext::PrepareField(
const ::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertySet> & xPropertySet)
{
+ uno::Any aAny;
if ( aName.getLength() )
{
- uno::Any aAny;
aAny <<= aName;
xPropertySet->setPropertyValue(sPropertyName, aAny);
}
+ Reference<XPropertySetInfo> xPropertySetInfo(
+ xPropertySet->getPropertySetInfo());
+ if (bFormatOK &&
+ xPropertySetInfo->hasPropertyByName(sPropertyNumberFormat))
+ {
+ aAny <<= nFormat;
+ xPropertySet->setPropertyValue(sPropertyNumberFormat, aAny);
+
+ if( xPropertySetInfo->hasPropertyByName( sPropertyIsFixedLanguage ) )
+ {
+ sal_Bool bIsFixedLanguage = ! bIsDefaultLanguage;
+ aAny.setValue( &bIsFixedLanguage, ::getBooleanCppuType() );
+ xPropertySet->setPropertyValue( sPropertyIsFixedLanguage, aAny );
+ }
+ }
// call superclass to handle "fixed"
XMLSimpleDocInfoImportContext::PrepareField(xPropertySet);
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx
index ea18c31a01..f47aa1016d 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -1661,8 +1661,14 @@ void XMLTextImportHelper::SetOutlineStyles( sal_Bool bSetEmptyLevels )
pProps->Name = sHeadingStyleName;
for ( sal_Int32 i = 0; i < nCount; ++i )
{
- pProps->Value <<= sChosenStyles[i];
- xChapterNumbering->replaceByIndex( i, makeAny( aProps ) );
+ // --> OD 2009-12-11 #i107610#
+ if ( bSetEmptyLevels ||
+ sChosenStyles[i].getLength() > 0 )
+ // <--
+ {
+ pProps->Value <<= sChosenStyles[i];
+ xChapterNumbering->replaceByIndex( i, makeAny( aProps ) );
+ }
}
// <--
}