diff options
Diffstat (limited to 'sfx2/source/doc')
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 11 | ||||
-rw-r--r-- | sfx2/source/doc/makefile.mk | 8 | ||||
-rw-r--r-- | sfx2/source/doc/objcont.cxx | 44 | ||||
-rw-r--r-- | sfx2/source/doc/objmisc.cxx | 7 | ||||
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 16 | ||||
-rwxr-xr-x | sfx2/source/doc/sfxacldetect.cxx | 108 |
6 files changed, 174 insertions, 20 deletions
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 7902444ad2c4..00bad511b10c 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -155,6 +155,8 @@ using namespace ::com::sun::star::io; #define MAX_REDIRECT 5 +sal_Bool IsReadonlyAccordingACL( const sal_Unicode* pFilePath ); + //========================================================== namespace { @@ -1145,6 +1147,15 @@ sal_Bool SfxMedium::LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI ) } catch( uno::Exception ) {} + + if ( !bContentReadonly ) + { + // the file is not readonly, check the ACL + + String aPhysPath; + if ( ::utl::LocalFileHelper::ConvertURLToPhysicalName( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), aPhysPath ) ) + bContentReadonly = IsReadonlyAccordingACL( aPhysPath.GetBuffer() ); + } } // do further checks only if the file not readonly in fs diff --git a/sfx2/source/doc/makefile.mk b/sfx2/source/doc/makefile.mk index 1b42844491e0..66fd03175a8e 100644 --- a/sfx2/source/doc/makefile.mk +++ b/sfx2/source/doc/makefile.mk @@ -86,11 +86,19 @@ SLOFILES = \ $(SLO)$/DocumentMetadataAccess.obj \ $(SLO)$/Metadatable.obj \ $(SLO)$/sfxmodelfactory.obj \ + $(SLO)$/sfxacldetect.obj \ $(SLO)$/docstoragemodifylistener.obj \ $(SLO)$/querytemplate.obj # $(SLO)$/applet.obj \ +.IF "$(GUI)" == "WNT" + +#HACK TO DISABLE PCH +NOOPTFILES= \ + $(SLO)$/sfxacldetect.obj +.ENDIF + # --- Tagets ------------------------------------------------------- diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index ae2353e3c277..6883f0976566 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -1423,31 +1423,35 @@ sal_Bool SfxObjectShell::IsHelpDocument() const void SfxObjectShell::ResetFromTemplate( const String& rTemplateName, const String& rFileName ) { - uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties()); - xDocProps->setTemplateURL( ::rtl::OUString() ); - xDocProps->setTemplateName( ::rtl::OUString() ); - xDocProps->setTemplateDate( util::DateTime() ); - xDocProps->resetUserData( ::rtl::OUString() ); + // only care about reseting this data for openoffice formats otherwise + if ( IsOwnStorageFormat_Impl( *GetMedium()) ) + { + uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties()); + xDocProps->setTemplateURL( ::rtl::OUString() ); + xDocProps->setTemplateName( ::rtl::OUString() ); + xDocProps->setTemplateDate( util::DateTime() ); + xDocProps->resetUserData( ::rtl::OUString() ); - // TODO/REFACTOR: - // Title? + // TODO/REFACTOR: + // Title? - if( ::utl::LocalFileHelper::IsLocalFile( rFileName ) ) - { - String aFoundName; - if( SFX_APP()->Get_Impl()->GetDocumentTemplates()->GetFull( String(), rTemplateName, aFoundName ) ) + if( ::utl::LocalFileHelper::IsLocalFile( rFileName ) ) { - INetURLObject aObj( rFileName ); - xDocProps->setTemplateURL( aObj.GetMainURL(INetURLObject::DECODE_TO_IURI) ); - xDocProps->setTemplateName( rTemplateName ); + String aFoundName; + if( SFX_APP()->Get_Impl()->GetDocumentTemplates()->GetFull( String(), rTemplateName, aFoundName ) ) + { + INetURLObject aObj( rFileName ); + xDocProps->setTemplateURL( aObj.GetMainURL(INetURLObject::DECODE_TO_IURI) ); + xDocProps->setTemplateName( rTemplateName ); - ::DateTime now; - xDocProps->setTemplateDate( util::DateTime( - now.Get100Sec(), now.GetSec(), now.GetMin(), - now.GetHour(), now.GetDay(), now.GetMonth(), - now.GetYear() ) ); + ::DateTime now; + xDocProps->setTemplateDate( util::DateTime( + now.Get100Sec(), now.GetSec(), now.GetMin(), + now.GetHour(), now.GetDay(), now.GetMonth(), + now.GetYear() ) ); - SetQueryLoadTemplate( sal_True ); + SetQueryLoadTemplate( sal_True ); + } } } } diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 295f7db83a11..09943f5cca38 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -491,6 +491,13 @@ sal_Bool SfxObjectShell::IsInModalMode() const return pImp->bModalMode || pImp->bRunningMacro; } +//<!--Added by PengYunQuan for Validity Cell Range Picker +sal_Bool SfxObjectShell::AcceptStateUpdate() const +{ + return !IsInModalMode(); +} +//-->Added by PengYunQuan for Validity Cell Range Picker + //------------------------------------------------------------------------- sal_Bool SfxObjectShell::HasModalViews() const diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 2c1a79dba418..fb555c5edeec 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -1512,3 +1512,19 @@ void SfxObjectShell::SignScriptingContent() ImplSign( TRUE ); } +// static +const uno::Sequence<sal_Int8>& SfxObjectShell::getUnoTunnelId() +{ + static uno::Sequence<sal_Int8> * pSeq = 0; + if( !pSeq ) + { + osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); + if( !pSeq ) + { + static uno::Sequence< sal_Int8 > aSeq( 16 ); + rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); + pSeq = &aSeq; + } + } + return *pSeq; +} diff --git a/sfx2/source/doc/sfxacldetect.cxx b/sfx2/source/doc/sfxacldetect.cxx new file mode 100755 index 000000000000..94370e9a1c52 --- /dev/null +++ b/sfx2/source/doc/sfxacldetect.cxx @@ -0,0 +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
+
|