diff -urN officecfg.old/registry/data/org/openoffice/Setup.xcu officecfg/registry/data/org/openoffice/Setup.xcu
--- officecfg.old/registry/data/org/openoffice/Setup.xcu 2010-01-25 11:33:48.734375000 +0800
+++ officecfg/registry/data/org/openoffice/Setup.xcu 2010-01-26 13:28:22.390625000 +0800
@@ -89,6 +89,9 @@
+
+ false
+
scalc
@@ -130,6 +133,9 @@
+
+ false
+
sdraw
@@ -171,6 +177,9 @@
+
+ false
+
simpress
@@ -210,6 +219,9 @@
+
+ false
+
smath
@@ -249,6 +261,9 @@
+
+ false
+
sglobal
@@ -290,6 +305,9 @@
+
+ false
+
swriter
@@ -438,6 +456,9 @@
+
+ false
+
sweb
@@ -690,6 +711,9 @@
+
+ false
+
schart
@@ -729,6 +753,9 @@
+
+ false
+
dbapp
diff -urN officecfg.old/registry/schema/org/openoffice/Setup.xcs officecfg/registry/schema/org/openoffice/Setup.xcs
--- officecfg.old/registry/schema/org/openoffice/Setup.xcs 2010-01-25 11:33:50.078125000 +0800
+++ officecfg/registry/schema/org/openoffice/Setup.xcs 2010-01-25 15:16:26.828125000 +0800
@@ -138,6 +138,12 @@
Specifies the name of the standard template file for the factory.
+
+
+
+ Indicates if the system default template has been changed.
+
+
diff -urN sfx2.old/inc/sfx2/docfac.hxx sfx2/inc/sfx2/docfac.hxx
--- sfx2.old/inc/sfx2/docfac.hxx 2010-01-25 14:31:06.921875000 +0800
+++ sfx2/inc/sfx2/docfac.hxx 2010-01-25 15:16:26.843750000 +0800
@@ -100,6 +100,7 @@
const SfxFilter* GetTemplateFilter() const;
static String GetStandardTemplate( const String& rServiceName );
static void SetStandardTemplate( const String& rServiceName, const String& rTemplateName );
+ static void SetSystemTemplate( const String& rServiceName, const String& rTemplateName );
void SetDocumentServiceName( const rtl::OUString& rServiceName );
const rtl::OUString& GetDocumentServiceName() const;
diff -urN sfx2.old/source/doc/docfac.cxx sfx2/source/doc/docfac.cxx
--- sfx2.old/source/doc/docfac.cxx 2010-01-25 14:31:07.515625000 +0800
+++ sfx2/source/doc/docfac.cxx 2010-03-09 13:57:45.875000000 +0800
@@ -33,13 +33,19 @@
#include
#include
#include
+#include
+#include
+#include
+#include
#include
#include
#include
#include
#include
#include
+#include
#include
+#include
#include
#include
@@ -52,9 +58,15 @@
#include
#include "sfxresid.hxx"
#include
+#include "syspath.hxx"
+#include
+#include
#include "doc.hrc"
+#include
+
namespace css = ::com::sun::star;
+using namespace ::com::sun::star;
//========================================================================
@@ -185,13 +197,125 @@
pImpl->pModule = pMod;
}
+void SfxObjectFactory::SetSystemTemplate( const String& rServiceName, const String& rTemplateName )
+{
+ static ::rtl::OUString SERVICE_FILTER_FACTORY = ::rtl::OUString::createFromAscii( "com.sun.star.document.FilterFactory" );
+ static ::rtl::OUString SERVICE_TYPE_DECTECTION = ::rtl::OUString::createFromAscii( "com.sun.star.document.TypeDetection" );
+ static ::rtl::OUString SERVICE_SIMPLE_ACCESS = ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" );
+
+ static ::rtl::OUString CONF_ROOT = ::rtl::OUString::createFromAscii( "/org.openoffice.Setup");
+ static ::rtl::OUString CONF_PATH = ::rtl::OUString::createFromAscii( "Office/Factories/" ) + ::rtl::OUString( rServiceName );
+ static ::rtl::OUString PROP_DEF_TEMPL_CHANGED = ::rtl::OUString::createFromAscii( "ooSetupFactorySystemDefaultTemplateChanged" );
+ static ::rtl::OUString PROP_ACTUAL_FILTER = ::rtl::OUString::createFromAscii( "ooSetupFactoryActualFilter" );
+
+ static ::rtl::OUString DEF_TPL_STR = ::rtl::OUString::createFromAscii("/soffice.");
+
+ String sURL;
+ ::utl::LocalFileHelper::ConvertPhysicalNameToURL( String( SystemPath::GetUserTemplateLocation()), sURL );
+
+ ::rtl::OUString aUserTemplateURL( sURL );
+ if ( aUserTemplateURL.getLength() != 0)
+ {
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
+ uno::Reference< uno::XInterface > xConfig = ::comphelper::ConfigurationHelper::openConfig(
+ xFactory, CONF_ROOT, ::comphelper::ConfigurationHelper::E_STANDARD );
+
+ ::rtl::OUString aActualFilter;
+ ::comphelper::ConfigurationHelper::readRelativeKey( xConfig, CONF_PATH, PROP_ACTUAL_FILTER ) >>= aActualFilter;
+ sal_Bool bChanged;
+ ::comphelper::ConfigurationHelper::readRelativeKey( xConfig, CONF_PATH, PROP_DEF_TEMPL_CHANGED ) >>= bChanged;
+
+ uno::Reference< container::XNameAccess > xFilterFactory(
+ xFactory->createInstance( SERVICE_FILTER_FACTORY ), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameAccess > xTypeDetection(
+ xFactory->createInstance( SERVICE_TYPE_DECTECTION ), uno::UNO_QUERY_THROW );
+
+ ::rtl::OUString aActualFilterTypeName;
+ uno::Sequence< beans::PropertyValue > aActuralFilterData;
+ xFilterFactory->getByName( aActualFilter ) >>= aActuralFilterData;
+ for ( sal_Int32 nInd = 0; nInd < aActuralFilterData.getLength(); nInd++ )
+ if ( aActuralFilterData[nInd].Name.equalsAscii( "Type" ) )
+ aActuralFilterData[nInd].Value >>= aActualFilterTypeName;
+ ::comphelper::SequenceAsHashMap aProps1( xTypeDetection->getByName( aActualFilterTypeName ) );
+ uno::Sequence< ::rtl::OUString > aAllExt =
+ aProps1.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "Extensions" ), uno::Sequence< ::rtl::OUString >() );
+ //To-do: check if aAllExt is empty first
+ ::rtl::OUString aExt = aAllExt[0];
+
+ aUserTemplateURL += DEF_TPL_STR;
+ aUserTemplateURL += aExt;
+
+ uno::Reference< ucb::XSimpleFileAccess > xSimpleFileAccess(
+ xFactory->createInstance( SERVICE_SIMPLE_ACCESS ), uno::UNO_QUERY_THROW );
+
+ ::rtl::OUString aBackupURL;
+ ::osl::Security().getConfigDir(aBackupURL);
+ aBackupURL += ::rtl::OUString::createFromAscii( "/temp" );
+
+ if ( !xSimpleFileAccess->exists( aBackupURL ) )
+ xSimpleFileAccess->createFolder( aBackupURL );
+
+ aBackupURL += DEF_TPL_STR;
+ aBackupURL += aExt;
+
+ if ( rTemplateName.Len() != 0 )
+ {
+ if ( xSimpleFileAccess->exists( aUserTemplateURL ) && !bChanged )
+ xSimpleFileAccess->copy( aUserTemplateURL, aBackupURL );
+
+ uno::Reference< document::XTypeDetection > xTypeDetector( xTypeDetection, uno::UNO_QUERY );
+ ::comphelper::SequenceAsHashMap aProps2( xTypeDetection->getByName( xTypeDetector->queryTypeByURL( rTemplateName ) ) );
+ ::rtl::OUString aFilterName =
+ aProps2.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii("PreferredFilter"), ::rtl::OUString() );
+
+ uno::Sequence< beans::PropertyValue > aArgs( 3 );
+ aArgs[0].Name = ::rtl::OUString::createFromAscii( "FilterName" );
+ aArgs[0].Value <<= aFilterName;
+ aArgs[1].Name = ::rtl::OUString::createFromAscii( "AsTemplate" );
+ aArgs[1].Value <<= sal_True;
+ aArgs[2].Name = ::rtl::OUString::createFromAscii( "URL" );
+ aArgs[2].Value <<= ::rtl::OUString( rTemplateName );
+
+ uno::Reference< frame::XLoadable > xLoadable( xFactory->createInstance( ::rtl::OUString( rServiceName ) ), uno::UNO_QUERY );
+ xLoadable->load( aArgs );
+
+ aArgs.realloc( 2 );
+ aArgs[1].Name = ::rtl::OUString::createFromAscii( "Overwrite" );
+ aArgs[1].Value <<= sal_True;
+
+ uno::Reference< frame::XStorable > xStorable( xLoadable, uno::UNO_QUERY );
+ xStorable->storeToURL( aUserTemplateURL, aArgs );
+ ::comphelper::ConfigurationHelper::writeRelativeKey( xConfig, CONF_PATH, PROP_DEF_TEMPL_CHANGED, uno::makeAny( sal_True ));
+ ::comphelper::ConfigurationHelper::flush( xConfig );
+ }
+ else
+ {
+ DBG_ASSERT( bChanged, "invalid ooSetupFactorySystemDefaultTemplateChanged value!" );
+
+ xSimpleFileAccess->copy( aBackupURL, aUserTemplateURL );
+ xSimpleFileAccess->kill( aBackupURL );
+ ::comphelper::ConfigurationHelper::writeRelativeKey( xConfig, CONF_PATH, PROP_DEF_TEMPL_CHANGED, uno::makeAny( sal_False ));
+ ::comphelper::ConfigurationHelper::flush( xConfig );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+}
+
void SfxObjectFactory::SetStandardTemplate( const String& rServiceName, const String& rTemplate )
{
SvtModuleOptions::EFactory eFac = SvtModuleOptions::ClassifyFactoryByServiceName(rServiceName);
if (eFac == SvtModuleOptions::E_UNKNOWN_FACTORY)
eFac = SvtModuleOptions::ClassifyFactoryByShortName(rServiceName);
if (eFac != SvtModuleOptions::E_UNKNOWN_FACTORY)
+ {
+ SetSystemTemplate( rServiceName, rTemplate );
SvtModuleOptions().SetFactoryStandardTemplate(eFac, rTemplate);
+ }
}
String SfxObjectFactory::GetStandardTemplate( const String& rServiceName )
diff -urN sfx2.old/source/doc/makefile.mk sfx2/source/doc/makefile.mk
--- sfx2.old/source/doc/makefile.mk 2010-01-25 14:31:07.562500000 +0800
+++ sfx2/source/doc/makefile.mk 2010-01-25 15:16:26.859375000 +0800
@@ -88,7 +88,8 @@
$(SLO)$/sfxmodelfactory.obj \
$(SLO)$/sfxacldetect.obj \
$(SLO)$/docstoragemodifylistener.obj \
- $(SLO)$/querytemplate.obj
+ $(SLO)$/querytemplate.obj \
+ $(SLO)$/syspathw32.obj
# $(SLO)$/applet.obj \
diff -urN sfx2.old/source/doc/syspath.hxx sfx2/source/doc/syspath.hxx
--- sfx2.old/source/doc/syspath.hxx 1970-01-01 08:00:00.000000000 +0800
+++ sfx2/source/doc/syspath.hxx 2010-02-03 16:11:50.609375000 +0800
@@ -0,0 +1,44 @@
+/*************************************************************************
+*
+* 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
+*
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
+
+#ifndef __SYSPATH_HXX__
+#define __SYSPATH_HXX__
+//#pragma warning(disable:4917)
+
+#include
+#include
+
+class SFX2_DLLPUBLIC SystemPath
+{
+public:
+ static ::rtl::OUString GetUserTemplateLocation();
+};
+
+#endif
\ No newline at end of file
diff -urN sfx2.old/source/doc/syspathw32.cxx sfx2/source/doc/syspathw32.cxx
--- sfx2.old/source/doc/syspathw32.cxx 1970-01-01 08:00:00.000000000 +0800
+++ sfx2/source/doc/syspathw32.cxx 2010-02-04 10:59:32.046875000 +0800
@@ -0,0 +1,79 @@
+/*************************************************************************
+*
+* 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
+*
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sfx2.hxx"
+
+#include "syspath.hxx"
+
+using namespace ::rtl;
+
+#ifdef WNT
+#include
+
+#define ALLOC(type, n) ((type *) HeapAlloc(GetProcessHeap(), 0, sizeof(type) * n ))
+#define FREE(p) HeapFree(GetProcessHeap(), 0, p)
+
+static OUString _SHGetSpecialFolderW32( int nFolderID )
+{
+ LPITEMIDLIST pidl;
+ HRESULT hHdl = SHGetSpecialFolderLocation( NULL, nFolderID, &pidl );
+ OUString aFolder;
+
+ if( hHdl == NOERROR )
+ {
+ WCHAR *lpFolderA;
+ lpFolderA = ALLOC( WCHAR, 16000 );
+
+ SHGetPathFromIDListW( pidl, lpFolderA );
+ aFolder = OUString( reinterpret_cast(lpFolderA) );
+
+ FREE( lpFolderA );
+ IMalloc *pMalloc;
+ if( NOERROR == SHGetMalloc(&pMalloc) )
+ {
+ pMalloc->Free( pidl );
+ pMalloc->Release();
+ }
+ }
+ return aFolder;
+}
+
+#endif
+
+OUString SystemPath::GetUserTemplateLocation()
+{
+#ifdef WNT
+ return _SHGetSpecialFolderW32(CSIDL_TEMPLATES);
+#endif
+#ifdef UNX
+ return OUString();
+#endif
+}