From 17f1988c7649d4239ba675040bf7dc145f3e5423 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Wed, 16 Sep 2009 11:45:54 +0000 Subject: CWS-TOOLING: integrate CWS l10nframework01 --- sfx2/sdi/makefile.mk | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sfx2') diff --git a/sfx2/sdi/makefile.mk b/sfx2/sdi/makefile.mk index ddf487094cf3..f8def0a3c23c 100644 --- a/sfx2/sdi/makefile.mk +++ b/sfx2/sdi/makefile.mk @@ -39,10 +39,13 @@ TARGET=sfxslots .INCLUDE : settings.mk .INCLUDE : $(PRJ)$/util$/makefile.pmk +.IF "$(L10N_framework)"=="" + SDI1NAME=$(TARGET) SDI1EXPORT=sfx #SIDHRCNAME=sfx.hrc unused??? +.ENDIF # --- Files -------------------------------------------------------- SVSDI1DEPEND= \ -- cgit From a9ac4fe6fd5b3ee921a8eee85a715c3ef881e47e Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Wed, 16 Sep 2009 13:55:36 +0000 Subject: CWS-TOOLING: integrate CWS impressnotes01 2009-09-11 13:52:41 +0200 cl r276061 : CWS-TOOLING: rebase CWS impressnotes01 to trunk@276043 (milestone: DEV300:m58) 2009-09-10 15:44:57 +0200 cl r276039 : #i103139# continued work on the impress annotation feature 2009-09-10 14:52:31 +0200 cl r276032 : #i103139# continued work on the impress annotation feature 2009-09-10 14:50:32 +0200 cl r276031 : #i103139# continued work on the impress annotation feature 2009-09-10 14:48:29 +0200 cl r276030 : #i103139# continued work on the impress annotation feature 2009-09-10 11:36:11 +0200 cl r276027 : #i103139# continued work on the impress annotation feature 2009-09-09 20:22:41 +0200 cl r276018 : #i103139# continued work on the impress annotation feature 2009-09-09 20:21:45 +0200 cl r276017 : #i103139# continued work on the impress annotation feature 2009-09-09 19:32:29 +0200 sj r276015 : #i103139# added import of comments (ppt binary) 2009-09-09 19:31:07 +0200 sj r276014 : #i103139# added import of comments (ppt binary) 2009-09-09 19:16:41 +0200 cl r276011 : #i103139# continued work on the impress annotation feature 2009-09-09 19:15:19 +0200 cl r276010 : #i103139# continued work on the impress annotation feature 2009-09-09 16:27:19 +0200 cl r276001 : #i104579# fixed isEmptyPresObj() 2009-09-09 15:12:02 +0200 cl r275997 : #i103139# continued work on the impress annotation feature 2009-09-09 15:06:29 +0200 sj r275996 : #i103139# added import of comments (ppt binary) 2009-09-09 14:53:01 +0200 cl r275995 : #i103139# continued work on the impress annotation feature 2009-09-09 14:51:32 +0200 cl r275994 : #i103139# continued work on the impress annotation feature 2009-09-09 12:11:17 +0200 cl r275982 : #i103139# continued work on the impress annotation feature 2009-09-09 11:47:55 +0200 cl r275981 : #i103139# continued work on the impress annotation feature 2009-09-09 11:47:23 +0200 cl r275980 : #i103139# continued work on the impress annotation feature 2009-09-09 11:44:47 +0200 cl r275978 : #i104315# added missing tab pages 2009-09-08 16:04:44 +0200 cl r275936 : #i103139# continued work on the impress annotation feature 2009-09-08 16:03:28 +0200 cl r275935 : #i103139# continued work on the impress annotation feature 2009-09-08 11:45:47 +0200 cl r275920 : #i103139# continued work on the impress annotation feature 2009-09-08 11:41:51 +0200 cl r275919 : #i103139# continued work on the impress annotation feature 2009-09-07 18:30:55 +0200 cl r275910 : #i103139# continued work on the impress annotation feature 2009-09-07 18:29:37 +0200 cl r275909 : #i103139# continued work on the impress annotation feature 2009-09-07 17:25:43 +0200 cl r275905 : #i103139# continued work on the impress annotation feature 2009-09-07 12:00:28 +0200 cl r275884 : #i103139# continued work on the impress annotation feature 2009-09-06 14:14:00 +0200 cl r275859 : #i103139# continued work on the impress annotation feature 2009-09-05 20:57:24 +0200 cl r275854 : #i103139# continued work on the impress annotation feature 2009-09-05 20:56:29 +0200 cl r275853 : #i103139# continued work on the impress annotation feature 2009-09-05 20:55:27 +0200 cl r275852 : #i103139# continued work on the impress annotation feature 2009-09-05 20:11:42 +0200 cl r275851 : #i103139# continued work on the impress annotation feature 2009-09-05 20:11:09 +0200 cl r275850 : #i103139# continued work on the impress annotation feature 2009-09-05 17:43:33 +0200 cl r275845 : #i103139# continued work on the impress annotation feature 2009-09-05 17:04:41 +0200 cl r275843 : #i103139# continued work on the impress annotation feature 2009-09-05 17:03:26 +0200 cl r275842 : #i103139# continued work on the impress annotation feature 2009-09-05 17:02:53 +0200 cl r275841 : #i103139# continued work on the impress annotation feature 2009-09-05 13:15:04 +0200 pl r275839 : #i104823# WB_NEEDSFOCUS 2009-09-05 13:14:41 +0200 pl r275838 : #i104823# WB_NEEDSFOCUS 2009-09-04 17:48:21 +0200 cl r275826 : #i103139# continued work on the impress annotation feature 2009-09-04 17:35:03 +0200 cl r275825 : #i103139# continued work on the impress annotation feature 2009-09-04 17:15:46 +0200 cl r275824 : #i103139# continued work on the impress annotation feature 2009-09-04 17:12:54 +0200 cl r275823 : #i103139# continued work on the impress annotation feature 2009-09-04 17:05:23 +0200 cl r275822 : #i103139# continued work on the impress annotation feature 2009-09-04 16:48:28 +0200 cl r275820 : #i103139# continued work on the impress annotation feature 2009-09-04 16:44:02 +0200 cl r275818 : #i103139# continued work on the impress annotation feature 2009-09-04 16:43:23 +0200 cl r275817 : #i103139# continued work on the impress annotation feature 2009-09-04 16:06:04 +0200 cl r275812 : #i103139# continued work on the impress annotation feature 2009-09-04 16:05:45 +0200 cl r275811 : #i103139# continued work on the impress annotation feature 2009-09-04 15:04:33 +0200 cl r275806 : #i103139# continued work on the impress annotation feature 2009-09-04 11:43:14 +0200 cl r275795 : #i103139# continued work on the impress annotation feature 2009-09-04 11:27:10 +0200 cl r275793 : #i103139# continued work on the impress annotation feature 2009-09-04 11:10:02 +0200 cl r275792 : #i103139# continued work on the impress annotation feature 2009-09-04 11:07:05 +0200 cl r275790 : #i103139# continued work on the impress annotation feature 2009-09-04 11:05:01 +0200 cl r275789 : #i103139# continued work on the impress annotation feature 2009-09-04 10:55:51 +0200 cl r275785 : #i103139# renamed notes to comments 2009-09-04 10:54:57 +0200 cl r275784 : #i103139# renamed notes to comments 2009-09-03 20:37:35 +0200 cl r275772 : #i103139# continued work on the impress annotation feature 2009-09-03 20:35:31 +0200 cl r275771 : #i103139# continued work on the impress annotation feature 2009-09-01 18:17:55 +0200 cl r275680 : #i103139# continued work on the impress annotation feature 2009-09-01 18:15:08 +0200 cl r275678 : #i103139# continued work on the impress annotation feature 2009-09-01 18:13:38 +0200 cl r275677 : #i103139# continued work on the impress annotation feature 2009-08-18 12:35:42 +0200 cl r275089 : fixed merge error 2009-08-18 11:39:58 +0200 cl r275086 : CWS-TOOLING: rebase CWS impressnotes01 to trunk@275001 (milestone: DEV300:m55) 2009-07-30 13:45:10 +0200 cl r274481 : fixed merge errrors 2009-07-30 13:41:21 +0200 cl r274480 : fixed merge errrors 2009-07-30 13:39:40 +0200 cl r274478 : fixed merge errrors 2009-07-22 18:07:30 +0200 cl r274256 : CWS-TOOLING: rebase CWS impressnotes01 to trunk@273858 (milestone: DEV300:m52) 2009-07-21 17:21:31 +0200 cl r274208 : merging 2009-07-20 14:28:34 +0200 cl r274137 : #i103139# annotation support for impress 2009-07-20 14:28:04 +0200 cl r274136 : #i103139# annotation support for impress 2009-07-20 14:27:20 +0200 cl r274135 : #i103139# annotation support for impress 2009-07-20 14:21:17 +0200 cl r274134 : #i103139# annotation support for impress 2009-07-20 14:20:56 +0200 cl r274133 : #i103139# annotation support for impress 2009-07-20 14:20:09 +0200 cl r274132 : #i103139# annotation support for impress 2009-07-20 14:19:00 +0200 cl r274131 : #i103139# annotation support for impress 2009-07-20 14:17:50 +0200 cl r274130 : #i103139# annotation support for impress 2009-07-20 14:12:24 +0200 cl r274129 : #i103139# annotation support for impress 2009-07-20 13:52:03 +0200 cl r274128 : #i103139# annotation support for impress 2009-07-20 13:51:11 +0200 cl r274127 : #i103139# annotation support for impress 2009-07-20 13:48:59 +0200 cl r274126 : #i103139# annotation support for impress 2009-07-20 13:43:56 +0200 cl r274125 : #i103139# annotation support for impress 2009-07-20 13:31:55 +0200 cl r274123 : #i103139# annotation support for impress 2009-07-20 13:30:45 +0200 cl r274122 : #i103139# annotation support for impress --- sfx2/source/doc/objserv.cxx | 2 +- sfx2/source/doc/objstor.cxx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index a47fc1bf4747..34a3f3159169 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -1386,7 +1386,7 @@ void SfxObjectShell::ImplSign( sal_Bool bScriptingContent ) { // the document might need saving ( new, modified or in ODF1.1 format without signature ) - if ( nVersion == SvtSaveOptions::ODFVER_012 ) + if ( nVersion >= SvtSaveOptions::ODFVER_012 ) { if ( (bHasSign && QueryBox( NULL, SfxResId( MSG_XMLSEC_QUERY_SAVESIGNEDBEFORESIGN ) ).Execute() == RET_YES) diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 5a4aed274c30..602174fb2bf9 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -370,7 +370,7 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto SvtSaveOptions::ODFDefaultVersion nDefVersion = aSaveOpt.GetODFDefaultVersion(); // older versions can not have this property set, it exists only starting from ODF1.2 - if ( nDefVersion == SvtSaveOptions::ODFVER_012 ) + if ( nDefVersion >= SvtSaveOptions::ODFVER_012 ) aVersion = ODFVER_012_TEXT; if ( aVersion.getLength() ) @@ -1207,7 +1207,7 @@ sal_Bool SfxObjectShell::SaveTo_Impl bNoPreserveForOasis = ( (aODFVersion.equals( ODFVER_012_TEXT ) && nVersion == SvtSaveOptions::ODFVER_011) || - (!aODFVersion.getLength() && nVersion == SvtSaveOptions::ODFVER_012) + (!aODFVersion.getLength() && nVersion >= SvtSaveOptions::ODFVER_012) ); } } -- cgit From 8c895561f63ed7161947a04da8e6a3d3fb195fa7 Mon Sep 17 00:00:00 2001 From: Jens-Heiner Rechtien Date: Wed, 16 Sep 2009 16:17:27 +0000 Subject: CWS-TOOLING: integrate CWS fwk116 2009-09-03 Mikhail Voytenko #i101453# write the default values for old entries 2009-09-03 Mikhail Voytenko #i101453# let the new default value be used 2009-09-03 Mikhail Voytenko #i101453# revert the change for xslt-transformation, the duplicate nodes should not be allowed 2009-09-03 Mikhail Voytenko #i101453# allow duplicate nodes for different modules 2009-09-03 Mikhail Voytenko #i101453# fix the special mac installation 2009-09-02 Mikhail Voytenko #i101453# correct the usage of configuration files 2009-09-02 Mikhail Voytenko #i10000# fix warning 2009-09-02 Mikhail Voytenko #i10000# fix warning 2009-09-02 Mikhail Voytenko #i96918# try to open the file for editing always 2009-09-02 Mikhail Voytenko #i51058# remove unused strings 2009-09-02 Mikhail Voytenko #i51058# remove unused strings 2009-09-01 Mikhail Voytenko #i10000# fix typo 2009-08-30 Mikhail Voytenko Rebase on DEV300_m56 2009-08-19 Mikhail Voytenko #i101732# do not generate a transparent bitmap for thumbnail 2009-08-13 Mikhail Voytenko #i101453# do not use system temporary location on Mac 2009-08-13 Mikhail Voytenko #i101453# do not use system temporary location on Mac 2009-08-07 Mikhail Voytenko #i103617# fix warning 2009-07-31 Carsten Driesner #i103924# Fix wrong number of arguments 2009-07-31 Mikhail Voytenko #i101207# integrate the patch 2009-07-31 Mikhail Voytenko #i103783# integrate the patch; get rid of CRLF 2009-07-31 Mikhail Voytenko #i97969# integrate the patch 2009-07-27 Carsten Driesner #i103423# Use correct request count in the ctor. Don't descrease value before checking the request count --- sfx2/source/doc/docfile.cxx | 16 ++++++++++++++-- sfx2/source/doc/doctemplates.cxx | 10 ++++++++-- sfx2/source/doc/graphhelp.cxx | 27 +-------------------------- 3 files changed, 23 insertions(+), 30 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 23093bfa066f..3fec8e40bfb7 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -1231,9 +1231,20 @@ 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 ) + if ( bLoading && ::utl::LocalFileHelper::IsLocalFile( aLogicName ) ) + { + // let the stream be opened to check the possibility to open it for editing + GetMedium_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 ) { try { @@ -1244,11 +1255,12 @@ sal_Bool SfxMedium::LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI ) {} } + // do further checks only if the file not readonly in fs if ( !bContentReadonly ) { + // the special file locking should be used only for file URLs if ( ::utl::LocalFileHelper::IsLocalFile( aLogicName ) ) { - // the special file locking should be used only for file URLs // in case of storing the document should request the output before locking if ( bLoading ) diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx index 7df93afaa63e..099e649506c0 100644 --- a/sfx2/source/doc/doctemplates.cxx +++ b/sfx2/source/doc/doctemplates.cxx @@ -72,6 +72,7 @@ #include "sfxurlrelocator.hxx" #include "doctemplateslocal.hxx" #include +#include #include "doc.hrc" //----------------------------------------------------------------------------- @@ -909,7 +910,8 @@ sal_Bool SfxDocTplService_Impl::CreateNewUniqueFolderWithPrefix( const ::rtl::OU Content aParent; - if ( Content::create( aDirPath.GetMainURL( INetURLObject::NO_DECODE ), maCmdEnv, aParent ) ) + uno::Reference< XCommandEnvironment > aQuietEnv; + if ( Content::create( aDirPath.GetMainURL( INetURLObject::NO_DECODE ), aQuietEnv, aParent ) ) { for ( sal_Int32 nInd = 0; nInd < 32000; nInd++ ) { @@ -1919,7 +1921,11 @@ sal_Bool SfxDocTplService_Impl::storeTemplate( const OUString& rGroupName, aStoreArgs[1].Name = ::rtl::OUString::createFromAscii( "DocumentTitle" ); aStoreArgs[1].Value <<= rTemplateName; - rStorable->storeToURL( aNewTemplateTargetURL, aStoreArgs ); + ::rtl::OUString aCurrentDocumentURL = rStorable->getLocation(); + if( !SfxMedium::EqualURLs( aNewTemplateTargetURL, rStorable->getLocation() )) + rStorable->storeToURL( aNewTemplateTargetURL, aStoreArgs ); + else + rStorable->store(); // the storing was successful, now the old template with the same name can be removed if it existed if ( aTemplateToRemoveTargetURL.getLength() ) diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx index f1e6cc80812e..bd0e65830870 100644 --- a/sfx2/source/doc/graphhelp.cxx +++ b/sfx2/source/doc/graphhelp.cxx @@ -374,32 +374,7 @@ sal_Bool GraphicHelper::createThumb_Impl( const GDIMetaFile& rMtf, if ( aBmp.GetBitCount() != 24 ) aBmp.Convert( BMP_CONVERSION_24BIT ); - // create resulting mask bitmap with metafile output set to black - GDIMetaFile aMonchromeMtf( rMtf.GetMonochromeMtf( COL_BLACK ) ); - aVDev.DrawWallpaper( Rectangle( aNullPt, aSizePix ), Wallpaper( Color( COL_WHITE ) ) ); - aMonchromeMtf.WindStart(); - aMonchromeMtf.Play( &aVDev, aBackPosPix, aDrawSize ); - - // watch for overlay mask - if ( pOverlay ) - { - Bitmap aOverlayMergeBmp( aVDev.GetBitmap( aOverlayRect.TopLeft(), aOverlayRect.GetSize() ) ); - - // create ANDed resulting mask at overlay area - if ( pOverlay->IsTransparent() ) - aVDev.DrawBitmap( aOverlayRect.TopLeft(), aOverlayRect.GetSize(), pOverlay->GetMask() ); - else - { - aVDev.SetLineColor( COL_BLACK ); - aVDev.SetFillColor( COL_BLACK ); - aVDev.DrawRect( aOverlayRect); - } - - aOverlayMergeBmp.CombineSimple( aVDev.GetBitmap( aOverlayRect.TopLeft(), aOverlayRect.GetSize() ), BMP_COMBINE_AND ); - aVDev.DrawBitmap( aOverlayRect.TopLeft(), aOverlayRect.GetSize(), aOverlayMergeBmp ); - } - - rBmpEx = BitmapEx( aBmp, aVDev.GetBitmap( aNullPt, aVDev.GetOutputSizePixel() ) ); + rBmpEx = BitmapEx( aBmp ); } return !rBmpEx.IsEmpty(); -- cgit From ac49eeddaf88a0002901b078ca64a7d6a4068c30 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Thu, 17 Sep 2009 13:53:54 +0000 Subject: CWS-TOOLING: integrate CWS encsig09 2009-09-14 15:11:29 +0200 oc r276125 : #i105049# MacroSignatur needs Macro 2009-09-09 17:09:46 +0200 jl r276005 : #i103989# could not signe encrypted doc containing a formular object 2009-09-09 13:11:24 +0200 jl r275985 : #i103989# could not signe encrypted doc containing a formular object 2009-09-08 15:54:02 +0200 mav r275934 : #i103906# fix the automation test scenario ( tempfile should be writable for the user ) 2009-09-07 14:01:39 +0200 mav r275895 : #i103906# fix the problem with reload 2009-09-07 09:34:48 +0200 mav r275871 : #i104786# do the ODF version check only for ODF documents 2009-09-07 08:19:06 +0200 mav r275870 : #i104389# fix text 2009-09-06 22:24:21 +0200 mav r275867 : #i104786# check the consistency of ODF version 2009-09-06 22:23:24 +0200 mav r275866 : #i104786# check the consistency of ODF version 2009-09-06 22:23:00 +0200 mav r275865 : #i104786# check the consistency of ODF version 2009-09-06 22:22:36 +0200 mav r275864 : #i104786# check the consistency of ODF version 2009-09-06 22:22:03 +0200 mav r275863 : #i104786# check the consistency of ODF version 2009-09-02 17:09:30 +0200 mav r275722 : #i104715# let repairing mechanics use the streams correctly 2009-09-01 16:52:49 +0200 mav r275670 : #i104389# notify user not to trust the corrupted document 2009-09-01 16:31:37 +0200 mav r275668 : #i104389# use vnd.sun.star.zip: protocol to access zip files 2009-09-01 16:30:32 +0200 mav r275667 : #i104389# use vnd.sun.star.zip: protocol to access zip files 2009-09-01 16:22:13 +0200 jl r275666 : #i104339# small content change 2009-09-01 14:20:42 +0200 jl r275660 : #i103519# remove some debug output 2009-09-01 13:51:52 +0200 jl r275659 : #i103519# NSS uses '\' for escaping in distinguished names 2009-09-01 12:49:47 +0200 mav r275655 : #i104389# use zip-mode to read from jar files 2009-09-01 12:40:22 +0200 mav r275653 : #i104389# use zip-mode to read from jar files 2009-09-01 12:32:29 +0200 mav r275652 : #i104389# use constants 2009-08-31 21:58:00 +0200 mav r275637 : #i10000# fix warning 2009-08-31 21:11:17 +0200 mav r275636 : #i104227# adding of scripting signature removes the document signature 2009-08-31 20:55:05 +0200 mav r275635 : #i103905# ZipStorage supports Compressed property 2009-08-31 20:53:55 +0200 mav r275634 : #i103905# adjust macro signature transfer to usage of ZipStorage 2009-08-31 15:30:49 +0200 jl r275609 : #i103989# warning is shown as long the user does not click 'OK' 2009-08-31 14:36:10 +0200 jl r275608 : #i103989# changed warning text when signing macro and there is a document signature. This warning is only displayed once 2009-08-31 13:34:41 +0200 mav r275603 : #i104452# disable macros in repaired documents 2009-08-31 13:33:42 +0200 mav r275602 : #i104452# disable macros in repaired documents 2009-08-31 13:03:56 +0200 jl r275600 : #i45212# signature dialog could not be started when using read-only documents 2009-08-31 09:26:13 +0200 mav r275583 : #i104578# store the additional entry as the last one to workaround parsing problem in OOo3.1 and later 2009-08-30 20:54:25 +0200 mav r275562 : #i10000# adopt for unix 2009-08-30 10:56:00 +0200 mav r275561 : CWS-TOOLING: rebase CWS encsig09 to trunk@275331 (milestone: DEV300:m56) 2009-08-28 16:34:00 +0200 mav r275539 : #i104578# write necessary info in manifest.xml for ODF1.2 encrypted document 2009-08-28 14:04:22 +0200 mav r275533 : #104587# fix handling of readonly streams 2009-08-28 13:58:10 +0200 mav r275531 : #i104389# fix the broken document handling 2009-08-28 11:40:39 +0200 mav r275522 : #i104389# fix the signature streams check 2009-08-27 21:48:12 +0200 mav r275509 : #i103927# show the warning 2009-08-27 21:47:48 +0200 mav r275508 : #i103927# show the warning 2009-08-27 16:45:59 +0200 jl r275495 : #i45212# remove unused variable 2009-08-27 16:34:00 +0200 jl r275494 : #i103989# 2009-08-27 13:54:28 +0200 jl r275482 : #i103519# fixed replacement of 'S' by 'ST' 2009-08-27 12:32:21 +0200 mav r275472 : #i10000# fix warning 2009-08-27 11:58:11 +0200 mav r275467 : #i104389# handle the entry path correctly 2009-08-26 17:18:35 +0200 jl r275438 : #i103519# subject and issuer distinguished names were not properly displayed. The strings were obtained by system functions (Windows, NSS), which use quotes to escape the values, when they contain special characters 2009-08-26 11:00:20 +0200 mav r275403 : #i10000# fix warnings 2009-08-26 08:25:45 +0200 mav r275392 : #i10000# fix warning 2009-08-26 08:02:22 +0200 mav r275391 : #i10000# adopt for linux 2009-08-26 07:40:30 +0200 mav r275390 : #i10000# fix warning 2009-08-26 07:35:28 +0200 mav r275389 : #i10000# use correct include file name 2009-08-25 15:01:41 +0200 jl r275356 : #i103989# better check for mimetype of streams 2009-08-25 09:07:09 +0200 mav r275335 : CWS-TOOLING: rebase CWS encsig09 to trunk@274622 (milestone: DEV300:m54) 2009-08-24 18:17:02 +0200 mav r275329 : #i103927# check the nonencrypted streams 2009-08-24 18:14:14 +0200 mav r275328 : #i103927# check the nonencrypted streams 2009-08-24 17:59:34 +0200 mav r275327 : #i103927#,#i104389# check the package consistency and nonencrypted streams 2009-08-24 16:18:28 +0200 jl r275323 : #i103989# added comment 2009-08-24 13:08:47 +0200 jl r275305 : #i45212# #i66276# only write the X509Certificate element once and allow to add remove several certificates at a time 2009-08-21 12:57:28 +0200 ufi r275239 : 104339 2009-08-21 08:39:05 +0200 jl r275213 : #i10398# comparing URIs of signed files with the 'element list' 2009-08-20 13:39:47 +0200 jl r275178 : #i10398# displaying 'new partially signed' status in the status bar 2009-08-20 13:35:39 +0200 jl r275177 : #i10398# displaying 'new partially signed' status in the status bar 2009-08-20 13:29:06 +0200 jl r275176 : #i10398# displaying 'new partially signed' status in the status bar 2009-08-20 13:26:21 +0200 jl r275175 : #i10398# displaying 'new partially signed' status in the status bar 2009-08-20 12:05:09 +0200 ufi r275170 : i104339 2009-08-19 12:24:54 +0200 jl r275146 : #i10398# displaying 'old signature' icon and status in signature dialog 2009-08-18 15:18:48 +0200 jl r275111 : #i103989# document signatures containing manifest.xml are now validated according to the final ODF1.2 spec 2009-08-18 11:41:06 +0200 mav r275087 : #i103927# detect if encrypted ODF1.2 document contains nonencrypted streams 2009-08-18 11:35:13 +0200 mav r275085 : #i103927# detect if encrypted ODF1.2 document contains nonencrypted streams 2009-08-14 17:32:41 +0200 jl r274999 : #i103989# using c14n tranformation for XML streams 2009-08-14 15:27:43 +0200 jl r274987 : #i103989# remove special handling for encrypted document streams in UriBindingHelper::OpenInputStream, since we use zip storage this is not necessary anymore 2009-08-14 15:08:10 +0200 jl r274983 : #i103989# Showing a message when adding or removing a macro signature, that the document signature will be removed 2009-08-14 14:57:27 +0200 jl r274982 : #i103989# accesing Sequence at invalid index 2009-08-11 08:55:02 +0200 mav r274846 : #i103905# let signing service know if there is already a valid document signature 2009-08-10 11:33:37 +0200 jl r274799 : #i103905# do not truncate the stream 2009-08-10 10:43:47 +0200 mav r274797 : #i103905# provide the storage version 2009-08-07 16:58:46 +0200 jl r274780 : #i103989# 2009-08-07 16:56:19 +0200 jl r274779 : #i103989# using odf version string etc. 2009-08-07 15:20:53 +0200 mav r274771 : #i103905# provide the storage version 2009-08-07 15:19:12 +0200 mav r274770 : #i103905# provide the storage version 2009-08-07 12:41:45 +0200 mav r274758 : #103930# do not store thumbnail in case of encrypted document 2009-08-07 12:36:52 +0200 mav r274757 : #i103905# provide the storage version 2009-08-07 12:15:54 +0200 mav r274754 : #i103760# the signed state is not lost on saving 2009-08-07 12:06:19 +0200 mav r274753 : #i103760# avoid warning regarding signature removal on export 2009-08-07 12:06:01 +0200 mav r274752 : #i103760# avoid warning regarding signature removal on export 2009-08-06 08:47:34 +0200 mav r274703 : #i103905# allow to transport ODF version to the signing component 2009-08-05 21:34:42 +0200 mav r274701 : #i103905# allow to transport ODF version to the signing component 2009-08-05 15:48:17 +0200 mav r274683 : #i103905# allow to transport ODF version to the signing component 2009-08-05 14:58:12 +0200 jl r274673 : #i103989# documentsignature now signes all streams except documentsignatures.xml, all streams are processed as binary files 2009-08-05 12:00:32 +0200 mav r274648 : #i103905# allow to transport ODF version to the signing component 2009-08-04 10:57:04 +0200 jl r274612 : #i103989# added XInitialization 2009-07-31 10:32:27 +0200 mav r274516 : #i103905# use zip storage to sign documents 2009-07-30 14:01:33 +0200 mav r274489 : #i103906# optimize the usage of temporary medium 2009-07-30 14:00:28 +0200 mav r274488 : #i103906# optimize the usage of temporary medium 2009-07-30 13:59:09 +0200 mav r274487 : #i103906# optimize the usage of temporary medium 2009-07-30 13:50:44 +0200 mav r274485 : #i103906# optimize the usage of temporary medium 2009-07-30 13:49:53 +0200 mav r274484 : #i103906# optimize the usage of temporary medium 2009-07-30 13:49:13 +0200 mav r274483 : #i103906# optimize the usage of temporary medium 2009-07-30 13:47:09 +0200 mav r274482 : #i103905#,#i103906# let the signing process use zip-storage; optimize the usage of temporary medium 2009-07-21 09:10:31 +0200 mav r274159 : CWS-TOOLING: rebase CWS encsig09 to trunk@273468 (milestone: DEV300:m51) 2009-05-05 08:39:01 +0200 mav r271496 : #i100832# allow to sign macros only when there are any --- sfx2/inc/guisaveas.hxx | 4 +- sfx2/inc/sfx2/docfile.hxx | 25 +- sfx2/inc/sfx2/docmacromode.hxx | 24 +- sfx2/inc/sfx2/objsh.hxx | 15 +- sfx2/inc/sfx2/signaturestate.hxx | 9 +- sfx2/source/appl/appopen.cxx | 4 +- sfx2/source/bastyp/helper.cxx | 33 -- sfx2/source/bastyp/progress.cxx | 14 +- sfx2/source/dialog/dinfdlg.cxx | 2 +- sfx2/source/doc/docfile.cxx | 963 +++++++++++++-------------------------- sfx2/source/doc/docmacromode.cxx | 197 +++----- sfx2/source/doc/guisaveas.cxx | 23 +- sfx2/source/doc/objmisc.cxx | 137 +++++- sfx2/source/doc/objserv.cxx | 139 +++--- sfx2/source/doc/objstor.cxx | 202 ++++---- sfx2/source/doc/objxtor.cxx | 3 +- sfx2/source/doc/sfxbasemodel.cxx | 12 +- sfx2/source/inc/helper.hxx | 1 - sfx2/source/inc/objshimp.hxx | 9 +- sfx2/source/view/viewfrm.cxx | 8 +- 20 files changed, 775 insertions(+), 1049 deletions(-) (limited to 'sfx2') diff --git a/sfx2/inc/guisaveas.hxx b/sfx2/inc/guisaveas.hxx index 772c3f7c5304..f8b19e1d5754 100644 --- a/sfx2/inc/guisaveas.hxx +++ b/sfx2/inc/guisaveas.hxx @@ -41,6 +41,7 @@ #include #include +#include namespace com { namespace sun { namespace star { @@ -78,7 +79,8 @@ public: const ::rtl::OUString& aSlotName, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgsSequence, sal_Bool bPreselectPassword, - ::rtl::OUString aUserSelectedName ); + ::rtl::OUString aUserSelectedName, + sal_uInt16 nDocumentSignatureState = SIGNATURESTATE_NOSIGNATURES ); static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SearchForFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerQuery >& xFilterQuery, diff --git a/sfx2/inc/sfx2/docfile.hxx b/sfx2/inc/sfx2/docfile.hxx index bebcdc684d89..e8ae3f5d1d85 100644 --- a/sfx2/inc/sfx2/docfile.hxx +++ b/sfx2/inc/sfx2/docfile.hxx @@ -199,8 +199,6 @@ public: void SetDataAvailableLink( const Link& rLink ); Link GetDataAvailableLink( ) const; - void SetClassFilter( const SvGlobalName & rFilterClass ); - sal_uInt32 GetMIMEAndRedirect( String& ); sal_uInt32 GetErrorCode() const; sal_uInt32 GetError() const @@ -227,17 +225,14 @@ public: SvEaMgr* GetEaMgr(); sal_Bool Commit(); - sal_Bool TryStorage(); - SAL_DLLPRIVATE ErrCode Unpack_Impl( const String& ); sal_Bool IsStorage(); 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(); - ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetStorage(); + ::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(); - const SvGlobalName& GetClassFilter(); void ResetError(); sal_Bool UsesCache() const; void SetUsesCache( sal_Bool ); @@ -253,9 +248,8 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > GetInputStream(); - void CreateTempFile(); + void CreateTempFile( sal_Bool bReplace = sal_True ); void CreateTempFileNoCopy(); - void TryToSwitchToRepairedTemp(); ::rtl::OUString SwitchDocumentToTempFile(); sal_Bool SwitchDocumentToFile( ::rtl::OUString aURL ); @@ -264,24 +258,19 @@ public: ::rtl::OUString GetBaseURL( bool bForSaving=false ); #if _SOLAR__PRIVATE -//REMOVE // the storage will be truncated, if it is still not open then the stream will be truncated -//REMOVE ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetOutputStorage_Impl(); - SAL_DLLPRIVATE ::rtl::OUString GetOutputStorageURL_Impl(); SAL_DLLPRIVATE BOOL HasStorage_Impl() const; - SAL_DLLPRIVATE sal_Bool BasedOnOriginalFile_Impl(); SAL_DLLPRIVATE void StorageBackup_Impl(); SAL_DLLPRIVATE ::rtl::OUString GetBackup_Impl(); - SAL_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetLastCommitReadStorage_Impl(); - SAL_DLLPRIVATE void CloseReadStorage_Impl(); + SAL_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetZipStorageToSign_Impl( sal_Bool bReadOnly = sal_True ); + SAL_DLLPRIVATE void CloseZipStorage_Impl(); // the storage that will be returned by the medium on GetStorage request SAL_DLLPRIVATE void SetStorage_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xNewStorage ); SAL_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > GetInputStream_Impl(); SAL_DLLPRIVATE void CloseAndReleaseStreams_Impl(); -//REMOVE SvStorage* GetStorage_Impl( BOOL bUCBStorage ); SAL_DLLPRIVATE void RefreshName_Impl(); SAL_DLLPRIVATE sal_uInt16 AddVersion_Impl( com::sun::star::util::RevisionTag& rVersion ); SAL_DLLPRIVATE sal_Bool TransferVersionList_Impl( SfxMedium& rMedium ); @@ -320,7 +309,6 @@ public: SAL_DLLPRIVATE void DataAvailable_Impl(); SAL_DLLPRIVATE void Cancel_Impl(); SAL_DLLPRIVATE void SetPhysicalName_Impl(const String& rName); - SAL_DLLPRIVATE void MoveTempTo_Impl( SfxMedium* pMedium ); SAL_DLLPRIVATE void CanDisposeStorage_Impl( sal_Bool bDisposeStorage ); SAL_DLLPRIVATE sal_Bool WillDisposeStorageOnClose_Impl(); @@ -340,7 +328,7 @@ public: const INetURLObject& aDest, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xComEnv ); - SAL_DLLPRIVATE sal_Bool SignContents_Impl( sal_Bool bScriptingContent ); + SAL_DLLPRIVATE sal_Bool SignContents_Impl( sal_Bool bScriptingContent, const ::rtl::OUString& aODFVersion, sal_Bool bHasValidDocumentSignature ); // the following two methods must be used and make sence only during saving currently // TODO/LATER: in future the signature state should be controlled by the medium not by the document @@ -353,6 +341,9 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); static sal_Bool EqualURLs( const ::rtl::OUString& aFirstURL, const ::rtl::OUString& aSecondURL ); static ::rtl::OUString CreateTempCopyWithExt( const ::rtl::OUString& aURL ); + static sal_Bool CallApproveHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler, ::com::sun::star::uno::Any aRequest, sal_Bool bAllowAbort ); + + static sal_Bool SetWritableForUserOnly( const ::rtl::OUString& aURL ); }; SV_DECL_IMPL_REF( SfxMedium ) diff --git a/sfx2/inc/sfx2/docmacromode.hxx b/sfx2/inc/sfx2/docmacromode.hxx index 4f0f1d2f9d9b..79d0cb016104 100644 --- a/sfx2/inc/sfx2/docmacromode.hxx +++ b/sfx2/inc/sfx2/docmacromode.hxx @@ -114,10 +114,11 @@ namespace sfx2 virtual ::rtl::OUString getDocumentLocation() const = 0; - /** returns the storage to which the document has last been committed to, for read-only - access + /** returns a zip-storage based on the last commited version of the document, + for readonly access - An implementation is allowed to return here if and only if the document + The storage is intended to be used for signing. An implementation is + allowed to return here if and only if the document does not support signing the script storages. @todo @@ -126,7 +127,7 @@ namespace sfx2 XStorageBasedDocument. */ virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > - getLastCommitDocumentStorage() = 0; + getZipStorageToSign() = 0; /** checks whether the document's storage contains sub storages with macros or scripts @@ -161,7 +162,20 @@ namespace sfx2 @seealso */ virtual sal_Int16 - getScriptingSignatureState() const = 0; + getScriptingSignatureState() = 0; + + /** allows to detect whether there is a trusted scripting signature + + Note: On the medium run, the signature handling of a document should be outsourced + into a dedicated class, instead of being hard-wired into the SfxObjectShell. This + class could then be used outside the SfxObjectShell (e.g. in Base documents), too. + When this happens, this method here should be replaced by a method at this + new class. + + @seealso + */ + virtual sal_Bool + hasTrustedScriptingSignature( sal_Bool bAllowUIToAddAuthor ) = 0; /** shows a warning that the document's signature is broken diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 71f1729840c0..56369a8ea936 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -236,10 +237,6 @@ private: //REMOVE sal_Bool SaveInfoAndConfig_Impl( SvStorageRef pNewStg ); - SAL_DLLPRIVATE sal_uInt16 ImplCheckSignaturesInformation( - const ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation >& aInfos ); - - //#endif protected: @@ -733,6 +730,9 @@ public: SAL_DLLPRIVATE void BreakMacroSign_Impl( sal_Bool bBreakMacroSing ); SAL_DLLPRIVATE void CheckSecurityOnLoading_Impl(); SAL_DLLPRIVATE void CheckForBrokenDocSignatures_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ); + SAL_DLLPRIVATE sal_uInt16 ImplCheckSignaturesInformation( + const ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation >& aInfos ); + SAL_DLLPRIVATE void CheckEncryption_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ); SAL_DLLPRIVATE static SEQUENCE< OUSTRING > GetEventNames_Impl(); SAL_DLLPRIVATE void InitBasicManager_Impl(); @@ -797,6 +797,13 @@ public: SAL_DLLPRIVATE SfxAcceleratorManager* GetAccMgr_Impl(); SAL_DLLPRIVATE SfxToolBoxConfig* GetToolBoxConfig_Impl(); SAL_DLLPRIVATE sal_uInt16 ImplGetSignatureState( sal_Bool bScriptingContent = FALSE ); + + SAL_DLLPRIVATE ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation > + ImplAnalyzeSignature( + sal_Bool bScriptingContent, + const ::com::sun::star::uno::Reference< ::com::sun::star::security::XDocumentDigitalSignatures >& xSigner + = ::com::sun::star::uno::Reference< ::com::sun::star::security::XDocumentDigitalSignatures >() ); + SAL_DLLPRIVATE void ImplSign( sal_Bool bScriptingContent = FALSE ); SAL_DLLPRIVATE sal_Bool QuerySaveSizeExceededModules_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ); //#endif diff --git a/sfx2/inc/sfx2/signaturestate.hxx b/sfx2/inc/sfx2/signaturestate.hxx index 48c06fee623b..be035ef25818 100644 --- a/sfx2/inc/sfx2/signaturestate.hxx +++ b/sfx2/inc/sfx2/signaturestate.hxx @@ -36,7 +36,12 @@ #define SIGNATURESTATE_NOSIGNATURES (sal_Int16)0 #define SIGNATURESTATE_SIGNATURES_OK (sal_Int16)1 #define SIGNATURESTATE_SIGNATURES_BROKEN (sal_Int16)2 -#define SIGNATURESTATE_SIGNATURES_INVALID (sal_Int16)3 // State was SIGNATURES_OK, but doc is modified now -#define SIGNATURESTATE_SIGNATURES_NOTVALIDATED (sal_Int16)4 // signature is OK, but certificate could not be validated +// State was SIGNATURES_OK, but doc is modified now +#define SIGNATURESTATE_SIGNATURES_INVALID (sal_Int16)3 +// signature is OK, but certificate could not be validated +#define SIGNATURESTATE_SIGNATURES_NOTVALIDATED (sal_Int16)4 +//signatur and certificate are ok,but not al files are signed, as was the case in +//OOo 2.x - OOo 3.1.1. This state is only used together with document signatures. +#define SIGNATURESTATE_SIGNATURES_PARTIAL_OK (sal_Int16)5 #endif // SFX2_SIGNATURESTATE_HXX diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 85f38abf284c..c6cb16f8f3f6 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -311,7 +311,7 @@ sal_uInt32 CheckPasswd_Impl if( ( !pFile->GetFilter() || pFile->IsStorage() ) ) { - uno::Reference< embed::XStorage > xStorage = pFile->GetStorage(); + uno::Reference< embed::XStorage > xStorage = pFile->GetStorage( sal_True ); if( xStorage.is() ) { uno::Reference< beans::XPropertySet > xStorageProps( xStorage, uno::UNO_QUERY ); @@ -392,7 +392,7 @@ ULONG SfxApplication::LoadTemplate( SfxObjectShellLock& xDoc, const String &rFil const SfxFilter* pFilter = NULL; SfxMedium aMedium( rFileName, ( STREAM_READ | STREAM_SHARE_DENYNONE ), FALSE ); - if ( !aMedium.GetStorage().is() ) + if ( !aMedium.GetStorage( sal_True ).is() ) aMedium.GetInStream(); if ( aMedium.GetError() ) diff --git a/sfx2/source/bastyp/helper.cxx b/sfx2/source/bastyp/helper.cxx index 258170789c2f..3c0adfd5c873 100644 --- a/sfx2/source/bastyp/helper.cxx +++ b/sfx2/source/bastyp/helper.cxx @@ -819,39 +819,6 @@ ULONG SfxContentHelper::GetSize( const String& rContent ) return nSize; } -// ----------------------------------------------------------------------- - -sal_Bool SfxContentHelper::IsYounger( const String& rIsYoung, const String& rIsOlder ) -{ - DateTime aYoungDate, aOlderDate; - INetURLObject aYoungObj( rIsYoung ); - DBG_ASSERT( aYoungObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); - INetURLObject aOlderObj( rIsOlder ); - DBG_ASSERT( aOlderObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); - try - { - uno::Reference< ucb::XCommandEnvironment > aCmdEnv; - ::ucbhelper::Content aYoung( aYoungObj.GetMainURL( INetURLObject::NO_DECODE ), aCmdEnv ); - util::DateTime aTempYoungDate; - aYoung.getPropertyValue( OUString::createFromAscii( "DateModified" ) ) >>= aTempYoungDate; - CONVERT_DATETIME( aTempYoungDate, aYoungDate ); - ::ucbhelper::Content aOlder( aOlderObj.GetMainURL( INetURLObject::NO_DECODE ), aCmdEnv ); - util::DateTime aTempOlderDate; - aOlder.getPropertyValue( OUString::createFromAscii( "DateModified" ) ) >>= aTempOlderDate; - CONVERT_DATETIME( aTempOlderDate, aOlderDate ); - } - catch( ucb::CommandAbortedException& ) - { - DBG_ERRORFILE( "CommandAbortedException" ); - } - catch( uno::Exception& ) - { - DBG_ERRORFILE( "Any other exception" ); - } - - return ( aYoungDate > aOlderDate ); -} - // ----------------------------------------------------------------------- // please don't use it (only used in appbas.cxx and appcfg.cxx) sal_Bool SfxContentHelper::Exists( const String& rContent ) diff --git a/sfx2/source/bastyp/progress.cxx b/sfx2/source/bastyp/progress.cxx index 62bc5533e1a9..121b8604e02d 100644 --- a/sfx2/source/bastyp/progress.cxx +++ b/sfx2/source/bastyp/progress.cxx @@ -117,20 +117,8 @@ struct SfxProgress_Impl : public SfxCancellable #define aTypeLibInfo aProgressTypeLibImpl //======================================================================== -#if defined(_MSC_VER) && (_MSC_VER < 1300) -inline ULONG Get10ThSec() -{ -#if defined (MSC) && defined (WIN) - ULONG n10Ticks = 10 * (ULONG)GetTickCount(); -#else - ULONG n10Ticks = 10 * (ULONG)clock(); -#endif - - return n10Ticks / CLOCKS_PER_SEC; -} -#else extern ULONG Get10ThSec(); -#endif + // ----------------------------------------------------------------------- void SfxProgress_Impl::Enable_Impl( BOOL bEnable ) diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 6de52384a90c..38808c36c7be 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -899,7 +899,7 @@ void SfxDocumentPage::ImplUpdateSignatures() { String s; Sequence< security::DocumentSignatureInformation > aInfos; - aInfos = xD->verifyDocumentContentSignatures( pMedium->GetLastCommitReadStorage_Impl(), + aInfos = xD->verifyDocumentContentSignatures( pMedium->GetZipStorageToSign_Impl(), uno::Reference< io::XInputStream >() ); if( aInfos.getLength() > 1 ) { diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 3fec8e40bfb7..32ae33ec3c8b 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -84,6 +84,7 @@ #include #include #include +#include #include #include #ifndef _MSGBOX_HXX //autogen @@ -106,6 +107,7 @@ #include #include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -373,10 +375,9 @@ public: uno::Sequence < util::RevisionTag > aVersions; - ::utl::TempFile* pTempDir; ::utl::TempFile* pTempFile; - uno::Reference < embed::XStorage > m_xReadStorage; + uno::Reference < embed::XStorage > m_xZipStorage; Reference < XInputStream > xInputStream; Reference < XStream > xStream; @@ -452,7 +453,6 @@ SfxMedium_Impl::SfxMedium_Impl( SfxMedium* pAntiImplP ) nFileVersion( 0 ), pOrigFilter( 0 ), aExpireTime( Date() + 10, Time() ), - pTempDir( NULL ), pTempFile( NULL ), nLastStorageError( 0 ), m_bRemoveBackup( sal_False ), @@ -470,9 +470,6 @@ SfxMedium_Impl::~SfxMedium_Impl() if ( pTempFile ) delete pTempFile; - - if ( pTempDir ) - delete pTempDir; } //================================================================ @@ -490,18 +487,6 @@ SfxMedium_Impl::~SfxMedium_Impl() pInStream(0), \ pOutStream( 0 ) -//------------------------------------------------------------------ -/* -const SvGlobalName& SfxMedium::GetClassFilter() -{ - GetMedium_Impl(); - if( GetError() ) - return aFilterClass; - if( !bSetFilter && GetStorage() ) - SetClassFilter( GetStorage()->GetClassName() ); - return aFilterClass; -}*/ - //------------------------------------------------------------------ void SfxMedium::ResetError() { @@ -556,15 +541,6 @@ sal_uInt32 SfxMedium::GetErrorCode() const return lError; } -//------------------------------------------------------------------ -long SfxMedium::GetFileVersion() const -{ - if ( !pImp->nFileVersion && pFilter ) - return pFilter->GetVersion(); - else - return pImp->nFileVersion; -} - //------------------------------------------------------------------ void SfxMedium::CheckFileDate( const util::DateTime& aInitDate ) { @@ -665,6 +641,7 @@ Reference < XContent > SfxMedium::GetContent() const return pImp->aContent.get(); } +//------------------------------------------------------------------ ::rtl::OUString SfxMedium::GetBaseURL( bool bForSaving ) { ::rtl::OUString aBaseURL; @@ -703,7 +680,7 @@ SvStream* SfxMedium::GetInStream() if ( pInStream ) return pInStream; - if ( pImp->pTempFile || pImp->pTempDir ) + if ( pImp->pTempFile ) { pInStream = new SvFileStream( aName, nStorOpenMode ); @@ -747,7 +724,7 @@ void SfxMedium::CloseInStream_Impl() if ( pInStream && !GetContent().is() ) { - CreateTempFile(); + CreateTempFile( sal_True ); return; } @@ -755,7 +732,7 @@ void SfxMedium::CloseInStream_Impl() if ( pSet ) pSet->ClearItem( SID_INPUTSTREAM ); - CloseReadStorage_Impl(); + CloseZipStorage_Impl(); pImp->xInputStream = uno::Reference< io::XInputStream >(); if ( !pOutStream ) @@ -775,8 +752,7 @@ SvStream* SfxMedium::GetOutStream() { // Create a temp. file if there is none because we always // need one. - if ( !pImp->pTempFile ) - CreateTempFile(); + CreateTempFile( sal_False ); if ( pImp->pTempFile ) { @@ -844,8 +820,7 @@ void SfxMedium::CreateFileStream() GetInStream(); if( pInStream ) { - if ( !pImp->pTempFile ) - CreateTempFile(); + CreateTempFile( sal_False ); pImp->bIsTemp = sal_True; CloseInStream_Impl(); } @@ -941,83 +916,18 @@ sal_Bool SfxMedium::IsPreview_Impl() return bPreview; } -//------------------------------------------------------------------ -sal_Bool SfxMedium::TryStorage() -{ - GetStorage(); - - if ( pImp->xStorage.is() ) - return sal_True; - - // this code will be removed when binary filter components are available! - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMgr( ::comphelper::getProcessServiceFactory() ); - ::com::sun::star::uno::Reference< ::com::sun::star::util::XArchiver > - xPacker( xSMgr->createInstance( DEFINE_CONST_UNICODE( "com.sun.star.util.Archiver" ) ), ::com::sun::star::uno::UNO_QUERY ); - - if( !xPacker.is() ) - return sal_False; - - // extract extra data - ::rtl::OUString aPath = GetURLObject().PathToFileName(); - ::rtl::OUString aExtraData = xPacker->getExtraData( aPath ); - const ::rtl::OUString aSig1( DEFINE_CONST_UNICODE( "private:" ) ); - String aTmp( '?' ); - aTmp += String::CreateFromAscii("simpress");//pFilter->GetFilterContainer()->GetName(); - const ::rtl::OUString aSig2( aTmp ); - sal_Int32 nIndex1 = aExtraData.indexOf( aSig1 ); - sal_Int32 nIndex2 = aExtraData.indexOf( aSig2 ); - - if( nIndex1 != 0 || nIndex2 == -1 ) - return sal_False; - - nIndex1 += aSig1.getLength(); - ::rtl::OUString aTempDoku = aExtraData.copy( nIndex1, nIndex2 - nIndex1 ); - - // create a temp dir to unpack to - pImp->pTempDir = new ::utl::TempFile( NULL, sal_True ); - pImp->pTempDir->EnableKillingFile( sal_True ); - - // unpack all files to temp dir - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs; - com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler > xInteractionHandler = GetInteractionHandler(); - if (xInteractionHandler.is()) - { - aArgs.realloc(1); - aArgs.getArray()[0].Name = DEFINE_CONST_UNICODE( "InteractionHandler" ); - aArgs.getArray()[0].Value <<= xInteractionHandler ; - } - ::com::sun::star::uno::Sequence< ::rtl::OUString > files(0); - - if( !xPacker->unpack( pImp->pTempDir->GetURL(), aPath, files, aArgs ) ) - return sal_False; - - String aNewName = pImp->pTempDir->GetURL(); - aNewName += '/'; - aNewName += String( aTempDoku ); - CloseInStream_Impl(); - String aTemp; - ::utl::LocalFileHelper::ConvertURLToPhysicalName( aNewName, aTemp ); - SetPhysicalName_Impl( aTemp ); - GetStorage(); - - return pImp->xStorage.is(); -} - -//------------------------------------------------------------------ -sal_Bool SfxMedium::BasedOnOriginalFile_Impl() -{ - return ( !pImp->pTempFile && !( aLogicName.Len() && pImp->m_bSalvageMode ) - && GetURLObject().GetMainURL( INetURLObject::NO_DECODE ).getLength() - && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) - && ::utl::UCBContentHelper::IsDocument( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) ); -} - //------------------------------------------------------------------ void SfxMedium::StorageBackup_Impl() { ::ucbhelper::Content aOriginalContent; Reference< ::com::sun::star::ucb::XCommandEnvironment > xDummyEnv; - if ( BasedOnOriginalFile_Impl() && !pImp->m_aBackupURL.getLength() + + sal_Bool bBasedOnOriginalFile = ( !pImp->pTempFile && !( aLogicName.Len() && pImp->m_bSalvageMode ) + && GetURLObject().GetMainURL( INetURLObject::NO_DECODE ).getLength() + && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) + && ::utl::UCBContentHelper::IsDocument( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) ); + + if ( bBasedOnOriginalFile && !pImp->m_aBackupURL.getLength() && ::ucbhelper::Content::create( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv, aOriginalContent ) ) { DoInternalBackup_Impl( aOriginalContent ); @@ -1035,26 +945,6 @@ void SfxMedium::StorageBackup_Impl() return pImp->m_aBackupURL; } -//------------------------------------------------------------------ -::rtl::OUString SfxMedium::GetOutputStorageURL_Impl() -{ - String aStorageName; - - if ( aName.Len() ) - { - if ( !::utl::LocalFileHelper::ConvertPhysicalNameToURL( aName, aStorageName ) ) - { - DBG_ERROR("Physical name not convertable!"); - } - } - else - { - aStorageName = GetURLObject().GetMainURL( INetURLObject::NO_DECODE ); - } - - return aStorageName; -} - //------------------------------------------------------------------ uno::Reference < embed::XStorage > SfxMedium::GetOutputStorage() { @@ -1249,7 +1139,9 @@ sal_Bool SfxMedium::LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI ) try { // MediaDescriptor does this check also, the duplication should be avoided in future - pImp->aContent.getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) ) ) >>= bContentReadonly; + Reference< ::com::sun::star::ucb::XCommandEnvironment > xDummyEnv; + ::ucbhelper::Content aContent( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), xDummyEnv ); + aContent.getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) ) ) >>= bContentReadonly; } catch( uno::Exception ) {} @@ -1420,222 +1312,82 @@ sal_Bool SfxMedium::LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI ) } //------------------------------------------------------------------ -uno::Reference < embed::XStorage > SfxMedium::GetStorage() +uno::Reference < embed::XStorage > SfxMedium::GetStorage( sal_Bool bCreateTempIfNo ) { if ( pImp->xStorage.is() || bTriedStorage ) return pImp->xStorage; uno::Sequence< uno::Any > aArgs( 2 ); - String aStorageName; - if ( pImp->pTempFile || pImp->pTempDir ) - { - // open storage from the temporary file - if ( !::utl::LocalFileHelper::ConvertPhysicalNameToURL( aName, aStorageName ) ) - { - DBG_ERROR("Physical name not convertable!"); - } + // the medium should be retrieved before temporary file creation + // to let the MediaDescriptor be filled with the streams + GetMedium_Impl(); - CloseOutStream(); - // create the set of the streams based on the temporary file - GetMedium_Impl(); + if ( bCreateTempIfNo ) + CreateTempFile( sal_False ); - OSL_ENSURE( pImp->xStream.is(), "It must be possible to create read write stream access!" ); - if ( pImp->xStream.is() ) - { - aArgs[0] <<= pImp->xStream; - pImp->bStorageBasedOnInStream = sal_True; - } - else - { - CloseStreams_Impl(); - aArgs[0] <<= ::rtl::OUString( aName ); - pImp->bStorageBasedOnInStream = sal_False; - } + GetMedium_Impl(); - aArgs[1] <<= ( nStorOpenMode&STREAM_WRITE ? embed::ElementModes::READWRITE : embed::ElementModes::READ ); + if ( GetError() ) + return pImp->xStorage; - try - { - pImp->xStorage = uno::Reference< embed::XStorage >( - ::comphelper::OStorageHelper::GetStorageFactory()->createInstanceWithArguments( aArgs ), - uno::UNO_QUERY ); - } - catch( uno::Exception& ) - { - //TODO/LATER: error handling; Error and LastStorageError - } - } - else + SFX_ITEMSET_ARG( GetItemSet(), pRepairItem, SfxBoolItem, SID_REPAIRPACKAGE, sal_False); + if ( pRepairItem && pRepairItem->GetValue() ) { - // open the storage from original location - { - GetMedium_Impl(); - if ( GetError() ) - return pImp->xStorage; - - try - { - if ( IsReadOnly() && ::utl::LocalFileHelper::IsLocalFile( aLogicName ) ) - { - //TODO/LATER: performance problem if not controlled by special Mode in SfxMedium - //(should be done only for permanently open storages) - // create a copy, the following method will close all existing streams - CreateTempFile(); - - // create the set of the streams based on the temporary file - GetMedium_Impl(); - - OSL_ENSURE( pImp->xStream.is(), "It must be possible to create read write stream access!" ); - if ( pImp->xStream.is() ) - { - aArgs[0] <<= pImp->xStream; - pImp->bStorageBasedOnInStream = sal_True; - } - else - { - CloseStreams_Impl(); - aArgs[0] <<= ::rtl::OUString( aName ); - pImp->bStorageBasedOnInStream = sal_False; - } - - aArgs[1] <<= embed::ElementModes::READWRITE; - - } - else - { - // there is no explicit request to open the document readonly - - // create a storage on the stream - if ( pImp->xStream.is() ) - { - aArgs[0] <<= pImp->xStream; - aArgs[1] <<= ( ( nStorOpenMode & STREAM_WRITE ) ? - embed::ElementModes::READWRITE : embed::ElementModes::READ ); - - pImp->bStorageBasedOnInStream = sal_True; - } - else - { - // no readwrite stream, but it can be a case of http protocol - sal_Bool bReadOnly = sal_False; - - if ( aLogicName.CompareToAscii( "private:stream", 14 ) != COMPARE_EQUAL - && GetContent().is() ) - { - // unfortunately the content can not always have the interaction handler - // so in some cases it has to be set for some time - Reference < ::com::sun::star::ucb::XCommandEnvironment > xEnv; - Reference < ::com::sun::star::ucb::XCommandEnvironment > xOldEnv; - Reference < ::com::sun::star::task::XInteractionHandler > xInteractionHandler = ((SfxMedium*)this)->GetInteractionHandler(); - if ( xInteractionHandler.is() ) - xEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, - Reference< ::com::sun::star::ucb::XProgressHandler >() ); - - if ( xEnv.is() ) - { - xOldEnv = pImp->aContent.getCommandEnvironment(); - pImp->aContent.setCommandEnvironment( xEnv ); - } - - try - { - Any aAny = pImp->aContent.getPropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsReadOnly" )) ); - - if ( ( aAny >>= bReadOnly ) && bReadOnly ) - { - GetItemSet()->Put( SfxBoolItem(SID_DOC_READONLY, sal_True)); - SetOpenMode( SFX_STREAM_READONLY, sal_False, sal_True ); - } - } - catch( uno::Exception& ) - {} - - if ( xEnv.is() ) - pImp->aContent.setCommandEnvironment( xOldEnv ); - } - - // if the document is opened as readonly the copy should be done according to selected approach - // if the document is opened for editing the copy should be done to use it as a temporary location for changes before the final transfer - // the following method will close all existing streams - CreateTempFile(); + // the storage should be created for repairing mode + CreateTempFile( sal_False ); + GetMedium_Impl(); - // create the set of the streams based on the temporary file - GetMedium_Impl(); + Reference< ::com::sun::star::ucb::XProgressHandler > xProgressHandler; + Reference< ::com::sun::star::task::XStatusIndicator > xStatusIndicator; - OSL_ENSURE( pImp->xStream.is(), "It must be possible to create read write stream access!" ); - if ( pImp->xStream.is() ) - { - aArgs[0] <<= pImp->xStream; - pImp->bStorageBasedOnInStream = sal_True; - } - else - { - CloseStreams_Impl(); - aArgs[0] <<= ::rtl::OUString( aName ); - pImp->bStorageBasedOnInStream = sal_False; - } + SFX_ITEMSET_ARG( GetItemSet(), pxProgressItem, SfxUnoAnyItem, SID_PROGRESS_STATUSBAR_CONTROL, sal_False ); + if( pxProgressItem && ( pxProgressItem->GetValue() >>= xStatusIndicator ) ) + xProgressHandler = Reference< ::com::sun::star::ucb::XProgressHandler >( + new utl::ProgressHandlerWrap( xStatusIndicator ) ); - if ( bReadOnly ) - aArgs[1] <<= embed::ElementModes::READ; - else - aArgs[1] <<= embed::ElementModes::READWRITE; - } - } + uno::Sequence< beans::PropertyValue > aAddProps( 2 ); + aAddProps[0].Name = ::rtl::OUString::createFromAscii( "RepairPackage" ); + aAddProps[0].Value <<= (sal_Bool)sal_True; + aAddProps[1].Name = ::rtl::OUString::createFromAscii( "StatusIndicator" ); + aAddProps[1].Value <<= xProgressHandler; - SFX_ITEMSET_ARG( GetItemSet(), pRepairItem, SfxBoolItem, SID_REPAIRPACKAGE, sal_False); - if ( pRepairItem && pRepairItem->GetValue() ) - { - // the storage should be created for repairing mode - CreateTempFile(); - Reference< ::com::sun::star::ucb::XProgressHandler > xProgressHandler; - Reference< ::com::sun::star::task::XStatusIndicator > xStatusIndicator; - - SFX_ITEMSET_ARG( GetItemSet(), pxProgressItem, SfxUnoAnyItem, SID_PROGRESS_STATUSBAR_CONTROL, sal_False ); - if( pxProgressItem && ( pxProgressItem->GetValue() >>= xStatusIndicator ) ) - xProgressHandler = Reference< ::com::sun::star::ucb::XProgressHandler >( - new utl::ProgressHandlerWrap( xStatusIndicator ) ); - - uno::Sequence< beans::PropertyValue > aAddProps( 2 ); - aAddProps[0].Name = ::rtl::OUString::createFromAscii( "RepairPackage" ); - aAddProps[0].Value <<= (sal_Bool)sal_True; - aAddProps[1].Name = ::rtl::OUString::createFromAscii( "StatusIndicator" ); - aAddProps[1].Value <<= xProgressHandler; - - aArgs.realloc( 3 ); - aArgs[0] <<= ::rtl::OUString( aName ); - aArgs[1] <<= embed::ElementModes::READWRITE; - aArgs[2] <<= aAddProps; - - pImp->bStorageBasedOnInStream = sal_False; - } - - pImp->xStorage = uno::Reference< embed::XStorage >( - ::comphelper::OStorageHelper::GetStorageFactory()->createInstanceWithArguments( aArgs ), - uno::UNO_QUERY ); + // the first arguments will be filled later + aArgs.realloc( 3 ); + aArgs[2] <<= aAddProps; + } - if ( !pImp->xStorage.is() ) - throw uno::RuntimeException(); + if ( pImp->xStream.is() ) + { + // since the storage is based on temporary stream we open it always read-write + aArgs[0] <<= pImp->xStream; + aArgs[1] <<= embed::ElementModes::READWRITE; + pImp->bStorageBasedOnInStream = sal_True; + } + else if ( pImp->xInputStream.is() ) + { + // since the storage is based on temporary stream we open it always read-write + aArgs[0] <<= pImp->xInputStream; + aArgs[1] <<= embed::ElementModes::READ; + pImp->bStorageBasedOnInStream = sal_True; + } + else + { + CloseStreams_Impl(); + aArgs[0] <<= ::rtl::OUString( aName ); + aArgs[1] <<= embed::ElementModes::READ; + pImp->bStorageBasedOnInStream = sal_False; + } - if ( pRepairItem && pRepairItem->GetValue() ) - { - // in repairing mode the mediatype required by filter should be used - ::rtl::OUString aMediaType; - ::rtl::OUString aMediaTypePropName( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ); - uno::Reference < beans::XPropertySet > xPropSet( pImp->xStorage, uno::UNO_QUERY_THROW ); - xPropSet->getPropertyValue( aMediaTypePropName ) >>= aMediaType; - if ( !aMediaType.getLength() && pFilter ) - xPropSet->setPropertyValue( aMediaTypePropName, - uno::makeAny( ::rtl::OUString( pFilter->GetMimeType() ) ) ); - } - } - catch ( uno::Exception& ) - { - //TODO/MBA: error handling; Error and LastStorageError - pImp->bStorageBasedOnInStream = sal_False; - } - } + try + { + pImp->xStorage = uno::Reference< embed::XStorage >( + ::comphelper::OStorageHelper::GetStorageFactory()->createInstanceWithArguments( aArgs ), + uno::UNO_QUERY ); + } + catch( uno::Exception& ) + { + // impossibility to create the storage is no error } if( ( pImp->nLastStorageError = GetError() ) != SVSTREAM_OK ) @@ -1643,13 +1395,12 @@ uno::Reference < embed::XStorage > SfxMedium::GetStorage() pImp->xStorage = 0; if ( pInStream ) pInStream->Seek(0); - return NULL; + return uno::Reference< embed::XStorage >(); } bTriedStorage = sal_True; - //TODO/MBA: error handling; Error and LastStorageError - //if ( aStorage->GetError() == SVSTREAM_OK ) + // TODO/LATER: Get versionlist on demand if ( pImp->xStorage.is() ) { SetPasswordToStorage_Impl(); @@ -1716,15 +1467,6 @@ uno::Reference < embed::XStorage > SfxMedium::GetStorage() bResetStorage = TRUE; } - //TODO/MBA: error handling; Error and LastStorageError - if ( pImp->xStorage.is() ) - { /* - if( ( pImp->nLastStorageError = aStorage->GetError() ) != SVSTREAM_OK ) - bResetStorage = TRUE; - else if ( GetFilter() ) - aStorage->SetVersion( GetFilter()->GetVersion() );*/ - } - if ( bResetStorage ) { pImp->xStorage = 0; @@ -1737,28 +1479,25 @@ uno::Reference < embed::XStorage > SfxMedium::GetStorage() } //------------------------------------------------------------------ -uno::Reference< embed::XStorage > SfxMedium::GetLastCommitReadStorage_Impl() +uno::Reference< embed::XStorage > SfxMedium::GetZipStorageToSign_Impl( sal_Bool bReadOnly ) { - if ( !GetError() && !pImp->m_xReadStorage.is() ) + if ( !GetError() && !pImp->m_xZipStorage.is() ) { + // very careful!!! + // if bReadOnly == sal_False and there is no temporary file the original file might be used GetMedium_Impl(); try { - if ( pImp->xInputStream.is() ) + // we can not sign document if there is no stream + // should it be possible at all? + if ( !bReadOnly && pImp->xStream.is() ) { - uno::Sequence< uno::Any > aArgs( 2 ); - aArgs[0] <<= pImp->xInputStream; - aArgs[1] <<= embed::ElementModes::READ; - pImp->m_xReadStorage = uno::Reference< embed::XStorage >( - ::comphelper::OStorageHelper::GetStorageFactory()->createInstanceWithArguments( aArgs ), - uno::UNO_QUERY ); + pImp->m_xZipStorage = ::comphelper::OStorageHelper::GetStorageOfFormatFromStream( ZIP_STORAGE_FORMAT_STRING, pImp->xStream, embed::ElementModes::READWRITE ); } - else if ( GetStorage().is() ) + else if ( pImp->xInputStream.is() ) { - uno::Reference< embed::XStorage > xTempStor = ::comphelper::OStorageHelper::GetTemporaryStorage(); - GetStorage()->copyLastCommitTo( xTempStor ); - pImp->m_xReadStorage = xTempStor; + pImp->m_xZipStorage = ::comphelper::OStorageHelper::GetStorageOfFormatFromInputStream( ZIP_STORAGE_FORMAT_STRING, pImp->xInputStream ); } } catch( uno::Exception& ) @@ -1770,20 +1509,20 @@ uno::Reference< embed::XStorage > SfxMedium::GetLastCommitReadStorage_Impl() ResetError(); } - return pImp->m_xReadStorage; + return pImp->m_xZipStorage; } //------------------------------------------------------------------ -void SfxMedium::CloseReadStorage_Impl() +void SfxMedium::CloseZipStorage_Impl() { - if ( pImp->m_xReadStorage.is() ) + if ( pImp->m_xZipStorage.is() ) { try { - pImp->m_xReadStorage->dispose(); + pImp->m_xZipStorage->dispose(); } catch( uno::Exception& ) {} - pImp->m_xReadStorage = uno::Reference< embed::XStorage >(); + pImp->m_xZipStorage = uno::Reference< embed::XStorage >(); } } @@ -1885,11 +1624,12 @@ sal_Bool SfxMedium::StorageCommit_Impl() try { xTrans->commit(); - CloseReadStorage_Impl(); + CloseZipStorage_Impl(); bResult = sal_True; } catch ( embed::UseBackupException& aBackupExc ) { + // since the temporary file is created always now, the scenario is close to be impossible if ( !pImp->pTempFile ) { OSL_ENSURE( pImp->m_aBackupURL.getLength(), "No backup on storage commit!\n" ); @@ -1936,9 +1676,6 @@ sal_Bool SfxMedium::TransactedTransferForFS_Impl( const INetURLObject& aSource, Reference< XOutputStream > aDestStream; ::ucbhelper::Content aOriginalContent; -// actualy it should work even for contents different from file content -// DBG_ASSERT( ::utl::LocalFileHelper::IsLocalFile( aDest.GetMainURL( INetURLObject::NO_DECODE ) ), -// "SfxMedium::TransactedTransferForFS() should be used only for local contents!" ); try { aOriginalContent = ::ucbhelper::Content( aDest.GetMainURL( INetURLObject::NO_DECODE ), xComEnv ); @@ -2241,57 +1978,10 @@ void SfxMedium::Transfer_Impl() catch ( uno::Exception& ) { //TODO/MBA: error handling - //if ( !GetError() ) - // SetError( xStor->GetError(, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) )) ); } return; } - if ( pFilter && SOFFICE_FILEFORMAT_60 <= pFilter->GetVersion() ) - { - //TODO/LATER: how?! - /* - SFX_ITEMSET_ARG( GetItemSet(), pItem, SfxBoolItem, SID_UNPACK, sal_False); - if ( pItem && pItem->GetValue() ) - { - // this file must be stored without packing into a JAR file - // check for an existing unpacked storage - SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( GetName(), STREAM_STD_READ ); - if ( !pStream->GetError() ) - { - String aURL = UCBStorage::GetLinkedFile( *pStream ); - if ( aURL.Len() ) - // remove a possibly existing old folder - ::utl::UCBContentHelper::Kill( aURL ); - - DELETEZ( pStream ); - } - - // create a new folder based storage - SvStorageRef xStor = new SvStorage( TRUE, GetName(), STREAM_STD_READWRITE, STORAGE_CREATE_UNPACKED ); - - // copy package into unpacked storage - if ( xStor->GetError() == ERRCODE_NONE && GetStorage()->copyToStorage( xStor ) ) - { - // commit changes, writing will happen now - xStor->Commit(); - - // take new unpacked storage as own storage - if ( pImp->xStorage.is() ) - CloseStorage(); - - CloseStreams_Impl(); - - DELETEZ( pImp->pTempFile ); - ::utl::LocalFileHelper::ConvertURLToPhysicalName( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), aName ); - SetStorage_Impl( xStor ); - } - else if ( !GetError() ) - SetError( xStor->GetError(, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) )) ); - return; - }*/ - } - INetURLObject aDest( GetURLObject() ); // source is the temp file written so far @@ -2606,7 +2296,7 @@ void SfxMedium::GetMedium_Impl() // in case the temporary file exists the streams should be initialized from it, // but the original MediaDescriptor should not be changed - sal_Bool bFromTempFile = ( pImp->pTempFile || pImp->pTempDir ); + sal_Bool bFromTempFile = ( pImp->pTempFile != NULL ); if ( !bFromTempFile ) { @@ -2703,54 +2393,6 @@ void SfxMedium::CancelTransfers() pImp->xCancelManager->Cancel(); } -//---------------------------------------------------------------- -/* -String SfxMedium::GetStatusString( const SvProgressArg* pArg ) -{ - String aString; - StringList_Impl aSL( SfxResId( RID_DLSTATUS2 ), (USHORT)pArg->eStatus ); - USHORT nTotal = 0; - - if ( pArg->eStatus == SVBINDSTATUS_ENDDOWNLOADDATA && nTotal <= 1 ) - return aString; - - if( aSL ) - { - INetURLObject aObj( pArg->rStatus ); - aString = aSL.GetString(); - aString.SearchAndReplaceAscii( "$(HOST)", aObj.GetHost() ); - String aTarget = aObj.GetFull(); - if( aTarget.Len() <= 1 && pArg->eStatus != SVBINDSTATUS_CONNECTING ) - aTarget = aObj.GetHost(); - if( pArg->nMax ) - { - aTarget += DEFINE_CONST_UNICODE( " (" ); - AddNumber_Impl( aTarget, pArg->nMax ); - aTarget += ')'; - } - - aString.SearchAndReplaceAscii( "$(TARGET)",aTarget ); - String aNumber; - AddNumber_Impl( aNumber, pArg->nProgress ); - if( pArg->nRate ) - { - aNumber+= DEFINE_CONST_UNICODE( " (" ); - AddNumber_Impl( aNumber, (ULONG)pArg->nRate ); - aNumber+= DEFINE_CONST_UNICODE( "/s)" ); - } - if( pArg->nMax && pArg->nProgress && pArg->nMax != pArg->nProgress ) - { - aNumber += DEFINE_CONST_UNICODE( " [" ); - float aPerc = pArg->nProgress / (float)pArg->nMax; - aNumber += String::CreateFromInt32( (USHORT)(aPerc * 100) ); - aNumber += DEFINE_CONST_UNICODE( "%]" ); - } - aString.SearchAndReplaceAscii( "$(BYTE)", aNumber ); - } - return aString; -} -*/ - sal_Bool SfxMedium::IsRemote() { return bRemote; @@ -2910,7 +2552,7 @@ SfxMedium::SfxMedium( const SfxMedium& rMedium, sal_Bool bTemporary ) pFilter = rMedium.pFilter; Init_Impl(); if( bTemporary ) - CreateTempFile(); + CreateTempFile( sal_True ); } //------------------------------------------------------------------ @@ -2989,7 +2631,7 @@ void SfxMedium::Close() const SvStream *pStream = aStorage->GetSvStream(); if ( pStream && pStream == pInStream ) { - CloseReadStorage_Impl(); + CloseZipStorage_Impl(); pInStream = NULL; pImp->xInputStream = Reference < XInputStream >(); pImp->xLockBytes.Clear(); @@ -3022,7 +2664,7 @@ void SfxMedium::CloseAndRelease() const SvStream *pStream = aStorage->GetSvStream(); if ( pStream && pStream == pInStream ) { - CloseReadStorage_Impl(); + CloseZipStorage_Impl(); pInStream = NULL; pImp->xInputStream = Reference < XInputStream >(); pImp->xLockBytes.Clear(); @@ -3062,7 +2704,7 @@ void SfxMedium::UnlockFile() void SfxMedium::CloseAndReleaseStreams_Impl() { - CloseReadStorage_Impl(); + CloseZipStorage_Impl(); uno::Reference< io::XInputStream > xInToClose = pImp->xInputStream; uno::Reference< io::XOutputStream > xOutToClose; @@ -3184,26 +2826,6 @@ void SfxMedium::SetPhysicalName_Impl( const String& rNameP ) } } -//---------------------------------------------------------------- -void SfxMedium::MoveTempTo_Impl( SfxMedium* pMedium ) -{ - if ( pMedium && pMedium != this && pImp->pTempFile ) - { - if( pMedium->pImp->pTempFile ) - delete pMedium->pImp->pTempFile; - pMedium->pImp->pTempFile = pImp->pTempFile; - - pImp->pTempFile->EnableKillingFile( sal_True ); - pImp->pTempFile = NULL; - - pMedium->aName = pMedium->pImp->pTempFile->GetFileName(); - - pMedium->CloseInStream(); - pMedium->CloseStorage(); - pMedium->pImp->aContent = ::ucbhelper::Content(); - } -} - //------------------------------------------------------------------ void SfxMedium::SetTemporary( sal_Bool bTemp ) { @@ -3407,22 +3029,15 @@ SfxMedium::~SfxMedium() delete pURLObj; delete pImp; } -//------------------------------------------------------------------ +//------------------------------------------------------------------ void SfxMedium::SetItemSet(SfxItemSet *pNewSet) { delete pSet; pSet = pNewSet; } -//------------------------------------------------------------------ -void SfxMedium::SetClassFilter( const SvGlobalName & rFilterClass ) -{ - bSetFilter = sal_True; - aFilterClass = rFilterClass; -} //---------------------------------------------------------------- - const INetURLObject& SfxMedium::GetURLObject() const { if( !pURLObj ) @@ -3755,131 +3370,122 @@ sal_Bool SfxMedium::IsReadOnly() } //---------------------------------------------------------------- -void SfxMedium::TryToSwitchToRepairedTemp() +sal_Bool SfxMedium::SetWritableForUserOnly( const ::rtl::OUString& aURL ) { - // the medium should be opened in repair mode - SFX_ITEMSET_ARG( GetItemSet(), pRepairItem, SfxBoolItem, SID_REPAIRPACKAGE, FALSE ); - if ( pRepairItem && pRepairItem->GetValue() ) + // UCB does not allow to allow write access only for the user, + // use osl API + sal_Bool bResult = sal_False; + + ::osl::DirectoryItem aDirItem; + if ( ::osl::DirectoryItem::get( aURL, aDirItem ) == ::osl::FileBase::E_None ) { - DBG_ASSERT( pImp->xStorage.is(), "Possible performance problem" ); - if ( GetStorage().is() ) + ::osl::FileStatus aFileStatus( FileStatusMask_Attributes ); + if ( aDirItem.getFileStatus( aFileStatus ) == osl::FileBase::E_None + && aFileStatus.isValid( FileStatusMask_Attributes ) ) { - ::utl::TempFile* pTmpFile = new ::utl::TempFile(); - pTmpFile->EnableKillingFile( sal_True ); - ::rtl::OUString aNewName = pTmpFile->GetFileName(); + sal_uInt64 nAttributes = aFileStatus.getAttributes(); - if( aNewName.getLength() ) - { - try - { - uno::Reference < embed::XStorage > xNewStorage = comphelper::OStorageHelper::GetStorageFromURL( aNewName, - embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE ); - //SvStorageRef aNewStorage = new SvStorage( sal_True, aNewName, STREAM_WRITE | STREAM_TRUNC, STORAGE_TRANSACTED ); - - pImp->xStorage->copyToStorage( xNewStorage ); - //if ( aNewStorage->GetError() == SVSTREAM_OK ) - { - CloseInStream(); - CloseStorage(); - if ( pImp->pTempFile ) - DELETEZ( pImp->pTempFile ); + nAttributes &= ~(Attribute_OwnWrite | + Attribute_GrpWrite | + Attribute_OthWrite | + Attribute_ReadOnly); + nAttributes |= Attribute_OwnWrite; - pImp->pTempFile = pTmpFile; - aName = aNewName; - } - } - catch ( uno::Exception& ) - { - //TODO/MBA: error handling - //SetError( aNewStorage->GetError(, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) )) ); - } - } - else - SetError( ERRCODE_IO_CANTWRITE, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); - - if (pImp->pTempFile != pTmpFile) - delete pTmpFile; + bResult = ( osl::File::setAttributes( aURL, nAttributes ) == ::osl::FileBase::E_None ); } - else - SetError( ERRCODE_IO_CANTREAD, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); } + + return bResult; } //---------------------------------------------------------------- -void SfxMedium::CreateTempFile() +void SfxMedium::CreateTempFile( sal_Bool bReplace ) { if ( pImp->pTempFile ) { + if ( !bReplace ) + return; + DELETEZ( pImp->pTempFile ); aName = String(); } - StreamMode nOpenMode = nStorOpenMode; - BOOL bCopy = ( nStorOpenMode == nOpenMode && ! ( nOpenMode & STREAM_TRUNC ) ); - if ( bCopy && !pInStream ) - { - if ( GetContent().is() ) - { - try - { - // make sure that the desired file exists before trying to open - SvMemoryStream aStream(0,0); - ::utl::OInputStreamWrapper* pInput = new ::utl::OInputStreamWrapper( aStream ); - Reference< XInputStream > xInput( pInput ); - - InsertCommandArgument aInsertArg; - aInsertArg.Data = xInput; - - aInsertArg.ReplaceExisting = sal_False; - Any aCmdArg; - aCmdArg <<= aInsertArg; - pImp->aContent.executeCommand( ::rtl::OUString::createFromAscii( "insert" ), aCmdArg ); - } - catch ( Exception& ) - { - // it is NOT an error when the stream already exists! - GetInStream(); - } - } - } - - nStorOpenMode = nOpenMode; - ResetError(); - pImp->pTempFile = new ::utl::TempFile(); pImp->pTempFile->EnableKillingFile( sal_True ); aName = pImp->pTempFile->GetFileName(); - if ( !aName.Len() ) + ::rtl::OUString aTmpURL = pImp->pTempFile->GetURL(); + if ( !aName.Len() || !aTmpURL.getLength() ) { SetError( ERRCODE_IO_CANTWRITE, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); return; } - if ( bCopy && pInStream ) + if ( !( nStorOpenMode & STREAM_TRUNC ) ) { - GetOutStream(); - if ( pOutStream ) + if ( GetContent().is() + && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) + && ::utl::UCBContentHelper::IsDocument( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) ) { - char *pBuf = new char [8192]; - sal_uInt32 nErr = ERRCODE_NONE; - - pInStream->Seek(0); - pOutStream->Seek(0); + // 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; + INetURLObject aTmpURLObj( aTmpURL ); + ::rtl::OUString aFileName = aTmpURLObj.getName( INetURLObject::LAST_SEGMENT, + true, + INetURLObject::DECODE_WITH_CHARSET ); + if ( aFileName.getLength() && aTmpURLObj.removeSegment() ) + { + ::ucbhelper::Content aTargetContent( aTmpURLObj.GetMainURL( INetURLObject::NO_DECODE ), xComEnv ); + if ( aTargetContent.transferContent( pImp->aContent, ::ucbhelper::InsertOperation_COPY, aFileName, NameClash::OVERWRITE ) ) + { + SetWritableForUserOnly( aTmpURL ); + bTransferSuccess = sal_True; + } + } + } + catch( uno::Exception& ) + {} - while( !pInStream->IsEof() && nErr == ERRCODE_NONE ) + if ( !bTransferSuccess ) { - sal_uInt32 nRead = pInStream->Read( pBuf, 8192 ); - nErr = pInStream->GetError(); - pOutStream->Write( pBuf, nRead ); + SetError( ERRCODE_IO_CANTWRITE, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); + return; } - delete[] pBuf; + CloseOutStream(); CloseInStream(); } - CloseOutStream_Impl(); + else if ( pInStream ) + { + // the case when there is no URL-access available or this is a remote protocoll + // but there is an input stream + GetOutStream(); + if ( pOutStream ) + { + char *pBuf = new char [8192]; + sal_uInt32 nErr = ERRCODE_NONE; + + pInStream->Seek(0); + pOutStream->Seek(0); + + while( !pInStream->IsEof() && nErr == ERRCODE_NONE ) + { + sal_uInt32 nRead = pInStream->Read( pBuf, 8192 ); + nErr = pInStream->GetError(); + pOutStream->Write( pBuf, nRead ); + } + + delete[] pBuf; + CloseInStream(); + } + CloseOutStream_Impl(); + } + else + CloseInStream(); } - else - CloseInStream(); CloseStorage(); } @@ -3887,6 +3493,7 @@ void SfxMedium::CreateTempFile() //---------------------------------------------------------------- void SfxMedium::CreateTempFileNoCopy() { + // this call always replaces the existing temporary file if ( pImp->pTempFile ) delete pImp->pTempFile; @@ -3944,100 +3551,120 @@ void SfxMedium::SetCharset( ::rtl::OUString aChs ) pImp->aCharset = aChs; } -sal_Bool SfxMedium::SignContents_Impl( sal_Bool bScriptingContent ) +sal_Bool SfxMedium::SignContents_Impl( sal_Bool bScriptingContent, const ::rtl::OUString& aODFVersion, sal_Bool bHasValidDocumentSignature ) { - DBG_ASSERT( GetStorage().is(), "SfxMedium::SignContents_Impl - Storage doesn't exist!" ); - sal_Bool bChanges = FALSE; - ::com::sun::star::uno::Reference< ::com::sun::star::security::XDocumentDigitalSignatures > xD( - comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), ::com::sun::star::uno::UNO_QUERY ); - - // TODO/LATER: error handling - if ( xD.is() && GetStorage().is() ) + // the medium should be closed to be able to sign, the caller is responsible to close it + if ( !IsOpen() && !GetError() ) { - sal_Int32 nEncrMode = IsReadOnly() ? embed::ElementModes::READ - : embed::ElementModes::READWRITE; + // The component should know if there was a valid document signature, since + // it should show a warning in this case + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[0] <<= aODFVersion; + aArgs[1] <<= bHasValidDocumentSignature; + ::com::sun::star::uno::Reference< ::com::sun::star::security::XDocumentDigitalSignatures > xSigner( + comphelper::getProcessServiceFactory()->createInstanceWithArguments( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ), + aArgs ), + ::com::sun::star::uno::UNO_QUERY ); - try + if ( xSigner.is() ) { - uno::Reference< embed::XStorage > xMetaInf = GetStorage()->openStorageElement( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) ), - nEncrMode ); - if ( !xMetaInf.is() ) - throw uno::RuntimeException(); - - if ( bScriptingContent ) + uno::Reference< embed::XStorage > xWriteableZipStor; + if ( !IsReadOnly() ) { - if ( !IsReadOnly() ) + // we can reuse the temporary file if there is one already + CreateTempFile( sal_False ); + GetMedium_Impl(); + + try { - uno::Reference< io::XStream > xStream = xMetaInf->openStreamElement( - xD->getScriptingContentSignatureDefaultStreamName(), - nEncrMode ); - if ( !xStream.is() ) + if ( !pImp->xStream.is() ) throw uno::RuntimeException(); - try + xWriteableZipStor = ::comphelper::OStorageHelper::GetStorageOfFormatFromStream( ZIP_STORAGE_FORMAT_STRING, pImp->xStream ); + if ( !xWriteableZipStor.is() ) + throw uno::RuntimeException(); + + uno::Reference< embed::XStorage > xMetaInf = xWriteableZipStor->openStorageElement( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) ), + embed::ElementModes::READWRITE ); + if ( !xMetaInf.is() ) + throw uno::RuntimeException(); + + if ( bScriptingContent ) { - // to leave the stream unencrypted as before - uno::Reference< beans::XPropertySet > xStrmProps( xStream, uno::UNO_QUERY_THROW ); - xStrmProps->setPropertyValue( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseCommonStoragePasswordEncryption" ) ), - uno::makeAny( (sal_Bool)sal_False ) ); + // If the signature has already the document signature it will be removed + // after the scripting signature is inserted. + uno::Reference< io::XStream > xStream( + xMetaInf->openStreamElement( xSigner->getScriptingContentSignatureDefaultStreamName(), + embed::ElementModes::READWRITE ), + uno::UNO_SET_THROW ); + + if ( xSigner->signScriptingContent( GetZipStorageToSign_Impl(), xStream ) ) + { + // remove the document signature if any + ::rtl::OUString aDocSigName = xSigner->getDocumentContentSignatureDefaultStreamName(); + if ( aDocSigName.getLength() && xMetaInf->hasByName( aDocSigName ) ) + xMetaInf->removeElement( aDocSigName ); + + uno::Reference< embed::XTransactedObject > xTransact( xMetaInf, uno::UNO_QUERY_THROW ); + xTransact->commit(); + xTransact.set( xWriteableZipStor, uno::UNO_QUERY_THROW ); + xTransact->commit(); + + // the temporary file has been written, commit it to the original file + Commit(); + bChanges = TRUE; + } } - catch ( uno::Exception& ) - {} - - if ( xD->signScriptingContent( GetLastCommitReadStorage_Impl(), xStream ) ) + else { - uno::Reference< embed::XTransactedObject > xTrans( xMetaInf, uno::UNO_QUERY ); - xTrans->commit(); - Commit(); - bChanges = TRUE; + uno::Reference< io::XStream > xStream( + xMetaInf->openStreamElement( xSigner->getDocumentContentSignatureDefaultStreamName(), + embed::ElementModes::READWRITE ), + uno::UNO_SET_THROW ); + + if ( xSigner->signDocumentContent( GetZipStorageToSign_Impl(), xStream ) ) + { + uno::Reference< embed::XTransactedObject > xTransact( xMetaInf, uno::UNO_QUERY_THROW ); + xTransact->commit(); + xTransact.set( xWriteableZipStor, uno::UNO_QUERY_THROW ); + xTransact->commit(); + + // the temporary file has been written, commit it to the original file + Commit(); + bChanges = TRUE; + } } } - else - xD->showScriptingContentSignatures( GetLastCommitReadStorage_Impl(), uno::Reference< io::XInputStream >() ); + catch ( uno::Exception& ) + { + OSL_ENSURE( sal_False, "Couldn't use signing functionality!\n" ); + } + + CloseAndRelease(); } else { - if ( !IsReadOnly() ) + try { - uno::Reference< io::XStream > xStream = xMetaInf->openStreamElement( - xD->getDocumentContentSignatureDefaultStreamName(), - nEncrMode ); - if ( !xStream.is() ) - throw uno::RuntimeException(); - - try - { - // to leave the stream unencrypted as before - uno::Reference< beans::XPropertySet > xStrmProps( xStream, uno::UNO_QUERY_THROW ); - xStrmProps->setPropertyValue( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseCommonStoragePasswordEncryption" ) ), - uno::makeAny( (sal_Bool)sal_False ) ); - } - catch ( uno::Exception& ) - {} - - if ( xD->signDocumentContent( GetLastCommitReadStorage_Impl(), xStream ) ) - { - uno::Reference< embed::XTransactedObject > xTrans( xMetaInf, uno::UNO_QUERY ); - xTrans->commit(); - Commit(); - bChanges = TRUE; - } - + if ( bScriptingContent ) + xSigner->showScriptingContentSignatures( GetZipStorageToSign_Impl(), uno::Reference< io::XInputStream >() ); + else + xSigner->showDocumentContentSignatures( GetZipStorageToSign_Impl(), uno::Reference< io::XInputStream >() ); + } + catch( uno::Exception& ) + { + OSL_ENSURE( sal_False, "Couldn't use signing functionality!\n" ); } - else - xD->showDocumentContentSignatures( GetLastCommitReadStorage_Impl(), uno::Reference< io::XInputStream >() ); } } - catch( uno::Exception& ) - { - OSL_ENSURE( sal_False, "Couldn't use signing functionality!\n" ); - } + + ResetError(); } + return bChanges; } @@ -4152,6 +3779,38 @@ BOOL SfxMedium::IsOpen() const return aResult; } +sal_Bool SfxMedium::CallApproveHandler( const uno::Reference< task::XInteractionHandler >& xHandler, uno::Any aRequest, sal_Bool bAllowAbort ) +{ + sal_Bool bResult = sal_False; + + if ( xHandler.is() ) + { + try + { + uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( bAllowAbort ? 2 : 1 ); + + ::rtl::Reference< ::framework::ContinuationApprove > pApprove( new ::framework::ContinuationApprove() ); + aContinuations[ 0 ] = pApprove.get(); + + if ( bAllowAbort ) + { + ::rtl::Reference< ::framework::ContinuationAbort > pAbort( new ::framework::ContinuationAbort() ); + aContinuations[ 1 ] = pAbort.get(); + } + + uno::Reference< task::XInteractionRequest > xRequest( new ::framework::InteractionRequest( aRequest, aContinuations ) ); + xHandler->handle( xRequest ); + + bResult = pApprove->isSelected(); + } + catch( const Exception& ) + { + } + } + + return bResult; +} + ::rtl::OUString SfxMedium::SwitchDocumentToTempFile() { // the method returns empty string in case of failure @@ -4189,7 +3848,7 @@ BOOL SfxMedium::IsOpen() const GetMedium_Impl(); LockOrigFileOnDemand( sal_False, sal_False ); - CreateTempFile(); + CreateTempFile( sal_True ); GetMedium_Impl(); if ( pImp->xStream.is() ) @@ -4247,7 +3906,7 @@ sal_Bool SfxMedium::SwitchDocumentToFile( ::rtl::OUString aURL ) // open the temporary file based document GetMedium_Impl(); LockOrigFileOnDemand( sal_False, sal_False ); - CreateTempFile(); + CreateTempFile( sal_True ); GetMedium_Impl(); if ( pImp->xStream.is() ) diff --git a/sfx2/source/doc/docmacromode.cxx b/sfx2/source/doc/docmacromode.cxx index e56a65d3f551..f1b889821de7 100644 --- a/sfx2/source/doc/docmacromode.cxx +++ b/sfx2/source/doc/docmacromode.cxx @@ -33,6 +33,7 @@ #include "sfx2/docmacromode.hxx" #include "sfx2/signaturestate.hxx" +#include "sfx2/docfile.hxx" /** === begin UNO includes === **/ #include @@ -85,14 +86,14 @@ namespace sfx2 //==================================================================== struct DocumentMacroMode_Data { - IMacroDocumentAccess& rDocumentAccess; - sal_Bool bMacroDisabledMessageShown; - sal_Bool bDocMacroDisabledMessageShown; - - DocumentMacroMode_Data( IMacroDocumentAccess& _rDocumentAccess ) - :rDocumentAccess( _rDocumentAccess ) - ,bMacroDisabledMessageShown( sal_False ) - ,bDocMacroDisabledMessageShown( sal_False ) + IMacroDocumentAccess& m_rDocumentAccess; + sal_Bool m_bMacroDisabledMessageShown; + sal_Bool m_bDocMacroDisabledMessageShown; + + DocumentMacroMode_Data( IMacroDocumentAccess& rDocumentAccess ) + :m_rDocumentAccess( rDocumentAccess ) + ,m_bMacroDisabledMessageShown( sal_False ) + ,m_bDocMacroDisabledMessageShown( sal_False ) { } }; @@ -103,85 +104,37 @@ namespace sfx2 namespace { //................................................................ - /** calls the given interaction handler with the given interaction request, offering - the two continuations "Approve" and "Abort" - - @return - if and only if the given handler handled the the request, and the "Approve" - continuation was selected. - */ - sal_Bool lcl_callInterActionHandler( const Reference< XInteractionHandler >& _rxHandler, const Any& _rRequest ) + void lcl_showGeneralSfxErrorOnce( const Reference< XInteractionHandler >& rxHandler, const sal_Int32 nSfxErrorCode, sal_Bool& rbAlreadyShown ) { - if ( !_rxHandler.is() ) - return sal_False; - - try - { - Sequence< Reference< XInteractionContinuation > > aContinuations(2); - - ::rtl::Reference< ::framework::ContinuationAbort > pAbort( new ::framework::ContinuationAbort() ); - aContinuations[ 0 ] = pAbort.get(); - - ::rtl::Reference< ::framework::ContinuationApprove > pApprove( new ::framework::ContinuationApprove() ); - aContinuations[ 1 ] = pApprove.get(); - - Reference< XInteractionRequest > xRequest( new ::framework::InteractionRequest( _rRequest, aContinuations ) ); - _rxHandler->handle( xRequest ); - - if ( pApprove->isSelected() ) - return sal_True; - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return sal_False; - } - - //................................................................ - void lcl_showGeneralSfxErrorOnce( const Reference< XInteractionHandler >& _rxHandler, const sal_Int32 _nSfxErrorCode, sal_Bool& _rbAlreadyShown ) - { - if ( _rbAlreadyShown ) + if ( rbAlreadyShown ) return; ErrorCodeRequest aErrorCodeRequest; - aErrorCodeRequest.ErrCode = _nSfxErrorCode; - - _rbAlreadyShown = lcl_callInterActionHandler( _rxHandler, makeAny( aErrorCodeRequest ) ); - } + aErrorCodeRequest.ErrCode = nSfxErrorCode; - //................................................................ - void lcl_showMacrosDisabledError( const Reference< XInteractionHandler >& _rxHandler, sal_Bool& _rbAlreadyShown ) - { - lcl_showGeneralSfxErrorOnce( _rxHandler, ERRCODE_SFX_MACROS_SUPPORT_DISABLED, _rbAlreadyShown ); + SfxMedium::CallApproveHandler( rxHandler, makeAny( aErrorCodeRequest ), sal_False ); + rbAlreadyShown = sal_True; } //................................................................ - void lcl_showDocumentMacrosDisabledError( const Reference< XInteractionHandler >& _rxHandler, sal_Bool& _rbAlreadyShown ) + void lcl_showMacrosDisabledError( const Reference< XInteractionHandler >& rxHandler, sal_Bool& rbAlreadyShown ) { - lcl_showGeneralSfxErrorOnce( _rxHandler, ERRCODE_SFX_DOCUMENT_MACRO_DISABLED, _rbAlreadyShown ); + lcl_showGeneralSfxErrorOnce( rxHandler, ERRCODE_SFX_MACROS_SUPPORT_DISABLED, rbAlreadyShown ); } //................................................................ - sal_Bool lcl_showMacroWarning( const Reference< XInteractionHandler >& _rxHandler, - const ::rtl::OUString& _rDocumentLocation ) + void lcl_showDocumentMacrosDisabledError( const Reference< XInteractionHandler >& rxHandler, sal_Bool& rbAlreadyShown ) { - DocumentMacroConfirmationRequest aRequest; - aRequest.DocumentURL = _rDocumentLocation; - return lcl_callInterActionHandler( _rxHandler, makeAny( aRequest ) ); + lcl_showGeneralSfxErrorOnce( rxHandler, ERRCODE_SFX_DOCUMENT_MACRO_DISABLED, rbAlreadyShown ); } //................................................................ - sal_Bool lcl_showMacroWarning( const Reference< XInteractionHandler >& _rxHandler, - const ::rtl::OUString& _rDocumentLocation, const Reference< XStorage >& _rxDocStor, - const Sequence< DocumentSignatureInformation >& _rDocSigInfo ) + sal_Bool lcl_showMacroWarning( const Reference< XInteractionHandler >& rxHandler, + const ::rtl::OUString& rDocumentLocation ) { DocumentMacroConfirmationRequest aRequest; - aRequest.DocumentURL = _rDocumentLocation; - aRequest.DocumentStorage = _rxDocStor; - aRequest.DocumentSignatureInformation = _rDocSigInfo; - aRequest.Classification = InteractionClassification_QUERY; - return lcl_callInterActionHandler( _rxHandler, makeAny( aRequest ) ); + aRequest.DocumentURL = rDocumentLocation; + return SfxMedium::CallApproveHandler( rxHandler, makeAny( aRequest ), sal_True ); } } @@ -189,8 +142,8 @@ namespace sfx2 //= DocumentMacroMode //==================================================================== //-------------------------------------------------------------------- - DocumentMacroMode::DocumentMacroMode( IMacroDocumentAccess& _rDocumentAccess ) - :m_pData( new DocumentMacroMode_Data( _rDocumentAccess ) ) + DocumentMacroMode::DocumentMacroMode( IMacroDocumentAccess& rDocumentAccess ) + :m_pData( new DocumentMacroMode_Data( rDocumentAccess ) ) { } @@ -202,26 +155,26 @@ namespace sfx2 //-------------------------------------------------------------------- sal_Bool DocumentMacroMode::allowMacroExecution() { - m_pData->rDocumentAccess.setCurrentMacroExecMode( MacroExecMode::ALWAYS_EXECUTE_NO_WARN ); + m_pData->m_rDocumentAccess.setCurrentMacroExecMode( MacroExecMode::ALWAYS_EXECUTE_NO_WARN ); return sal_True; } //-------------------------------------------------------------------- sal_Bool DocumentMacroMode::disallowMacroExecution() { - m_pData->rDocumentAccess.setCurrentMacroExecMode( MacroExecMode::NEVER_EXECUTE ); + m_pData->m_rDocumentAccess.setCurrentMacroExecMode( MacroExecMode::NEVER_EXECUTE ); return sal_False; } //-------------------------------------------------------------------- - sal_Bool DocumentMacroMode::adjustMacroMode( const Reference< XInteractionHandler >& _rxInteraction ) + sal_Bool DocumentMacroMode::adjustMacroMode( const Reference< XInteractionHandler >& rxInteraction ) { - sal_uInt16 nMacroExecutionMode = m_pData->rDocumentAccess.getCurrentMacroExecMode(); + sal_uInt16 nMacroExecutionMode = m_pData->m_rDocumentAccess.getCurrentMacroExecMode(); if ( SvtSecurityOptions().IsMacroDisabled() ) { // no macro should be executed at all - lcl_showMacrosDisabledError( _rxInteraction, m_pData->bMacroDisabledMessageShown ); + lcl_showMacrosDisabledError( rxInteraction, m_pData->m_bMacroDisabledMessageShown ); return disallowMacroExecution(); } @@ -273,9 +226,10 @@ namespace sfx2 try { - ::rtl::OUString sReferrer( m_pData->rDocumentAccess.getDocumentLocation() ); + ::rtl::OUString sReferrer( m_pData->m_rDocumentAccess.getDocumentLocation() ); // get document location from medium name and check whether it is a trusted one + // the service is created ohne document version, since it is not of interest here ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); Reference< XDocumentDigitalSignatures > xSignatures; if ( aContext.createComponent( "com.sun.star.security.DocumentDigitalSignatures", xSignatures ) ) @@ -295,61 +249,35 @@ namespace sfx2 // at this point it is clear that the document is not in the secure location if ( nMacroExecutionMode == MacroExecMode::FROM_LIST_NO_WARN ) { - lcl_showDocumentMacrosDisabledError( _rxInteraction, m_pData->bDocMacroDisabledMessageShown ); + lcl_showDocumentMacrosDisabledError( rxInteraction, m_pData->m_bDocMacroDisabledMessageShown ); return disallowMacroExecution(); } // check whether the document is signed with trusted certificate - if ( xSignatures.is() && nMacroExecutionMode != MacroExecMode::FROM_LIST ) + if ( nMacroExecutionMode != MacroExecMode::FROM_LIST ) { - Sequence< DocumentSignatureInformation > aScriptingSignatureInformations; - Reference < XStorage > xStore( m_pData->rDocumentAccess.getLastCommitDocumentStorage() ); + // the trusted macro check will also retrieve the signature state ( small optimization ) + sal_Bool bHasTrustedMacroSignature = m_pData->m_rDocumentAccess.hasTrustedScriptingSignature( nMacroExecutionMode != MacroExecMode::FROM_LIST_AND_SIGNED_NO_WARN ); - sal_uInt16 nSignatureState = m_pData->rDocumentAccess.getScriptingSignatureState(); + sal_uInt16 nSignatureState = m_pData->m_rDocumentAccess.getScriptingSignatureState(); if ( nSignatureState == SIGNATURESTATE_SIGNATURES_BROKEN ) { + // the signature is broken, no macro execution if ( nMacroExecutionMode != MacroExecMode::FROM_LIST_AND_SIGNED_NO_WARN ) - { - m_pData->rDocumentAccess.showBrokenSignatureWarning( _rxInteraction ); - return disallowMacroExecution(); - } + m_pData->m_rDocumentAccess.showBrokenSignatureWarning( rxInteraction ); + + return disallowMacroExecution(); } - else + else if ( bHasTrustedMacroSignature ) { - if ( ( ( nSignatureState == SIGNATURESTATE_SIGNATURES_OK ) - || ( nSignatureState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED ) - ) - && xStore.is() - ) - { - aScriptingSignatureInformations = - xSignatures->verifyScriptingContentSignatures( xStore, NULL ); - } + // there is trusted macro signature, allow macro execution + return allowMacroExecution(); } - - sal_Int32 nNumOfInfos = aScriptingSignatureInformations.getLength(); - - // from now on sReferrer is the system file path - // sReferrer = INetURLObject::decode( sReferrer, '%', INetURLObject::DECODE_WITH_CHARSET ); - ::rtl::OUString aSystemFileURL; - if ( osl::FileBase::getSystemPathFromFileURL( sReferrer, aSystemFileURL ) == osl::FileBase::E_None ) - sReferrer = aSystemFileURL; - - if ( nNumOfInfos ) + else if ( nSignatureState == SIGNATURESTATE_SIGNATURES_OK + || nSignatureState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED ) { - for ( sal_Int32 i = 0; i < nNumOfInfos; i++ ) - if ( xSignatures->isAuthorTrusted( aScriptingSignatureInformations[i].Signer ) ) - { - // there's at least one author we trust which signed the doc - return allowMacroExecution(); - } - - if ( nMacroExecutionMode != MacroExecMode::FROM_LIST_AND_SIGNED_NO_WARN ) - { - sal_Bool bApproved = lcl_showMacroWarning( _rxInteraction, - sReferrer, xStore, aScriptingSignatureInformations ); - return ( bApproved ? allowMacroExecution() : disallowMacroExecution() ); - } + // there is valid signature, but it is not from the trusted author + return disallowMacroExecution(); } } @@ -359,9 +287,8 @@ namespace sfx2 ) { if ( nMacroExecutionMode == MacroExecMode::FROM_LIST_AND_SIGNED_WARN ) - { - lcl_showDocumentMacrosDisabledError( _rxInteraction, m_pData->bDocMacroDisabledMessageShown ); - } + lcl_showDocumentMacrosDisabledError( rxInteraction, m_pData->m_bDocMacroDisabledMessageShown ); + return disallowMacroExecution(); } } @@ -381,13 +308,13 @@ namespace sfx2 if ( eAutoConfirm == eNoAutoConfirm ) { - ::rtl::OUString sReferrer( m_pData->rDocumentAccess.getDocumentLocation() ); + ::rtl::OUString sReferrer( m_pData->m_rDocumentAccess.getDocumentLocation() ); ::rtl::OUString aSystemFileURL; if ( osl::FileBase::getSystemPathFromFileURL( sReferrer, aSystemFileURL ) == osl::FileBase::E_None ) sReferrer = aSystemFileURL; - bSecure = lcl_showMacroWarning( _rxInteraction, sReferrer ); + bSecure = lcl_showMacroWarning( rxInteraction, sReferrer ); } else bSecure = ( eAutoConfirm == eAutoConfirmApprove ); @@ -398,7 +325,7 @@ namespace sfx2 //-------------------------------------------------------------------- sal_Bool DocumentMacroMode::isMacroExecutionDisallowed() const { - return m_pData->rDocumentAccess.getCurrentMacroExecMode() == MacroExecMode::NEVER_EXECUTE; + return m_pData->m_rDocumentAccess.getCurrentMacroExecMode() == MacroExecMode::NEVER_EXECUTE; } //-------------------------------------------------------------------- @@ -407,7 +334,7 @@ namespace sfx2 sal_Bool bHasMacroLib = sal_False; try { - Reference< XEmbeddedScripts > xScripts( m_pData->rDocumentAccess.getEmbeddedDocumentScripts() ); + Reference< XEmbeddedScripts > xScripts( m_pData->m_rDocumentAccess.getEmbeddedDocumentScripts() ); Reference< XLibraryContainer > xContainer; if ( xScripts.is() ) xContainer.set( xScripts->getBasicLibraries(), UNO_QUERY_THROW ); @@ -457,21 +384,21 @@ namespace sfx2 } //-------------------------------------------------------------------- - sal_Bool DocumentMacroMode::storageHasMacros( const Reference< XStorage >& _rxStorage ) + sal_Bool DocumentMacroMode::storageHasMacros( const Reference< XStorage >& rxStorage ) { sal_Bool bHasMacros = sal_False; - if ( _rxStorage.is() ) + if ( rxStorage.is() ) { try { static const ::rtl::OUString s_sBasicStorageName( ::rtl::OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "Basic" ) ) ); static const ::rtl::OUString s_sScriptsStorageName( ::rtl::OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "Scripts" ) ) ); - bHasMacros =( ( _rxStorage->hasByName( s_sBasicStorageName ) - && _rxStorage->isStorageElement( s_sBasicStorageName ) + bHasMacros =( ( rxStorage->hasByName( s_sBasicStorageName ) + && rxStorage->isStorageElement( s_sBasicStorageName ) ) - || ( _rxStorage->hasByName( s_sScriptsStorageName ) - && _rxStorage->isStorageElement( s_sScriptsStorageName ) + || ( rxStorage->hasByName( s_sScriptsStorageName ) + && rxStorage->isStorageElement( s_sScriptsStorageName ) ) ); } @@ -484,7 +411,7 @@ namespace sfx2 } //-------------------------------------------------------------------- - sal_Bool DocumentMacroMode::checkMacrosOnLoading( const Reference< XInteractionHandler >& _rxInteraction ) + sal_Bool DocumentMacroMode::checkMacrosOnLoading( const Reference< XInteractionHandler >& rxInteraction ) { sal_Bool bAllow = sal_False; if ( SvtSecurityOptions().IsMacroDisabled() ) @@ -494,9 +421,9 @@ namespace sfx2 } else { - if ( m_pData->rDocumentAccess.documentStorageHasMacros() || hasMacroLibrary() ) + if ( m_pData->m_rDocumentAccess.documentStorageHasMacros() || hasMacroLibrary() ) { - bAllow = adjustMacroMode( _rxInteraction ); + bAllow = adjustMacroMode( rxInteraction ); } else if ( !isMacroExecutionDisallowed() ) { diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index c46a467fa41d..5916fb625787 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -87,6 +87,8 @@ #include #include "alienwarn.hxx" +#include "../appl/app.hrc" + #define DOCPROPSNUM 17 // flags that specify requested operation @@ -1227,7 +1229,8 @@ sal_Bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& const ::rtl::OUString& aSlotName, uno::Sequence< beans::PropertyValue >& aArgsSequence, sal_Bool bPreselectPassword, - ::rtl::OUString aSuggestedName ) + ::rtl::OUString aSuggestedName, + sal_uInt16 nDocumentSignatureState ) { ModelData_Impl aModelData( *this, xModel, aArgsSequence ); @@ -1308,6 +1311,24 @@ sal_Bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& } } + if ( !( nStoreMode & EXPORT_REQUESTED ) ) + { + // if it is no export, warn user that the signature will be removed + if ( SIGNATURESTATE_SIGNATURES_OK == nDocumentSignatureState + || SIGNATURESTATE_SIGNATURES_INVALID == nDocumentSignatureState + || SIGNATURESTATE_SIGNATURES_NOTVALIDATED == nDocumentSignatureState + || SIGNATURESTATE_SIGNATURES_PARTIAL_OK == nDocumentSignatureState) + { + if ( QueryBox( NULL, SfxResId( RID_XMLSEC_QUERY_LOSINGSIGNATURE ) ).Execute() != RET_YES ) + { + // the user has decided not to store the document + throw task::ErrorCodeIOException( ::rtl::OUString(), + uno::Reference< uno::XInterface >(), + ERRCODE_IO_ABORT ); + } + } + } + // preselect a filter for the storing process uno::Sequence< beans::PropertyValue > aFilterProps = aModelData.GetPreselectedFilter_Impl( nStoreMode ); diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index a7910c463cf9..816ece081fc3 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -87,6 +87,8 @@ #include #include +#include +#include #include using namespace ::com::sun::star; @@ -120,6 +122,7 @@ using namespace ::com::sun::star::container; #include #include #include +#include #include #include @@ -285,8 +288,6 @@ sal_uInt32 SfxObjectShell::GetErrorCode() const sal_uInt32 lError=pImp->lErr; if(!lError && GetMedium()) lError=GetMedium()->GetErrorCode(); -//REMOVE if(!lError && HasStorage()) -//REMOVE lError= GetStorage()->GetErrorCode(); return lError; } @@ -301,9 +302,6 @@ void SfxObjectShell::ResetError() SfxMedium * pMed = GetMedium(); if( pMed ) pMed->ResetError(); -//REMOVE SvStorage *pStor= HasStorage() ? GetStorage() : 0; -//REMOVE if( pStor ) -//REMOVE pStor->ResetError(); } //------------------------------------------------------------------------- @@ -1234,10 +1232,52 @@ void SfxObjectShell::CheckSecurityOnLoading_Impl() if ( GetMedium() ) xInteraction = GetMedium()->GetInteractionHandler(); - // check macro security - pImp->aMacroMode.checkMacrosOnLoading( xInteraction ); // check if there is a broken signature... CheckForBrokenDocSignatures_Impl( xInteraction ); + + CheckEncryption_Impl( xInteraction ); + + // check macro security + pImp->aMacroMode.checkMacrosOnLoading( xInteraction ); +} + +//------------------------------------------------------------------------- +void SfxObjectShell::CheckEncryption_Impl( const uno::Reference< task::XInteractionHandler >& xHandler ) +{ + ::rtl::OUString aVersion; + sal_Bool bIsEncrypted = sal_False; + sal_Bool bHasNonEncrypted = sal_False; + + try + { + uno::Reference < beans::XPropertySet > xPropSet( GetStorage(), uno::UNO_QUERY_THROW ); + xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) ) >>= aVersion; + xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HasEncryptedEntries" ) ) ) >>= bIsEncrypted; + xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HasNonEncryptedEntries" ) ) ) >>= bHasNonEncrypted; + } + catch( uno::Exception& ) + { + } + + if ( aVersion.compareTo( ODFVER_012_TEXT ) >= 0 ) + { + // this is ODF1.2 or later + if ( bIsEncrypted && bHasNonEncrypted ) + { + if ( !pImp->m_bIncomplEncrWarnShown ) + { + // this is an encrypted document with nonencrypted streams inside, show the warning + ::com::sun::star::task::ErrorCodeRequest aErrorCode; + aErrorCode.ErrCode = ERRCODE_SFX_INCOMPLETE_ENCRYPTION; + + SfxMedium::CallApproveHandler( xHandler, uno::makeAny( aErrorCode ), sal_False ); + pImp->m_bIncomplEncrWarnShown = sal_True; + } + + // broken signatures imply no macro execution at all + pImp->aMacroMode.disallowMacroExecution(); + } + } } //------------------------------------------------------------------------- @@ -1476,7 +1516,7 @@ void SfxObjectShell::TemplateDisconnectionAfterLoad() { // some further initializations for templates SetTemplate_Impl( aName, aTemplateName, this ); - pTmpMedium->CreateTempFile(); + pTmpMedium->CreateTempFile( sal_True ); } // templates are never readonly @@ -2086,14 +2126,16 @@ void SfxObjectShell::Invalidate( USHORT nId ) Invalidate_Impl( pFrame->GetBindings(), nId ); } -bool SfxObjectShell::AdjustMacroMode( const String& /*rScriptType*/, bool _bSuppressUI ) +bool SfxObjectShell::AdjustMacroMode( const String& /*rScriptType*/, bool bSuppressUI ) { uno::Reference< task::XInteractionHandler > xInteraction; - if ( pMedium && !_bSuppressUI ) + if ( pMedium && !bSuppressUI ) xInteraction = pMedium->GetInteractionHandler(); CheckForBrokenDocSignatures_Impl( xInteraction ); + CheckEncryption_Impl( xInteraction ); + return pImp->aMacroMode.adjustMacroMode( xInteraction ); } @@ -2325,16 +2367,15 @@ sal_Bool SfxObjectShell_Impl::setCurrentMacroExecMode( sal_uInt16 nMacroMode ) return sLocation; } -uno::Reference< embed::XStorage > SfxObjectShell_Impl::getLastCommitDocumentStorage() +uno::Reference< embed::XStorage > SfxObjectShell_Impl::getZipStorageToSign() { Reference < embed::XStorage > xStore; SfxMedium* pMedium( rDocShell.GetMedium() ); OSL_PRECOND( pMedium, "SfxObjectShell_Impl::getLastCommitDocumentStorage: no medium!" ); if ( pMedium ) - { - xStore = pMedium->GetLastCommitReadStorage_Impl(); - } + xStore = pMedium->GetZipStorageToSign_Impl(); + return xStore; } @@ -2348,7 +2389,7 @@ Reference< XEmbeddedScripts > SfxObjectShell_Impl::getEmbeddedDocumentScripts() return Reference< XEmbeddedScripts >( rDocShell.GetModel(), UNO_QUERY ); } -sal_Int16 SfxObjectShell_Impl::getScriptingSignatureState() const +sal_Int16 SfxObjectShell_Impl::getScriptingSignatureState() { sal_Int16 nSignatureState( rDocShell.GetScriptingSignatureState() ); @@ -2361,6 +2402,72 @@ sal_Int16 SfxObjectShell_Impl::getScriptingSignatureState() const return nSignatureState; } +sal_Bool SfxObjectShell_Impl::hasTrustedScriptingSignature( sal_Bool bAllowUIToAddAuthor ) +{ + sal_Bool bResult = sal_False; + + try + { + ::rtl::OUString aVersion; + try + { + uno::Reference < beans::XPropertySet > xPropSet( rDocShell.GetStorage(), uno::UNO_QUERY_THROW ); + xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) ) >>= aVersion; + } + catch( uno::Exception& ) + { + } + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[0] <<= aVersion; + + uno::Reference< security::XDocumentDigitalSignatures > xSigner( comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ), aArgs ), uno::UNO_QUERY_THROW ); + + if ( nScriptingSignatureState == SIGNATURESTATE_UNKNOWN + || nScriptingSignatureState == SIGNATURESTATE_SIGNATURES_OK + || nScriptingSignatureState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED ) + { + uno::Sequence< security::DocumentSignatureInformation > aInfo = rDocShell.ImplAnalyzeSignature( sal_True, xSigner ); + + if ( aInfo.getLength() ) + { + if ( nScriptingSignatureState == SIGNATURESTATE_UNKNOWN ) + nScriptingSignatureState = rDocShell.ImplCheckSignaturesInformation( aInfo ); + + if ( nScriptingSignatureState == SIGNATURESTATE_SIGNATURES_OK + || nScriptingSignatureState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED ) + { + for ( sal_Int32 nInd = 0; !bResult && nInd < aInfo.getLength(); nInd++ ) + { + bResult = xSigner->isAuthorTrusted( aInfo[nInd].Signer ); + } + + if ( !bResult && bAllowUIToAddAuthor ) + { + uno::Reference< task::XInteractionHandler > xInteraction; + if ( rDocShell.GetMedium() ) + xInteraction = rDocShell.GetMedium()->GetInteractionHandler(); + + if ( xInteraction.is() ) + { + task::DocumentMacroConfirmationRequest2 aRequest; + aRequest.DocumentURL = getDocumentLocation(); + aRequest.DocumentZipStorage = rDocShell.GetMedium()->GetZipStorageToSign_Impl(); + aRequest.DocumentSignatureInformation = aInfo; + aRequest.DocumentVersion = aVersion; + aRequest.Classification = task::InteractionClassification_QUERY; + bResult = SfxMedium::CallApproveHandler( xInteraction, uno::makeAny( aRequest ), sal_True ); + } + } + } + } + } + } + catch( uno::Exception& ) + {} + + return bResult; +} + void SfxObjectShell_Impl::showBrokenSignatureWarning( const uno::Reference< task::XInteractionHandler >& _rxInteraction ) const { if ( !bSignatureErrorIsShown ) diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 34a3f3159169..8a8512a37af0 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -525,16 +525,6 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) { SfxErrorContext aEc( ERRCTX_SFX_SAVEASDOC, GetTitle() ); // ??? - // xmlsec05, check with SFX team - sal_uInt16 nState = GetDocumentSignatureState(); - if ( SIGNATURESTATE_SIGNATURES_OK == nState - || SIGNATURESTATE_SIGNATURES_INVALID == nState - || SIGNATURESTATE_SIGNATURES_NOTVALIDATED == nState ) - { - if ( QueryBox( NULL, SfxResId( RID_XMLSEC_QUERY_LOSINGSIGNATURE ) ).Execute() != RET_YES ) - return; - } - if ( nId == SID_SAVEASDOC ) { // in case of plugin mode the SaveAs operation means SaveTo @@ -644,7 +634,8 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) ::rtl::OUString::createFromAscii( pSlot->GetUnoName() ), aDispatchArgs, bPreselectPassword, - GetSharedFileURL() ); + GetSharedFileURL(), + GetDocumentSignatureState() ); } else { @@ -654,11 +645,6 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) ERRCODE_IO_ABORT ); } - // the scripting signature might be preserved - // pImp->nScriptingSignatureState = SIGNATURESTATE_NOSIGNATURES; - pImp->nDocumentSignatureState = SIGNATURESTATE_NOSIGNATURES; - pImp->bSignatureErrorIsShown = sal_False; - // merge aDispatchArgs to the request SfxAllItemSet aResultParams( GetPool() ); TransformParameters( nId, @@ -1085,7 +1071,11 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) } case SID_MACRO_SIGNATURE: { - rSet.Put( SfxUInt16Item( SID_MACRO_SIGNATURE, GetScriptingSignatureState() ) ); + // the slot makes sense only if there is a macro in the document + if ( pImp->documentStorageHasMacros() || pImp->aMacroMode.hasMacroLibrary() ) + rSet.Put( SfxUInt16Item( SID_MACRO_SIGNATURE, GetScriptingSignatureState() ) ); + else + rSet.DisableItem( nWhich ); break; } } @@ -1269,6 +1259,7 @@ sal_uInt16 SfxObjectShell::ImplCheckSignaturesInformation( const uno::Sequence< sal_Bool bCertValid = sal_True; sal_uInt16 nResult = SIGNATURESTATE_NOSIGNATURES; int nInfos = aInfos.getLength(); + bool bCompleteSignature = true; if( nInfos ) { //These errors of certificates are allowed @@ -1293,11 +1284,14 @@ sal_uInt16 SfxObjectShell::ImplCheckSignaturesInformation( const uno::Sequence< nResult = SIGNATURESTATE_SIGNATURES_BROKEN; break; // we know enough } + bCompleteSignature &= !aInfos[n].PartialDocumentSignature; } } if ( nResult == SIGNATURESTATE_SIGNATURES_OK && !bCertValid ) nResult = SIGNATURESTATE_SIGNATURES_NOTVALIDATED; + else if ( nResult == SIGNATURESTATE_SIGNATURES_OK && bCertValid && !bCompleteSignature) + nResult = SIGNATURESTATE_SIGNATURES_PARTIAL_OK; // this code must not check whether the document is modified // it should only check the provided info @@ -1305,41 +1299,61 @@ sal_uInt16 SfxObjectShell::ImplCheckSignaturesInformation( const uno::Sequence< return nResult; } -sal_uInt16 SfxObjectShell::ImplGetSignatureState( sal_Bool bScriptingContent ) +uno::Sequence< security::DocumentSignatureInformation > SfxObjectShell::ImplAnalyzeSignature( sal_Bool bScriptingContent, const uno::Reference< security::XDocumentDigitalSignatures >& xSigner ) { - sal_Int16* pState = bScriptingContent ? &pImp->nScriptingSignatureState : &pImp->nDocumentSignatureState; + uno::Sequence< security::DocumentSignatureInformation > aResult; + uno::Reference< security::XDocumentDigitalSignatures > xLocSigner = xSigner; - if ( *pState == SIGNATURESTATE_UNKNOWN ) + if ( GetMedium() && GetMedium()->GetName().Len() && IsOwnStorageFormat_Impl( *GetMedium()) && GetMedium()->GetStorage().is() ) { - *pState = SIGNATURESTATE_NOSIGNATURES; - - if ( GetMedium() && GetMedium()->GetName().Len() && IsOwnStorageFormat_Impl( *GetMedium()) && GetMedium()->GetStorage().is() ) + try { - try + if ( !xLocSigner.is() ) { - uno::Reference< security::XDocumentDigitalSignatures > xD( - comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), uno::UNO_QUERY ); - - if ( xD.is() ) + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[0] <<= ::rtl::OUString(); + try { - ::com::sun::star::uno::Sequence< security::DocumentSignatureInformation > aInfos; - if ( bScriptingContent ) - aInfos = xD->verifyScriptingContentSignatures( GetMedium()->GetLastCommitReadStorage_Impl(), - uno::Reference< io::XInputStream >() ); - else - aInfos = xD->verifyDocumentContentSignatures( GetMedium()->GetLastCommitReadStorage_Impl(), - uno::Reference< io::XInputStream >() ); - - *pState = ImplCheckSignaturesInformation( aInfos ); + uno::Reference < beans::XPropertySet > xPropSet( GetStorage(), uno::UNO_QUERY_THROW ); + aArgs[0] = xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) ); } + catch( uno::Exception& ) + { + } + + xLocSigner.set( comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ), aArgs ), uno::UNO_QUERY_THROW ); + } - catch( com::sun::star::uno::Exception& ) - { - } + + if ( bScriptingContent ) + aResult = xLocSigner->verifyScriptingContentSignatures( GetMedium()->GetZipStorageToSign_Impl(), + uno::Reference< io::XInputStream >() ); + else + aResult = xLocSigner->verifyDocumentContentSignatures( GetMedium()->GetZipStorageToSign_Impl(), + uno::Reference< io::XInputStream >() ); + } + catch( com::sun::star::uno::Exception& ) + { } } - if ( *pState == SIGNATURESTATE_SIGNATURES_OK || *pState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED ) + return aResult; +} + +sal_uInt16 SfxObjectShell::ImplGetSignatureState( sal_Bool bScriptingContent ) +{ + sal_Int16* pState = bScriptingContent ? &pImp->nScriptingSignatureState : &pImp->nDocumentSignatureState; + + if ( *pState == SIGNATURESTATE_UNKNOWN ) + { + *pState = SIGNATURESTATE_NOSIGNATURES; + + uno::Sequence< security::DocumentSignatureInformation > aInfos = ImplAnalyzeSignature( bScriptingContent ); + *pState = ImplCheckSignaturesInformation( aInfos ); + } + + if ( *pState == SIGNATURESTATE_SIGNATURES_OK || *pState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED + || *pState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK) { if ( IsModified() ) *pState = SIGNATURESTATE_SIGNATURES_INVALID; @@ -1415,7 +1429,6 @@ void SfxObjectShell::ImplSign( sal_Bool bScriptingContent ) //When the document is modified then we must not show the digital signatures dialog //If we have come here then the user denied to save. if (!bHasSign) - bNoSig = true; } } @@ -1437,18 +1450,42 @@ void SfxObjectShell::ImplSign( sal_Bool bScriptingContent ) bAllowModifiedBack = sal_True; } - if ( ! bNoSig && GetMedium()->SignContents_Impl( bScriptingContent ) ) + // we have to store to the original document, the original medium should be closed for this time + if ( !bNoSig + && ConnectTmpStorage_Impl( pMedium->GetStorage(), pMedium ) ) { - if ( bScriptingContent ) - pImp->nScriptingSignatureState = SIGNATURESTATE_UNKNOWN;// Re-Check - else - pImp->nDocumentSignatureState = SIGNATURESTATE_UNKNOWN;// Re-Check + GetMedium()->CloseAndRelease(); + + // We sign only ODF1.2, that means that if this point has been reached, + // the ODF1.2 signing process should be used. + // This code still might be called to show the signature of ODF1.1 document. + sal_Bool bSigned = GetMedium()->SignContents_Impl( + bScriptingContent, + aODFVersion, + pImp->nDocumentSignatureState == SIGNATURESTATE_SIGNATURES_OK + || pImp->nDocumentSignatureState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED + || pImp->nDocumentSignatureState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK); + + DoSaveCompleted( GetMedium() ); + + if ( bSigned ) + { + if ( bScriptingContent ) + { + pImp->nScriptingSignatureState = SIGNATURESTATE_UNKNOWN;// Re-Check + + // adding of scripting signature removes existing document signature + pImp->nDocumentSignatureState = SIGNATURESTATE_UNKNOWN;// Re-Check + } + else + pImp->nDocumentSignatureState = SIGNATURESTATE_UNKNOWN;// Re-Check - pImp->bSignatureErrorIsShown = sal_False; + pImp->bSignatureErrorIsShown = sal_False; - Invalidate( SID_SIGNATURE ); - Invalidate( SID_MACRO_SIGNATURE ); - Broadcast( SfxSimpleHint(SFX_HINT_TITLECHANGED) ); + Invalidate( SID_SIGNATURE ); + Invalidate( SID_MACRO_SIGNATURE ); + Broadcast( SfxSimpleHint(SFX_HINT_TITLECHANGED) ); + } } if ( bAllowModifiedBack ) diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 602174fb2bf9..2925090868e8 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -36,6 +36,7 @@ #endif #include #include +#include #include #include #include @@ -665,11 +666,14 @@ sal_Bool SfxObjectShell::DoLoad( SfxMedium *pMed ) xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaTypeFallbackUsed" ) ) ) >>= bWarnMediaTypeFallback; - if ( bWarnMediaTypeFallback && pRepairPackageItem && pRepairPackageItem->GetValue() ) + if ( pRepairPackageItem && pRepairPackageItem->GetValue() ) { + // the macros in repaired documents should be disabled + pMedium->GetItemSet()->Put( SfxUInt16Item( SID_MACROEXECMODE, document::MacroExecMode::NEVER_EXECUTE ) ); + // the mediatype was retrieved by using fallback solution but this is a repairing mode // so it is acceptable to open the document if there is no contents that required manifest.xml - bWarnMediaTypeFallback = sal_False; //!NoDependencyFromManifest_Impl( xStorage ); + bWarnMediaTypeFallback = sal_False; } if ( bWarnMediaTypeFallback || !xStorage->getElementNames().getLength() ) @@ -1175,7 +1179,7 @@ sal_Bool SfxObjectShell::SaveTo_Impl sal_Bool bStoreToSameLocation = sal_False; // the detection whether the script is changed should be done before saving - sal_Bool bTryToPreservScriptSignature = sal_False; + sal_Bool bTryToPreserveScriptSignature = sal_False; // no way to detect whether a filter is oasis format, have to wait for saving process sal_Bool bNoPreserveForOasis = sal_False; if ( bOwnSource && bOwnTarget @@ -1186,8 +1190,10 @@ sal_Bool SfxObjectShell::SaveTo_Impl AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "MacroSignaturePreserving" ) ) ); // the checking of the library modified state iterates over the libraries, should be done only when required - bTryToPreservScriptSignature = !pImp->pBasicManager->isAnyContainerModified(); - if ( bTryToPreservScriptSignature ) + // currently the check is commented out since it is broken, we have to check the signature every time we save + // TODO/LATER: let isAnyContainerModified() work! + bTryToPreserveScriptSignature = sal_True; // !pImp->pBasicManager->isAnyContainerModified(); + if ( bTryToPreserveScriptSignature ) { // check that the storage format stays the same SvtSaveOptions aSaveOpt; @@ -1203,7 +1209,7 @@ sal_Bool SfxObjectShell::SaveTo_Impl {} // preserve only if the same filter has been used - bTryToPreservScriptSignature = pMedium->GetFilter() && pFilter && pMedium->GetFilter()->GetFilterName() == pFilter->GetFilterName(); + bTryToPreserveScriptSignature = pMedium->GetFilter() && pFilter && pMedium->GetFilter()->GetFilterName() == pFilter->GetFilterName(); bNoPreserveForOasis = ( (aODFVersion.equals( ODFVER_012_TEXT ) && nVersion == SvtSaveOptions::ODFVER_011) || @@ -1473,9 +1479,10 @@ sal_Bool SfxObjectShell::SaveTo_Impl } - if ( bOk && GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) + if ( bOk && GetCreateMode() != SFX_CREATE_MODE_EMBEDDED && !bPasswdProvided ) { // store the thumbnail representation image + // the thumbnail is not stored in case of encrypted document AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Thumbnail creation." ) ) ); if ( !GenerateAndStoreThumbnail( bPasswdProvided, sal_False, @@ -1594,120 +1601,115 @@ sal_Bool SfxObjectShell::SaveTo_Impl bOk = SaveChildren( TRUE ); } - // if ODF version of oasis format changes on saving the signature should not be preserved - if ( bOk && bTryToPreservScriptSignature && bNoPreserveForOasis ) - bTryToPreservScriptSignature = ( SotStorage::GetVersion( rMedium.GetStorage() ) == SOFFICE_FILEFORMAT_60 ); - - uno::Reference< security::XDocumentDigitalSignatures > xDDSigns; - sal_Bool bScriptSignatureIsCopied = sal_False; - if ( bOk && bTryToPreservScriptSignature ) + if ( bOk ) { - // if the scripting code was not changed and it is signed the signature should be preserved - // unfortunately at this point we have only information whether the basic code has changed or not - // so the only way is to check the signature if the basic was not changed - try - { - xDDSigns = uno::Reference< security::XDocumentDigitalSignatures >( - comphelper::getProcessServiceFactory()->createInstance( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), - uno::UNO_QUERY_THROW ); + // if ODF version of oasis format changes on saving the signature should not be preserved + if ( bOk && bTryToPreserveScriptSignature && bNoPreserveForOasis ) + bTryToPreserveScriptSignature = ( SotStorage::GetVersion( rMedium.GetStorage() ) == SOFFICE_FILEFORMAT_60 ); - ::rtl::OUString aScriptSignName = xDDSigns->getScriptingContentSignatureDefaultStreamName(); + uno::Reference< security::XDocumentDigitalSignatures > xDDSigns; + if ( bOk && bTryToPreserveScriptSignature ) + { + AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Copying scripting signature." ) ) ); - if ( aScriptSignName.getLength() ) + // if the scripting code was not changed and it is signed the signature should be preserved + // unfortunately at this point we have only information whether the basic code has changed or not + // so the only way is to check the signature if the basic was not changed + try { - uno::Reference< embed::XStorage > xMetaInf = GetStorage()->openStorageElement( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) ), - embed::ElementModes::READ ); - uno::Reference< embed::XStorage > xTargetMetaInf = rMedium.GetStorage()->openStorageElement( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) ), - embed::ElementModes::WRITE ); - - if ( xMetaInf.is() && xTargetMetaInf.is() ) + // get the ODF version of the new medium + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[0] <<= ::rtl::OUString(); + try + { + uno::Reference < beans::XPropertySet > xPropSet( rMedium.GetStorage(), uno::UNO_QUERY_THROW ); + aArgs[0] = xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) ); + } + catch( uno::Exception& ) { - xMetaInf->copyElementTo( aScriptSignName, xTargetMetaInf, aScriptSignName ); - - // after loading the UseCommonStoragePassword property might be set to true - // set it to false here, since this is a rare case when it must be so - // TODO/LATER: in future it should be done on loading probably - uno::Reference< beans::XPropertySet > xTargetSignPropSet( - xTargetMetaInf->openStreamElement( aScriptSignName, embed::ElementModes::WRITE ), - uno::UNO_QUERY_THROW ); - xTargetSignPropSet->setPropertyValue( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseCommonStoragePasswordEncryption" ) ), - uno::makeAny( (sal_Bool)sal_False ) ); - - uno::Reference< embed::XTransactedObject > xTransact( xTargetMetaInf, uno::UNO_QUERY ); - if ( xTransact.is() ) - xTransact->commit(); - bScriptSignatureIsCopied = sal_True; } - } - } - catch( uno::Exception& ) - { - } - } - - if ( bOk ) - { - AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Medium commit." ) ) ); - // transfer data to its destinated location - // the medium commits the storage or the stream it is based on - RegisterTransfer( rMedium ); - bOk = rMedium.Commit(); + xDDSigns = uno::Reference< security::XDocumentDigitalSignatures >( + comphelper::getProcessServiceFactory()->createInstanceWithArguments( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ), + aArgs ), + uno::UNO_QUERY_THROW ); - if ( bOk && bScriptSignatureIsCopied ) - { - AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Script signature check." ) ) ); + ::rtl::OUString aScriptSignName = xDDSigns->getScriptingContentSignatureDefaultStreamName(); - // if the script signature was copied it should be checked now - // usually it should be ok, so no additional actions will be done - // but if for any reasong ( f.e. binshell change ) it is broken it should be removed here - // in result the behaviour will work in optimized way in most cases, means in case of signed basic scripts - OSL_ENSURE( !bScriptSignatureIsCopied || xDDSigns.is(), "The signing could not be done without the service!\n" ); - if ( xDDSigns.is() ) - { - try + if ( aScriptSignName.getLength() ) { - bOk = sal_False; - ::com::sun::star::uno::Sequence< security::DocumentSignatureInformation > aInfos = - xDDSigns->verifyScriptingContentSignatures( rMedium.GetLastCommitReadStorage_Impl(), - uno::Reference< io::XInputStream >() ); - sal_uInt16 nState = ImplCheckSignaturesInformation( aInfos ); - if ( nState == SIGNATURESTATE_SIGNATURES_OK || nState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED ) - { - rMedium.SetCachedSignatureState_Impl( nState ); - bOk = sal_True; - } - else + pMedium->Close(); + + // target medium is still not commited, it should not be closed + // commit the package storage and close it, but leave the streams open + rMedium.StorageCommit_Impl(); + rMedium.CloseStorage(); + + uno::Reference< embed::XStorage > xReadOrig = pMedium->GetZipStorageToSign_Impl(); + if ( !xReadOrig.is() ) + throw uno::RuntimeException(); + uno::Reference< embed::XStorage > xMetaInf = xReadOrig->openStorageElement( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) ), + embed::ElementModes::READ ); + + uno::Reference< embed::XStorage > xTarget = rMedium.GetZipStorageToSign_Impl( sal_False ); + if ( !xTarget.is() ) + throw uno::RuntimeException(); + uno::Reference< embed::XStorage > xTargetMetaInf = xTarget->openStorageElement( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) ), + embed::ElementModes::READWRITE ); + + if ( xMetaInf.is() && xTargetMetaInf.is() ) { - // the signature is broken, remove it - rMedium.SetCachedSignatureState_Impl( SIGNATURESTATE_NOSIGNATURES ); - uno::Reference< embed::XStorage > xTargetMetaInf = rMedium.GetStorage()->openStorageElement( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) ), - embed::ElementModes::WRITE ); + xMetaInf->copyElementTo( aScriptSignName, xTargetMetaInf, aScriptSignName ); + + uno::Reference< embed::XTransactedObject > xTransact( xTargetMetaInf, uno::UNO_QUERY ); + if ( xTransact.is() ) + xTransact->commit(); - if ( xTargetMetaInf.is() ) + xTargetMetaInf->dispose(); + + // now check the copied signature + uno::Sequence< security::DocumentSignatureInformation > aInfos = + xDDSigns->verifyScriptingContentSignatures( xTarget, + uno::Reference< io::XInputStream >() ); + sal_uInt16 nState = ImplCheckSignaturesInformation( aInfos ); + if ( nState == SIGNATURESTATE_SIGNATURES_OK || nState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED + || nState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK) { - xTargetMetaInf->removeElement( xDDSigns->getScriptingContentSignatureDefaultStreamName() ); - uno::Reference< embed::XTransactedObject > xTransact( xTargetMetaInf, uno::UNO_QUERY ); + rMedium.SetCachedSignatureState_Impl( nState ); + + // commit the ZipStorage from target medium + xTransact.set( xTarget, uno::UNO_QUERY ); if ( xTransact.is() ) xTransact->commit(); - - bOk = rMedium.Commit(); + } + else + { + // it should not happen, the copies signature is invalid! + // throw the changes away + OSL_ASSERT( "An invalid signature was copied!" ); } } } - catch( uno::Exception ) - { - OSL_ENSURE( sal_False, "This exception must not happen!" ); - } } + catch( uno::Exception& ) + { + } + + pMedium->Close(); + rMedium.CloseZipStorage_Impl(); } + AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Medium commit." ) ) ); + + // transfer data to its destinated location + // the medium commits the storage or the stream it is based on + RegisterTransfer( rMedium ); + bOk = rMedium.Commit(); + if ( bOk ) { AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Storing is successful." ) ) ); diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 26ba76517d8c..95ba194df0cb 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -265,6 +265,7 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,m_bCreateTempStor( sal_False ) ,m_xDocInfoListener() ,m_bIsInit( sal_False ) + ,m_bIncomplEncrWarnShown( sal_False ) { } @@ -368,7 +369,7 @@ SfxObjectShell::~SfxObjectShell() pImp->xModel = ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > (); // don't call GetStorage() here, in case of Load Failure it's possible that a storage was never assigned! - if ( pMedium && pMedium->HasStorage_Impl() && pMedium->GetStorage() == pImp->m_xDocStorage ) + if ( pMedium && pMedium->HasStorage_Impl() && pMedium->GetStorage( sal_False ) == pImp->m_xDocStorage ) pMedium->CanDisposeStorage_Impl( sal_False ); if ( pImp->mpObjectContainer ) diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index d4b0b3aaf7ab..29219942be01 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -2850,19 +2850,9 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL // TODO/LATER: a general way to set the error context should be available SfxErrorContext aEc( ERRCTX_SFX_SAVEASDOC, m_pData->m_pObjectShell->GetTitle() ); - ::com::sun::star::uno::Any aInteraction; - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > lContinuations(1); - ::framework::ContinuationApprove* pApprove = new ::framework::ContinuationApprove(); - lContinuations[0] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >(static_cast< ::com::sun::star::task::XInteractionContinuation* >(pApprove), uno::UNO_QUERY); - ::com::sun::star::task::ErrorCodeRequest aErrorCode; aErrorCode.ErrCode = nErrCode; - aInteraction <<= aErrorCode; - - ::framework::InteractionRequest* pRequest = new ::framework::InteractionRequest(aInteraction,lContinuations); - ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest > xRequest(static_cast< ::com::sun::star::task::XInteractionRequest* >(pRequest), uno::UNO_QUERY); - - xHandler->handle(xRequest); + SfxMedium::CallApproveHandler( xHandler, uno::makeAny( aErrorCode ), sal_False ); } } diff --git a/sfx2/source/inc/helper.hxx b/sfx2/source/inc/helper.hxx index d246c1f70830..16eabab43a7e 100644 --- a/sfx2/source/inc/helper.hxx +++ b/sfx2/source/inc/helper.hxx @@ -70,7 +70,6 @@ public: static sal_Bool MakeFolder( const String& rFolder ); static ErrCode QueryDiskSpace( const String& rPath, sal_Int64& rFreeBytes ); static ULONG GetSize( const String& rContent ); - static sal_Bool IsYounger( const String& rIsYoung, const String& rIsOlder ); // please don't use this! static sal_Bool Exists( const String& rContent ); diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx index eb8719435406..3b92971fabff 100644 --- a/sfx2/source/inc/objshimp.hxx +++ b/sfx2/source/inc/objshimp.hxx @@ -171,6 +171,9 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess ::com::sun::star::uno::Reference< ::com::sun::star::logging::XSimpleLogRing > m_xLogRing; + sal_Bool m_bIncomplEncrWarnShown; + + SfxObjectShell_Impl( SfxObjectShell& _rDocShell ); virtual ~SfxObjectShell_Impl(); @@ -180,10 +183,12 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess virtual sal_Int16 getCurrentMacroExecMode() const; virtual sal_Bool setCurrentMacroExecMode( sal_uInt16 nMacroMode ); virtual ::rtl::OUString getDocumentLocation() const; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > getLastCommitDocumentStorage(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > getZipStorageToSign(); virtual sal_Bool documentStorageHasMacros() const; virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XEmbeddedScripts > getEmbeddedDocumentScripts() const; - virtual sal_Int16 getScriptingSignatureState() const; + virtual sal_Int16 getScriptingSignatureState(); + + virtual sal_Bool hasTrustedScriptingSignature( sal_Bool bAllowUIToAddAuthor ); virtual void showBrokenSignatureWarning( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxInteraction ) const; }; diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 0769a782de86..1097ae9cdc8f 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -77,6 +77,7 @@ #include #include +#include #include #include @@ -453,7 +454,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) // to the logical one, then on file system it can be checked that the copy is still newer than the original and no document reload is required if ( ( !bNeedsReload && ( (aMedObj.GetProtocol() == INET_PROT_FILE && aMedObj.getFSysPath(INetURLObject::FSYS_DETECT) != aPhysObj.getFSysPath(INetURLObject::FSYS_DETECT) && - SfxContentHelper::IsYounger( aPhysObj.GetMainURL( INetURLObject::NO_DECODE ), aMedObj.GetMainURL( INetURLObject::NO_DECODE ) )) + !::utl::UCBContentHelper::IsYounger( aMedObj.GetMainURL( INetURLObject::NO_DECODE ), aPhysObj.GetMainURL( INetURLObject::NO_DECODE ) )) || pMed->IsRemote() ) ) || pVersionItem ) { @@ -716,7 +717,9 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) // eigentliches Reload //pNewSet->Put( SfxFrameItem ( SID_DOCFRAME, GetFrame() ) ); - //pNewSet->Put( SfxBoolItem( SID_SILENT, sal_True ) ); + + if ( pSilentItem && pSilentItem->GetValue() ) + pNewSet->Put( SfxBoolItem( SID_SILENT, sal_True ) ); SFX_ITEMSET_ARG(pNewSet, pInteractionItem, SfxUnoAnyItem, SID_INTERACTIONHANDLER, FALSE); SFX_ITEMSET_ARG(pNewSet, pMacroExecItem , SfxUInt16Item, SID_MACROEXECMODE , FALSE); @@ -820,6 +823,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) } xNewObj->GetMedium()->GetItemSet()->ClearItem( SID_RELOAD ); + xNewObj->GetMedium()->GetItemSet()->ClearItem( SID_SILENT ); UpdateDocument_Impl(); } -- cgit From 49c5701fbbc6a93ca0410719564ee22b5166ee48 Mon Sep 17 00:00:00 2001 From: Jens-Heiner Rechtien Date: Thu, 17 Sep 2009 14:41:33 +0000 Subject: CWS-TOOLING: integrate CWS kso32fixes2 2009-09-14 kso #i104767# - 64 bit build breaker 2009-09-14 kso #i14767# - compiler warning 2009-09-08 kso i104767# - Removed obsolete header. 2009-09-08 kso i104767# - Removed obsolete header include. 2009-09-08 kso #i104767# - Fixed build breaker. 2009-09-07 kso #i104767# - merged in dev300 m57. 2009-09-07 kso #i104767# - support for system credentials usage 2009-09-07 kso #i104767# - support for system credentials usage 2009-09-07 kso #i104767# - support for system credentials usage 2009-09-07 kso #i104767# - support for system credentials usage 2009-09-07 kso #i104767# - support for system credentials usage 2009-09-07 Kai Sommerfeld #i104767# - support for system credentials usage 2009-09-07 Kai Sommerfeld #i104767# - support for system credentials usage 2009-09-07 ks93798 #i104767# - adaptions for NTLM SSO --- sfx2/inc/pch/precompiled_sfx2.hxx | 1 - sfx2/source/appl/appdata.cxx | 1 - 2 files changed, 2 deletions(-) (limited to 'sfx2') diff --git a/sfx2/inc/pch/precompiled_sfx2.hxx b/sfx2/inc/pch/precompiled_sfx2.hxx index ad70b76f27ff..0de2e2e208d1 100644 --- a/sfx2/inc/pch/precompiled_sfx2.hxx +++ b/sfx2/inc/pch/precompiled_sfx2.hxx @@ -542,7 +542,6 @@ #include "svtools/lckbitem.hxx" #include "svtools/localisationoptions.hxx" #include "svtools/localresaccess.hxx" -#include "svtools/loginerr.hxx" #include "svtools/lstner.hxx" #include "svtools/memberid.hrc" #include "svtools/menuoptions.hxx" diff --git a/sfx2/source/appl/appdata.cxx b/sfx2/source/appl/appdata.cxx index 243c4c325fcd..23de7317c379 100644 --- a/sfx2/source/appl/appdata.cxx +++ b/sfx2/source/appl/appdata.cxx @@ -42,7 +42,6 @@ #include #include -#include #include #include #include -- cgit From c7e172b2d9036c788fe00552ded841340d115033 Mon Sep 17 00:00:00 2001 From: Jens-Heiner Rechtien Date: Fri, 18 Sep 2009 10:15:03 +0000 Subject: CWS-TOOLING: integrate CWS mba32issues02 2009-09-17 mb93783 merge commit 2009-09-03 tb121644 #i104748 - slot unification to .uno:PasteSpecial 2009-09-01 mba #101455#: code simplification 2009-08-31 mb93783 iso locales for norwegian builds are nb and nn, not no 2009-08-25 mba merge to m55 2009-07-29 mba cleanup after rebase 2009-07-29 mba #i103200#: wrong order of first and last name in CJK UI 2009-07-27 mba adding dictionary changes from broken svn CWS 2009-07-27 mba adding dictionary changes from broken svn CWS 2009-07-27 mba apply patch from broken svn CWS --- sfx2/inc/sfx2/dinfdlg.hxx | 6 +- sfx2/inc/sfx2/event.hxx | 37 +-- sfx2/inc/sfx2/evntconf.hxx | 31 +- sfx2/inc/sfx2/objsh.hxx | 2 +- sfx2/inc/sfx2/sfx.hrc | 3 + sfx2/inc/sfx2/sfxbasemodel.hxx | 2 +- sfx2/inc/sfx2/sfxsids.hrc | 6 +- sfx2/inc/sfx2/viewsh.hxx | 6 + sfx2/sdi/appslots.sdi | 8 - sfx2/sdi/sfx.sdi | 129 ++++----- sfx2/sdi/sfxslots.sdi | 1 + sfx2/source/appl/app.cxx | 4 +- sfx2/source/appl/app.hrc | 16 - sfx2/source/appl/app.src | 71 ----- sfx2/source/appl/appcfg.cxx | 20 +- sfx2/source/appl/appinit.cxx | 33 --- sfx2/source/appl/appserv.cxx | 17 +- sfx2/source/config/evntconf.cxx | 418 ++++---------------------- sfx2/source/control/bindings.cxx | 515 +-------------------------------- sfx2/source/dialog/dinfdlg.cxx | 26 +- sfx2/source/doc/makefile.mk | 2 +- sfx2/source/doc/objcont.cxx | 48 --- sfx2/source/doc/objembed.cxx | 2 +- sfx2/source/doc/objmisc.cxx | 10 +- sfx2/source/doc/objstor.cxx | 6 +- sfx2/source/doc/objxtor.cxx | 100 +------ sfx2/source/doc/sfxbasemodel.cxx | 34 ++- sfx2/source/doc/sfxbasemodel.src | 94 ------ sfx2/source/inc/eventsupplier.hxx | 3 - sfx2/source/inc/objshimp.hxx | 4 +- sfx2/source/notify/eventsupplier.cxx | 26 +- sfx2/source/view/frame.cxx | 2 +- sfx2/source/view/frmload.cxx | 139 +++++---- sfx2/source/view/prnmon.cxx | 2 +- sfx2/source/view/sfxbasecontroller.cxx | 4 +- sfx2/source/view/topfrm.cxx | 5 +- sfx2/source/view/viewfrm.cxx | 22 +- sfx2/source/view/viewimp.hxx | 17 ++ sfx2/source/view/viewprn.cxx | 51 +++- sfx2/source/view/viewsh.cxx | 98 ++++++- 40 files changed, 522 insertions(+), 1498 deletions(-) delete mode 100644 sfx2/source/doc/sfxbasemodel.src (limited to 'sfx2') diff --git a/sfx2/inc/sfx2/dinfdlg.hxx b/sfx2/inc/sfx2/dinfdlg.hxx index 1873c6e6c88e..27da2810d49e 100644 --- a/sfx2/inc/sfx2/dinfdlg.hxx +++ b/sfx2/inc/sfx2/dinfdlg.hxx @@ -417,12 +417,14 @@ private: ImageButton m_aRemoveButton; sal_Int32 m_nLineHeight; + sal_Int32 m_nScrollPos; SvtSysLocale m_aSysLocale; std::vector< CustomPropertyLine* > m_aCustomPropertiesLines; CustomPropertyLine* m_pCurrentLine; SvNumberFormatter m_aNumberFormatter; Timer m_aEditLoseFocusTimer; Timer m_aBoxLoseFocusTimer; + Link m_aRemovedHdl; DECL_LINK( TypeHdl, CustomPropertiesTypeBox* ); DECL_LINK( RemoveHdl, CustomPropertiesRemoveButton* ); @@ -449,6 +451,7 @@ public: bool DoesCustomPropertyExist( const String& rName ) const; ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > GetCustomProperties() const; + void SetRemovedHdl( const Link& rLink ) { m_aRemovedHdl = rLink; } }; // class CustomPropertiesControl ----------------------------------------- @@ -466,12 +469,13 @@ private: void Initialize(); DECL_LINK( ScrollHdl, ScrollBar* ); + DECL_LINK( RemovedHdl, void* ); public: CustomPropertiesControl( Window* pParent, const ResId& rResId ); ~CustomPropertiesControl(); - void AddLine( const ::rtl::OUString& sName, com::sun::star::uno::Any& rAny ); + void AddLine( const ::rtl::OUString& sName, com::sun::star::uno::Any& rAny, bool bInteractive ); inline bool AreAllLinesValid() const { return m_aPropertiesWin.AreAllLinesValid(); } inline void ClearAllLines() { m_aPropertiesWin.ClearAllLines(); } diff --git a/sfx2/inc/sfx2/event.hxx b/sfx2/inc/sfx2/event.hxx index cd83103c8196..653fa2eeb7d8 100644 --- a/sfx2/inc/sfx2/event.hxx +++ b/sfx2/inc/sfx2/event.hxx @@ -34,6 +34,8 @@ #include "sfx2/dllapi.h" #include #include +#include +#include #include #include @@ -44,33 +46,24 @@ class SfxObjectShell; class SFX2_DLLPUBLIC SfxEventHint : public SfxHint { - USHORT nEventId; SfxObjectShell* pObjShell; - String _aArgs; - BOOL _bDummy; - BOOL _bAddToHistory; + ::rtl::OUString aEventName; + USHORT nEventId; public: TYPEINFO(); - SfxEventHint( USHORT nId, - const String& rArgs, - SfxObjectShell *pObj = 0 ) - : nEventId(nId), - pObjShell(pObj), - _aArgs( rArgs ), - _bAddToHistory(FALSE) - {} - SfxEventHint( USHORT nId, SfxObjectShell *pObj = 0 ) - : nEventId(nId), - pObjShell(pObj), - _bAddToHistory(FALSE) + SfxEventHint( USHORT nId, const ::rtl::OUString& aName, SfxObjectShell *pObj = 0 ) + : pObjShell(pObj), + aEventName(aName), + nEventId(nId) {} - const String& GetArgs() const { return _aArgs;} - USHORT GetEventId() const { return nEventId; } + ::rtl::OUString GetEventName() const + { return aEventName; } + SfxObjectShell* GetObjShell() const { return pObjShell; } }; @@ -82,8 +75,6 @@ class SfxNamedHint : public SfxHint String _aEventName; SfxObjectShell* _pObjShell; String _aArgs; - BOOL _bDummy; - BOOL _bAddToHistory; public: TYPEINFO(); @@ -93,15 +84,13 @@ public: SfxObjectShell *pObj = 0 ) : _aEventName( rName ), _pObjShell( pObj), - _aArgs( rArgs ), - _bAddToHistory( FALSE ) + _aArgs( rArgs ) {} SfxNamedHint( const String& rName, SfxObjectShell *pObj = 0 ) : _aEventName( rName ), - _pObjShell( pObj ), - _bAddToHistory( FALSE ) + _pObjShell( pObj ) {} const String& GetArgs() const { return _aArgs;} diff --git a/sfx2/inc/sfx2/evntconf.hxx b/sfx2/inc/sfx2/evntconf.hxx index 51362c14c309..cfe8629cd0cf 100644 --- a/sfx2/inc/sfx2/evntconf.hxx +++ b/sfx2/inc/sfx2/evntconf.hxx @@ -118,36 +118,9 @@ public: class SFX2_DLLPUBLIC SfxEventConfiguration { -friend class SfxEventConfigItem_Impl; - - SvxMacroTableDtor* pAppTable; - SvxMacroTableDtor* pDocTable; - sal_Bool bIgnoreConfigure; - public: - SfxEventConfiguration(); - ~SfxEventConfiguration(); - - void ConfigureEvent(USHORT nId, const SvxMacro&, - SfxObjectShell* pObjSh); - void ConfigureEvent(USHORT nId, const String& rMacro, - SfxObjectShell* pObjSh); - - SvxMacroTableDtor* GetDocEventTable(SfxObjectShell*); - - static void RegisterEvent( USHORT nId, const String& rName, - const String& rMacroName ); - - SAL_DLLPRIVATE BOOL Warn_Impl( SfxObjectShell *pDoc, const SvxMacro* pMacro ); - SAL_DLLPRIVATE void PropagateEvent_Impl( SfxObjectShell *pDoc, - USHORT nId, - const SvxMacro* pMacro ); - SAL_DLLPRIVATE static rtl::OUString GetEventName_Impl( ULONG nID ); - SAL_DLLPRIVATE static ULONG GetEventId_Impl( const rtl::OUString& rEventName ); - SAL_DLLPRIVATE ::com::sun::star::uno::Any CreateEventData_Impl( const SvxMacro *pMacro ); - - SAL_DLLPRIVATE static ULONG GetPos_Impl( USHORT nID, sal_Bool &rFound ); - SAL_DLLPRIVATE static ULONG GetPos_Impl( const String& rName, sal_Bool &rFound ); + static void ConfigureEvent( ::rtl::OUString aName, const SvxMacro&, SfxObjectShell* pObjSh); + static SvxMacro* ConvertToMacro( const com::sun::star::uno::Any& rElement, SfxObjectShell* pDoc, BOOL bBlowUp ); }; #endif diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 56369a8ea936..7e3813584de9 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -734,7 +734,7 @@ public: const ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation >& aInfos ); SAL_DLLPRIVATE void CheckEncryption_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ); - SAL_DLLPRIVATE static SEQUENCE< OUSTRING > GetEventNames_Impl(); + SAL_DLLPRIVATE SEQUENCE< OUSTRING > GetEventNames_Impl(); SAL_DLLPRIVATE void InitBasicManager_Impl(); SAL_DLLPRIVATE SfxObjectShell_Impl* Get_Impl() { return pImp; } diff --git a/sfx2/inc/sfx2/sfx.hrc b/sfx2/inc/sfx2/sfx.hrc index fbc5e6f58d1c..1605f689471f 100644 --- a/sfx2/inc/sfx2/sfx.hrc +++ b/sfx2/inc/sfx2/sfx.hrc @@ -111,6 +111,9 @@ #define SFX_EVENT_SAVEDOCFAILED (EVENT_SFX_START + 28) #define SFX_EVENT_SAVETODOCFAILED (EVENT_SFX_START + 29) +#define SFX_EVENT_TITLECHANGED (EVENT_SFX_START + 30) +#define SFX_EVENT_MODECHANGED (EVENT_SFX_START + 31) + // Events f"ur Controls etc. #define SFX_EVENT_MOUSEOVER_OBJECT ( EVENT_SFX_START + 100 ) #define SFX_EVENT_MOUSECLICK_OBJECT ( EVENT_SFX_START + 101 ) diff --git a/sfx2/inc/sfx2/sfxbasemodel.hxx b/sfx2/inc/sfx2/sfxbasemodel.hxx index 324080484c81..6ef67b6a009a 100644 --- a/sfx2/inc/sfx2/sfxbasemodel.hxx +++ b/sfx2/inc/sfx2/sfxbasemodel.hxx @@ -1513,7 +1513,7 @@ private: SAL_DLLPRIVATE void impl_store( const OUSTRING& sURL , const SEQUENCE< PROPERTYVALUE >& seqArguments , sal_Bool bSaveTo ) ; - SAL_DLLPRIVATE void postEvent_Impl( ULONG nEventID ); + SAL_DLLPRIVATE void postEvent_Impl( ::rtl::OUString ); SAL_DLLPRIVATE String getEventName_Impl( long nID ); SAL_DLLPRIVATE void NotifyStorageListeners_Impl(); SAL_DLLPRIVATE bool QuerySaveSizeExceededModules( const com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >& xHandler ); diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index 545464e09433..c15c09a09384 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -140,8 +140,10 @@ //#define SID_TITLE (SID_SFX_START + 307) #define SID_CONTEXT (SID_SFX_START + 310) -#define SID_CURRENTTIME (SID_SFX_START + 311) -#define SID_CURRENTDATE (SID_SFX_START + 312) + +#define SID_PASTE_SPECIAL (SID_SFX_START + 311) +#define SID_CLIPBOARD_FORMAT_ITEMS (SID_SFX_START + 312) + #define SID_VERSION_VISIBLE (SID_SFX_START + 313) #define SID_PASTE_UNFORMATTED (SID_SFX_START + 314) #define SID_PRINTER_NOTFOUND_WARN (SID_SFX_START + 320) diff --git a/sfx2/inc/sfx2/viewsh.hxx b/sfx2/inc/sfx2/viewsh.hxx index 3dd4ff3d63a7..d0ac30a9fcd9 100644 --- a/sfx2/inc/sfx2/viewsh.hxx +++ b/sfx2/inc/sfx2/viewsh.hxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include "shell.hxx" #include @@ -77,6 +78,9 @@ class NotifyEvent; #define SFX_PRINTER_CHG_ORIENTATION_FLAG 3 #define SFX_PRINTER_CHG_SIZE_FLAG 4 +#define SFX_PRINTERROR_NONE 0 +#define SFX_PRINTERROR_BUSY 1 + enum SfxScrollingMode { SCROLLING_NO, @@ -302,6 +306,8 @@ public: void SetAdditionalPrintOptions( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& ); + void AddRemoveClipboardListener( const com::sun::star::uno::Reference < com::sun::star::datatransfer::clipboard::XClipboardListener>&, BOOL ); + #if _SOLAR__PRIVATE SAL_DLLPRIVATE SfxInPlaceClient* GetUIActiveIPClient_Impl() const; SAL_DLLPRIVATE void AddContextMenuInterceptor_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::ui::XContextMenuInterceptor >& xInterceptor ); diff --git a/sfx2/sdi/appslots.sdi b/sfx2/sdi/appslots.sdi index 61b897baceae..5da69fa977f3 100644 --- a/sfx2/sdi/appslots.sdi +++ b/sfx2/sdi/appslots.sdi @@ -92,14 +92,6 @@ interface Application ExecMethod = MiscExec_Impl ; StateMethod = MiscState_Impl ; ] - SID_CURRENTTIME // ole(no) api(final/play/norec) - [ - StateMethod = MiscState_Impl ; - ] - SID_CURRENTDATE // ole(no) api(final/play/norec) - [ - StateMethod = MiscState_Impl ; - ] SID_LOADCONFIG // ole(no) api(final/play) [ ExecMethod = MiscExec_Impl ; diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index db625a9386c3..26f55ccdd178 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -853,7 +853,7 @@ SfxBoolItem BrowseView SID_BROWSER_MODE [ /* flags: */ AutoUpdate = TRUE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -1041,7 +1041,7 @@ SfxVoidItem ClearHistory SID_CLEARHISTORY [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -1446,60 +1446,6 @@ SfxVoidItem CreateMacro SID_BASICIDE_CREATEMACRO GroupId = GID_MACRO; ] -//-------------------------------------------------------------------------- -SfxStringItem CurrentDate SID_CURRENTDATE - -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Volatile, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - Readonly = TRUE, - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = TRUE, - ToolBoxConfig = FALSE, - GroupId = GID_VIEW; -] - -//-------------------------------------------------------------------------- -SfxStringItem CurrentTime SID_CURRENTTIME - -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Volatile, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - Readonly = TRUE, - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = TRUE, - ToolBoxConfig = FALSE, - GroupId = GID_VIEW; -] - //-------------------------------------------------------------------------- SfxStringItem CurrentURL SID_CURRENT_URL @@ -1842,7 +1788,7 @@ SfxBoolItem EditDoc SID_EDITDOC [ /* flags: */ AutoUpdate = TRUE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -4287,7 +4233,7 @@ SfxBoolItem Modified SID_MODIFIED [ /* flags: */ AutoUpdate = TRUE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -5015,7 +4961,7 @@ SfxVoidItem Paste SID_PASTE [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = TRUE, HasCoreId = FALSE, HasDialog = FALSE, @@ -5034,6 +4980,59 @@ SfxVoidItem Paste SID_PASTE GroupId = GID_EDIT; ] +//-------------------------------------------------------------------------- +SfxVoidItem ClipboardFormatItems SID_CLIPBOARD_FORMAT_ITEMS +(SfxUInt32Item SelectedFormat SID_CLIPBOARD_FORMAT_ITEMS) +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = TRUE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* status: */ + SlotType = SvxClipboardFmtItem + + /* config: */ + AccelConfig = FALSE, + MenuConfig = FALSE, + StatusBarConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = GID_EDIT; +] + +//-------------------------------------------------------------------------- +SfxInt16Item PasteSpecial SID_PASTE_SPECIAL +(SfxUInt32Item Format SID_PASTE_SPECIAL) +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = TRUE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Asynchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_EDIT; +] + //-------------------------------------------------------------------------- SfxStringItem DocPath SID_DOCPATH @@ -5486,7 +5485,7 @@ SfxVoidItem Redo SID_REDO [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -5539,7 +5538,7 @@ SfxBoolItem Reload SID_RELOAD [ /* flags: */ AutoUpdate = TRUE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -5643,7 +5642,7 @@ SfxStringItem RepeatAction SID_REPEAT /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -5747,7 +5746,7 @@ SfxBoolItem Save SID_SAVEDOC [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = TRUE, HasCoreId = FALSE, HasDialog = FALSE, @@ -7179,7 +7178,7 @@ SfxVoidItem Undo SID_UNDO [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -8809,7 +8808,7 @@ SfxInt16Item PasteUnformatted SID_PASTE_UNFORMATTED [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = TRUE, HasCoreId = FALSE, HasDialog = FALSE, diff --git a/sfx2/sdi/sfxslots.sdi b/sfx2/sdi/sfxslots.sdi index 27336865be73..e439e8c776a0 100644 --- a/sfx2/sdi/sfxslots.sdi +++ b/sfx2/sdi/sfxslots.sdi @@ -59,6 +59,7 @@ TypeLibFile( "sfxslots.tlb" ) item String SfxFrameItem; //! Dummy item String SfxObjectShellItem //! Dummy item String SfxUsrAnyItem //! Dummy + item String SvxClipboardFmtItem; //! Dummy struct Point { diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx index d74bbd0961d9..53ea87703ac6 100644 --- a/sfx2/source/appl/app.cxx +++ b/sfx2/source/appl/app.cxx @@ -505,7 +505,7 @@ void SfxApplication::SetViewFrame_Impl( SfxViewFrame *pFrame ) if ( pOldContainerFrame ) { if ( bTaskActivate ) - NotifyEvent( SfxEventHint( SFX_EVENT_DEACTIVATEDOC, pOldContainerFrame->GetObjectShell() ) ); + NotifyEvent( SfxEventHint( SFX_EVENT_DEACTIVATEDOC, GlobalEventConfig::GetEventName(STR_EVENT_DEACTIVATEDOC), pOldContainerFrame->GetObjectShell() ) ); pOldContainerFrame->DoDeactivate( bTaskActivate, pFrame ); if( pOldContainerFrame->GetProgress() ) @@ -529,7 +529,7 @@ void SfxApplication::SetViewFrame_Impl( SfxViewFrame *pFrame ) if ( bTaskActivate && pNewContainerFrame->GetObjectShell() ) { pNewContainerFrame->GetObjectShell()->PostActivateEvent_Impl( pNewContainerFrame ); - NotifyEvent(SfxEventHint(SFX_EVENT_ACTIVATEDOC, pNewContainerFrame->GetObjectShell() ) ); + NotifyEvent(SfxEventHint(SFX_EVENT_ACTIVATEDOC, GlobalEventConfig::GetEventName(STR_EVENT_ACTIVATEDOC), pNewContainerFrame->GetObjectShell() ) ); } SfxProgress *pProgress = pNewContainerFrame->GetProgress(); diff --git a/sfx2/source/appl/app.hrc b/sfx2/source/appl/app.hrc index 5969833e449a..c08f46effc81 100644 --- a/sfx2/source/appl/app.hrc +++ b/sfx2/source/appl/app.hrc @@ -78,27 +78,11 @@ #define RID_RECORDINGTOOLBOX (RID_SFX_APP_START+43) #define RID_ENVTOOLBOX (RID_SFX_APP_START+44) -#define STR_EVENT_STARTAPP (RID_SFX_APP_START+50) -#define STR_EVENT_CLOSEAPP (RID_SFX_APP_START+51) -#define STR_EVENT_CREATEDOC (RID_SFX_APP_START+52) -#define STR_EVENT_OPENDOC (RID_SFX_APP_START+53) -#define STR_EVENT_CLOSEDOC (RID_SFX_APP_START+54) -#define STR_EVENT_SAVEDOC (RID_SFX_APP_START+55) -#define STR_EVENT_SAVEASDOC (RID_SFX_APP_START+56) -#define STR_EVENT_ACTIVATEDOC (RID_SFX_APP_START+57) -#define STR_EVENT_DEACTIVATEDOC (RID_SFX_APP_START+58) -#define STR_EVENT_ONERROR (RID_SFX_APP_START+78) -#define STR_EVENT_PREPARECLOSEDOC (RID_SFX_APP_START+89) -#define STR_EVENT_MODIFYCHANGED (RID_SFX_APP_START+90) -#define STR_EVENT_SAVEDOCDONE (RID_SFX_APP_START+95) -#define STR_EVENT_SAVEASDOCDONE (RID_SFX_APP_START+96) - #define STR_QUITAPP (RID_SFX_APP_START+59) #define STR_EXITANDRETURN (RID_SFX_APP_START+60) #define STR_ERR_NOFILE (RID_SFX_APP_START+61) #define STR_EXTHELPSTATUS (RID_SFX_APP_START+62) -#define STR_EVENT_PRINTDOC (RID_SFX_APP_START+64) #define STR_ADDRESS_NAME (RID_SFX_APP_START+65) #define RID_STR_HLPFILENOTEXIST (RID_SFX_APP_START+68) diff --git a/sfx2/source/appl/app.src b/sfx2/source/appl/app.src index eacfefddc689..463788d2d6d0 100644 --- a/sfx2/source/appl/app.src +++ b/sfx2/source/appl/app.src @@ -502,76 +502,6 @@ ToolBox RID_FULLSCREENTOOLBOX }; }; -String STR_EVENT_STARTAPP -{ - Text [ en-US ] = "Start Application" ; -}; - -String STR_EVENT_CLOSEAPP -{ - Text [ en-US ] = "Close Application" ; -}; - -String STR_EVENT_CREATEDOC -{ - Text [ en-US ] = "Create Document" ; -}; - -String STR_EVENT_CLOSEDOC -{ - Text [ en-US ] = "Document closed" ; -}; - -String STR_EVENT_PREPARECLOSEDOC -{ - Text [ en-US ] = "Document is closing" ; -}; - -String STR_EVENT_OPENDOC -{ - Text [ en-US ] = "Open Document" ; -}; - -String STR_EVENT_SAVEDOC -{ - Text [ en-US ] = "Save Document" ; -}; - -String STR_EVENT_SAVEASDOC -{ - Text [ en-US ] = "Save Document As" ; -}; - -String STR_EVENT_SAVEDOCDONE -{ - Text [ en-US ] = "Document has been saved" ; -}; - -String STR_EVENT_SAVEASDOCDONE -{ - Text [ en-US ] = "Document has been saved as" ; -}; - -String STR_EVENT_ACTIVATEDOC -{ - Text [ en-US ] = "Activate Document" ; -}; - -String STR_EVENT_DEACTIVATEDOC -{ - Text [ en-US ] = "Deactivate Document" ; -}; - -String STR_EVENT_PRINTDOC -{ - Text [ en-US ] = "Print Document" ; -}; - -String STR_EVENT_MODIFYCHANGED -{ - Text [ en-US ] = "'Modified' status was changed" ; -}; - String STR_ERR_NOTEMPLATE { Text [ en-US ] = "The selected template has an incorrect format" ; @@ -582,7 +512,6 @@ String STR_ERR_NOFILE Text [ en-US ] = "Can't open file $." ; }; - String STR_QUITAPP { Text [ en-US ] = "E~xit" ; diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx index 17b28c5ab3e6..c191f765200f 100644 --- a/sfx2/source/appl/appcfg.cxx +++ b/sfx2/source/appl/appcfg.cxx @@ -160,10 +160,12 @@ IMPL_LINK(SfxEventAsyncer_Impl, TimerHdl, Timer*, pAsyncTimer) SfxObjectShellRef xRef( aHint.GetObjShell() ); pAsyncTimer->Stop(); #ifdef DBG_UTIL - ::rtl::OUString aName = SfxEventConfiguration::GetEventName_Impl( aHint.GetEventId() ); - ByteString aTmp( "SfxEvent: "); - aTmp += ByteString( String(aName), RTL_TEXTENCODING_UTF8 ); - DBG_TRACE( aTmp.GetBuffer() ); + if (!xRef.Is()) + { + ByteString aTmp( "SfxEvent: "); + aTmp += ByteString( String( aHint.GetEventName() ), RTL_TEXTENCODING_UTF8 ); + DBG_TRACE( aTmp.GetBuffer() ); + } #endif SFX_APP()->Broadcast( aHint ); if ( xRef.Is() ) @@ -1037,7 +1039,7 @@ SfxEventConfiguration* SfxApplication::GetEventConfig() const //-------------------------------------------------------------------- void SfxApplication::NotifyEvent( const SfxEventHint& rEventHint, FASTBOOL bSynchron ) { - DBG_ASSERT(pAppData_Impl->pEventConfig,"Keine Events angemeldet!"); + //DBG_ASSERT(pAppData_Impl->pEventConfig,"Keine Events angemeldet!"); SfxObjectShell *pDoc = rEventHint.GetObjShell(); if ( pDoc && ( pDoc->IsPreview() || !pDoc->Get_Impl()->bInitialized ) ) @@ -1052,6 +1054,14 @@ void SfxApplication::NotifyEvent( const SfxEventHint& rEventHint, FASTBOOL bSync if ( bSynchron ) { +#ifdef DBG_UTIL + if (!pDoc) + { + ByteString aTmp( "SfxEvent: "); + aTmp += ByteString( String( rEventHint.GetEventName() ), RTL_TEXTENCODING_UTF8 ); + DBG_TRACE( aTmp.GetBuffer() ); + } +#endif Broadcast(rEventHint); if ( pDoc ) pDoc->Broadcast( rEventHint ); diff --git a/sfx2/source/appl/appinit.cxx b/sfx2/source/appl/appinit.cxx index 748cbc29c707..98439eb5a6dc 100644 --- a/sfx2/source/appl/appinit.cxx +++ b/sfx2/source/appl/appinit.cxx @@ -144,7 +144,6 @@ void SAL_CALL SfxTerminateListener_Impl::notifyTermination( const EventObject& a pApp->Broadcast( SfxSimpleHint( SFX_HINT_DEINITIALIZING ) ); pApp->Get_Impl()->pAppDispatch->ReleaseAll(); pApp->Get_Impl()->pAppDispatch->release(); - pApp->NotifyEvent(SfxEventHint( SFX_EVENT_CLOSEAPP) ); css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory(); css::uno::Reference< css::document::XEventListener > xGlobalBroadcaster(xSMGR->createInstance(SERVICE_GLOBALEVENTBROADCASTER), css::uno::UNO_QUERY); @@ -301,38 +300,6 @@ FASTBOOL SfxApplication::Initialize_Impl() Registrations_Impl(); -// ::vos::OGuard aGuard( Application::GetSolarMutex() ); - - // TODO/LATER: exchange confusing defines; CREATEDOC -> NEWDOC, DOCCREATED -> CREATEDOC - SfxEventConfiguration::RegisterEvent(SFX_EVENT_STARTAPP, String(SfxResId(STR_EVENT_STARTAPP)), SfxObjectShell::GetEventNames_Impl()[0] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_CLOSEAPP, String(SfxResId(STR_EVENT_CLOSEAPP)), SfxObjectShell::GetEventNames_Impl()[1] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_CREATEDOC, String(SfxResId(STR_EVENT_CREATEDOC)), SfxObjectShell::GetEventNames_Impl()[2] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_OPENDOC, String(SfxResId(STR_EVENT_OPENDOC)), SfxObjectShell::GetEventNames_Impl()[3] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_SAVEASDOC, String(SfxResId(STR_EVENT_SAVEASDOC)), SfxObjectShell::GetEventNames_Impl()[4] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_SAVEASDOCDONE, String(SfxResId(STR_EVENT_SAVEASDOCDONE)), SfxObjectShell::GetEventNames_Impl()[5] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_SAVEDOC, String(SfxResId(STR_EVENT_SAVEDOC)), SfxObjectShell::GetEventNames_Impl()[6] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_SAVEDOCDONE, String(SfxResId(STR_EVENT_SAVEDOCDONE)), SfxObjectShell::GetEventNames_Impl()[7] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_PREPARECLOSEDOC, String(SfxResId(STR_EVENT_PREPARECLOSEDOC)),SfxObjectShell::GetEventNames_Impl()[8] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_CLOSEDOC, String(SfxResId(STR_EVENT_CLOSEDOC)), SfxObjectShell::GetEventNames_Impl()[9] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_ACTIVATEDOC, String(SfxResId(STR_EVENT_ACTIVATEDOC)), SfxObjectShell::GetEventNames_Impl()[10] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_DEACTIVATEDOC, String(SfxResId(STR_EVENT_DEACTIVATEDOC)), SfxObjectShell::GetEventNames_Impl()[11] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_PRINTDOC, String(SfxResId(STR_EVENT_PRINTDOC)), SfxObjectShell::GetEventNames_Impl()[12] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_MODIFYCHANGED, String(SfxResId(STR_EVENT_MODIFYCHANGED)), SfxObjectShell::GetEventNames_Impl()[13] ); - - SfxEventConfiguration::RegisterEvent(SFX_EVENT_SAVETODOC, String(), SfxObjectShell::GetEventNames_Impl()[14] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_SAVETODOCDONE, String(), SfxObjectShell::GetEventNames_Impl()[15] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_VIEWCREATED, String(), SfxObjectShell::GetEventNames_Impl()[16] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_PREPARECLOSEVIEW, String(), SfxObjectShell::GetEventNames_Impl()[17] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_CLOSEVIEW, String(), SfxObjectShell::GetEventNames_Impl()[18] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_VISAREACHANGED, String(), SfxObjectShell::GetEventNames_Impl()[19] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_DOCCREATED, String(), SfxObjectShell::GetEventNames_Impl()[20] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_LOADFINISHED, String(), SfxObjectShell::GetEventNames_Impl()[21] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_SAVEASDOCFAILED, String(), SfxObjectShell::GetEventNames_Impl()[22] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_SAVEDOCFAILED, String(), SfxObjectShell::GetEventNames_Impl()[23] ); - SfxEventConfiguration::RegisterEvent(SFX_EVENT_SAVETODOCFAILED, String(), SfxObjectShell::GetEventNames_Impl()[24] ); - SfxEventConfiguration::RegisterEvent(SFX_HINT_TITLECHANGED, String(), SfxObjectShell::GetEventNames_Impl()[25] ); - SfxEventConfiguration::RegisterEvent(SFX_HINT_MODECHANGED, String(), SfxObjectShell::GetEventNames_Impl()[26] ); - // Subklasse initialisieren pAppData_Impl->bDowning = sal_False; Init(); diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index b51a7bb483dc..184ecb9f1a5c 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -668,17 +668,6 @@ void SfxApplication::MiscState_Impl(SfxItemSet &rSet) rSet.DisableItem(nWhich); break; - case SID_CURRENTTIME: - { - rSet.Put( SfxStringItem( nWhich, aLocaleWrapper.getTime( Time(), FALSE ) ) ); - break; - } - case SID_CURRENTDATE: - { - rSet.Put( SfxStringItem( nWhich, aLocaleWrapper.getDate( Date() ) ) ); - break; - } - case SID_HELPTIPS: { rSet.Put( SfxBoolItem( SID_HELPTIPS, Help::IsQuickHelpEnabled() ) ); @@ -859,6 +848,12 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) pFact->CreateFrameDialog( NULL, xFrame, rReq.GetSlot(), sPageURL ); pDlg->Execute(); delete pDlg; + SfxViewFrame* pView = SfxViewFrame::GetFirst(); + while ( pView ) + { + pView->GetBindings().InvalidateAll(FALSE); + pView = SfxViewFrame::GetNext( *pView ); + } } break; } diff --git a/sfx2/source/config/evntconf.cxx b/sfx2/source/config/evntconf.cxx index 6bca26886b2a..daf9174d20cb 100644 --- a/sfx2/source/config/evntconf.cxx +++ b/sfx2/source/config/evntconf.cxx @@ -69,23 +69,6 @@ #include // ----------------------------------------------------------------------- - -#define PROPERTYVALUE ::com::sun::star::beans::PropertyValue -#define XNAMEREPLACE ::com::sun::star::container::XNameReplace -#define XEVENTSSUPPLIER ::com::sun::star::document::XEventsSupplier -#define ANY ::com::sun::star::uno::Any -#define REFERENCE ::com::sun::star::uno::Reference -#define SEQUENCE ::com::sun::star::uno::Sequence -#define UNO_QUERY ::com::sun::star::uno::UNO_QUERY - -#define OUSTRING ::rtl::OUString - -// ----------------------------------------------------------------------- - -static const USHORT nCompatVersion = 3; -static const USHORT nOldVersion = 4; -static const USHORT nVersion = 5; - TYPEINIT1(SfxEventHint, SfxHint); TYPEINIT1(SfxEventNamesItem, SfxPoolItem); @@ -176,195 +159,11 @@ void SfxEventNamesItem::AddEvent( const String& rName, const String& rUIName, US aEventsList.Insert( new SfxEventName( nID, rName, rUIName.Len() ? rUIName : rName ) ); } -// class SfxAsyncEvent_Impl ---------------------------------------------- - -class SfxAsyncEvent_Impl : public SfxListener -{ - String aArgs; - SfxObjectShell* pSh; - const SvxMacro* pMacro; - Timer *pTimer; - -public: - - virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); - SfxAsyncEvent_Impl( SfxObjectShell *pDoc, const SvxMacro *pMacro, const String& rArgs ); - ~SfxAsyncEvent_Impl(); - DECL_LINK( TimerHdl, Timer*); -}; - -// ----------------------------------------------------------------------- - -void SfxAsyncEvent_Impl::Notify( SfxBroadcaster&, const SfxHint& rHint ) -{ - SfxSimpleHint* pHint = PTR_CAST( SfxSimpleHint, &rHint ); - if( pHint && pHint->GetId() == SFX_HINT_DYING && pTimer->IsActive() ) - { - pTimer->Stop(); - delete this; - } -} - -// ----------------------------------------------------------------------- - -SfxAsyncEvent_Impl::SfxAsyncEvent_Impl( SfxObjectShell *pDoc, const SvxMacro *pMac, const String& rArgs ) - : aArgs( rArgs ) - , pSh( pDoc ) - , pMacro( pMac ) -{ - if( pSh ) StartListening( *pSh ); - pTimer = new Timer; - pTimer->SetTimeoutHdl( LINK(this, SfxAsyncEvent_Impl, TimerHdl) ); - pTimer->SetTimeout( 0 ); - pTimer->Start(); -} - -// ----------------------------------------------------------------------- - -SfxAsyncEvent_Impl::~SfxAsyncEvent_Impl() -{ - delete pTimer; -} - -// ----------------------------------------------------------------------- - -IMPL_LINK(SfxAsyncEvent_Impl, TimerHdl, Timer*, pAsyncTimer) -{ - pAsyncTimer->Stop(); - ScriptType eSType = pMacro->GetScriptType(); - BOOL bIsBasic = ( eSType == STARBASIC ); - if ( bIsBasic && StarBASIC::IsRunning() ) - // Neues eventgebundenes Macro erst ausf"uhren, wenn gerade kein anderes Macro mehr l"auft - pAsyncTimer->Start(); - else - { - SFX_APP()->GetMacroConfig()->ExecuteMacro( pSh, pMacro, aArgs ); - delete this; - } - - return 0L; -} - -SfxEventNamesList *gp_Id_SortList = NULL; -SfxEventNamesList *gp_Name_SortList = NULL; - -//========================================================================== - -SfxEventConfiguration::SfxEventConfiguration() - : pAppTable( NULL ) - , pDocTable( NULL ) -{ - bIgnoreConfigure = sal_False; -} - -//========================================================================== - -SfxEventConfiguration::~SfxEventConfiguration() -{ - delete pDocTable; - - if ( gp_Id_SortList ) - { - delete gp_Id_SortList; - delete gp_Name_SortList; - gp_Id_SortList = NULL; - gp_Name_SortList = NULL; - } -} - -void SfxEventConfiguration::ConfigureEvent( USHORT nId, const SvxMacro& rMacro, SfxObjectShell *pDoc ) -{ - if ( bIgnoreConfigure ) - return; - - SvxMacro *pMacro = NULL; - if ( rMacro.GetMacName().Len() ) - pMacro = new SvxMacro( rMacro.GetMacName(), rMacro.GetLibName(), rMacro.GetScriptType() ); - if ( pDoc ) - { - PropagateEvent_Impl( pDoc, nId, pMacro ); - } - else - { - PropagateEvent_Impl( NULL, nId, pMacro ); - } -} //========================================================================== -SvxMacroTableDtor* SfxEventConfiguration::GetDocEventTable( SfxObjectShell*pDoc ) -{ - if ( pDocTable ) - delete pDocTable; - - pDocTable = new SvxMacroTableDtor; - - if ( pDoc ) - { - REFERENCE< XEVENTSSUPPLIER > xSup( pDoc->GetModel(), UNO_QUERY ); - uno::Reference < container::XNameReplace > xEvents = xSup->getEvents(); - - uno::Sequence < ::rtl::OUString > aNames = xEvents->getElementNames(); - for ( sal_Int32 i=0; igetByName( aNames[i] ), pDoc, TRUE ); - USHORT nID = (USHORT) GetEventId_Impl( aNames[i] ); - if ( nID && pMacro ) - pDocTable->Insert( nID, pMacro ); - } - } - - return pDocTable; -} - //-------------------------------------------------------------------------- -void SfxEventConfiguration::PropagateEvent_Impl( SfxObjectShell *pDoc, - USHORT nId, - const SvxMacro* pMacro ) -{ - REFERENCE< XEVENTSSUPPLIER > xSupplier; - if ( pDoc ) - { - xSupplier = REFERENCE< XEVENTSSUPPLIER >( pDoc->GetModel(), UNO_QUERY ); - } - else - { - xSupplier = REFERENCE< XEVENTSSUPPLIER > - ( ::comphelper::getProcessServiceFactory()->createInstance( - rtl::OUString::createFromAscii("com.sun.star.frame.GlobalEventBroadcaster" )), UNO_QUERY ); - } - - if ( xSupplier.is() ) - { - REFERENCE< XNAMEREPLACE > xEvents = xSupplier->getEvents(); - - bIgnoreConfigure = sal_True; - - OUSTRING aEventName = GetEventName_Impl( nId ); - - if ( aEventName.getLength() ) - { - ANY aEventData = CreateEventData_Impl( pMacro ); - - try - { - xEvents->replaceByName( aEventName, aEventData ); - } - catch( ::com::sun::star::lang::IllegalArgumentException ) - { DBG_ERRORFILE( "PropagateEvents_Impl: caught IllegalArgumentException" ); } - catch( ::com::sun::star::container::NoSuchElementException ) - { DBG_ERRORFILE( "PropagateEvents_Impl: caught NoSuchElementException" ); } - } - else { - DBG_WARNING( "PropagateEvents_Impl: Got unkown event" ); - } - - bIgnoreConfigure = sal_False; - } -} - -// ------------------------------------------------------------------------------------------------------- -ANY SfxEventConfiguration::CreateEventData_Impl( const SvxMacro *pMacro ) +uno::Any CreateEventData_Impl( const SvxMacro *pMacro ) { /* This function converts a SvxMacro into an Any containing three @@ -376,57 +175,57 @@ ANY SfxEventConfiguration::CreateEventData_Impl( const SvxMacro *pMacro ) If pMacro is NULL, we return an empty property sequence, so PropagateEvent_Impl can delete an event binding. */ - ANY aEventData; + uno::Any aEventData; if ( pMacro ) { if ( pMacro->GetScriptType() == STARBASIC ) { - SEQUENCE < PROPERTYVALUE > aProperties(3); - PROPERTYVALUE *pValues = aProperties.getArray(); + uno::Sequence < beans::PropertyValue > aProperties(3); + beans::PropertyValue *pValues = aProperties.getArray(); - OUSTRING aType = OUSTRING::createFromAscii( STAR_BASIC );; - OUSTRING aLib = pMacro->GetLibName(); - OUSTRING aMacro = pMacro->GetMacName(); + ::rtl::OUString aType = ::rtl::OUString::createFromAscii( STAR_BASIC );; + ::rtl::OUString aLib = pMacro->GetLibName(); + ::rtl::OUString aMacro = pMacro->GetMacName(); - pValues[ 0 ].Name = OUSTRING::createFromAscii( PROP_EVENT_TYPE ); + pValues[ 0 ].Name = ::rtl::OUString::createFromAscii( PROP_EVENT_TYPE ); pValues[ 0 ].Value <<= aType; - pValues[ 1 ].Name = OUSTRING::createFromAscii( PROP_LIBRARY ); + pValues[ 1 ].Name = ::rtl::OUString::createFromAscii( PROP_LIBRARY ); pValues[ 1 ].Value <<= aLib; - pValues[ 2 ].Name = OUSTRING::createFromAscii( PROP_MACRO_NAME ); + pValues[ 2 ].Name = ::rtl::OUString::createFromAscii( PROP_MACRO_NAME ); pValues[ 2 ].Value <<= aMacro; aEventData <<= aProperties; } else if ( pMacro->GetScriptType() == EXTENDED_STYPE ) { - SEQUENCE < PROPERTYVALUE > aProperties(2); - PROPERTYVALUE *pValues = aProperties.getArray(); + uno::Sequence < beans::PropertyValue > aProperties(2); + beans::PropertyValue *pValues = aProperties.getArray(); - OUSTRING aLib = pMacro->GetLibName(); - OUSTRING aMacro = pMacro->GetMacName(); + ::rtl::OUString aLib = pMacro->GetLibName(); + ::rtl::OUString aMacro = pMacro->GetMacName(); - pValues[ 0 ].Name = OUSTRING::createFromAscii( PROP_EVENT_TYPE ); + pValues[ 0 ].Name = ::rtl::OUString::createFromAscii( PROP_EVENT_TYPE ); pValues[ 0 ].Value <<= aLib; - pValues[ 1 ].Name = OUSTRING::createFromAscii( PROP_SCRIPT ); + pValues[ 1 ].Name = ::rtl::OUString::createFromAscii( PROP_SCRIPT ); pValues[ 1 ].Value <<= aMacro; aEventData <<= aProperties; } else if ( pMacro->GetScriptType() == JAVASCRIPT ) { - SEQUENCE < PROPERTYVALUE > aProperties(2); - PROPERTYVALUE *pValues = aProperties.getArray(); + uno::Sequence < beans::PropertyValue > aProperties(2); + beans::PropertyValue *pValues = aProperties.getArray(); - OUSTRING aMacro = pMacro->GetMacName(); + ::rtl::OUString aMacro = pMacro->GetMacName(); - pValues[ 0 ].Name = OUSTRING::createFromAscii( PROP_EVENT_TYPE ); + pValues[ 0 ].Name = ::rtl::OUString::createFromAscii( PROP_EVENT_TYPE ); pValues[ 0 ].Value <<= ::rtl::OUString::createFromAscii(SVX_MACRO_LANGUAGE_JAVASCRIPT); - pValues[ 1 ].Name = OUSTRING::createFromAscii( PROP_MACRO_NAME ); + pValues[ 1 ].Name = ::rtl::OUString::createFromAscii( PROP_MACRO_NAME ); pValues[ 1 ].Value <<= aMacro; aEventData <<= aProperties; @@ -438,171 +237,68 @@ ANY SfxEventConfiguration::CreateEventData_Impl( const SvxMacro *pMacro ) } else { - SEQUENCE < PROPERTYVALUE > aProperties; + uno::Sequence < beans::PropertyValue > aProperties; aEventData <<= aProperties; } return aEventData; } -// ------------------------------------------------------------------------------------------------------- -ULONG SfxEventConfiguration::GetPos_Impl( USHORT nId, sal_Bool &rFound ) +//-------------------------------------------------------------------------- +void PropagateEvent_Impl( SfxObjectShell *pDoc, rtl::OUString aEventName, const SvxMacro* pMacro ) { - rFound = sal_False; - - if ( ! gp_Id_SortList->Count() ) - return 0; - - // use binary search to find the correct position - // in the list - - int nCompVal = 1; - long nStart = 0; - long nEnd = gp_Id_SortList->Count() - 1; - long nMid = 0; - - SfxEventName* pMid; - - rFound = sal_False; - - while ( nCompVal && ( nStart <= nEnd ) ) - { - nMid = ( nEnd - nStart ) / 2 + nStart; - pMid = gp_Id_SortList->GetObject( (USHORT) nMid ); - - nCompVal = pMid->mnId - nId; - - if ( nCompVal < 0 ) // pMid < pData - nStart = nMid + 1; - else - nEnd = nMid - 1; - } - - if ( nCompVal == 0 ) + uno::Reference < document::XEventsSupplier > xSupplier; + if ( pDoc ) { - rFound = sal_True; + xSupplier = uno::Reference < document::XEventsSupplier >( pDoc->GetModel(), uno::UNO_QUERY ); } else { - if ( nCompVal < 0 ) // pMid < pData - nMid++; + xSupplier = uno::Reference < document::XEventsSupplier > + ( ::comphelper::getProcessServiceFactory()->createInstance( + rtl::OUString::createFromAscii("com.sun.star.frame.GlobalEventBroadcaster" )), uno::UNO_QUERY ); } - return (USHORT) nMid; -} - -// ------------------------------------------------------------------------------------------------------- -ULONG SfxEventConfiguration::GetPos_Impl( const String& rName, sal_Bool &rFound ) -{ - rFound = sal_False; - - if ( ! gp_Name_SortList->Count() ) - return 0; - - // use binary search to find the correct position - // in the list - - int nCompVal = 1; - long nStart = 0; - long nEnd = gp_Name_SortList->Count() - 1; - long nMid = 0; - - SfxEventName* pMid; - - rFound = sal_False; - - while ( nCompVal && ( nStart <= nEnd ) ) + if ( xSupplier.is() ) { - nMid = ( nEnd - nStart ) / 2 + nStart; - pMid = gp_Name_SortList->GetObject( (USHORT) nMid ); - - nCompVal = rName.CompareTo( pMid->maEventName ); - - if ( nCompVal < 0 ) // pMid < pData - nStart = nMid + 1; - else - nEnd = nMid - 1; - } + uno::Reference < container::XNameReplace > xEvents = xSupplier->getEvents(); + if ( aEventName.getLength() ) + { + uno::Any aEventData = CreateEventData_Impl( pMacro ); - if ( nCompVal == 0 ) - { - rFound = sal_True; - } - else - { - if ( nCompVal < 0 ) // pMid < pData - nMid++; + try + { + xEvents->replaceByName( aEventName, aEventData ); + } + catch( ::com::sun::star::lang::IllegalArgumentException ) + { DBG_ERRORFILE( "PropagateEvents_Impl: caught IllegalArgumentException" ); } + catch( ::com::sun::star::container::NoSuchElementException ) + { DBG_ERRORFILE( "PropagateEvents_Impl: caught NoSuchElementException" ); } + } + else { + DBG_WARNING( "PropagateEvents_Impl: Got unkown event" ); + } } - - return (USHORT) nMid; } //-------------------------------------------------------------------------------------------------------- -OUSTRING SfxEventConfiguration::GetEventName_Impl( ULONG nID ) +void SfxEventConfiguration::ConfigureEvent( rtl::OUString aName, const SvxMacro& rMacro, SfxObjectShell *pDoc ) { - OUSTRING aRet; - - if ( gp_Id_SortList ) + SvxMacro *pMacro = NULL; + if ( rMacro.GetMacName().Len() ) + pMacro = new SvxMacro( rMacro.GetMacName(), rMacro.GetLibName(), rMacro.GetScriptType() ); + if ( pDoc ) { - sal_Bool bFound; - ULONG nPos = GetPos_Impl( (USHORT) nID, bFound ); - - if ( bFound ) - { - SfxEventName *pData = gp_Id_SortList->GetObject( nPos ); - aRet = pData->maEventName; - } + PropagateEvent_Impl( pDoc, aName, pMacro ); } - - return aRet; -} - -//-------------------------------------------------------------------------------------------------------- -ULONG SfxEventConfiguration::GetEventId_Impl( const OUSTRING& rEventName ) -{ - ULONG nRet = 0; - - if ( gp_Name_SortList ) + else { - sal_Bool bFound; - ULONG nPos = GetPos_Impl( rEventName, bFound ); - - if ( bFound ) - { - SfxEventName *pData = gp_Name_SortList->GetObject( nPos ); - nRet = pData->mnId; - } + PropagateEvent_Impl( NULL, aName, pMacro ); } - - return nRet; } // ------------------------------------------------------------------------------------------------------- -void SfxEventConfiguration::RegisterEvent( USHORT nId, - const String& rUIName, - const String& rMacroName ) +SvxMacro* SfxEventConfiguration::ConvertToMacro( const com::sun::star::uno::Any& rElement, SfxObjectShell* pDoc, BOOL bBlowUp ) { - if ( ! gp_Id_SortList ) - { - gp_Id_SortList = new SfxEventNamesList; - gp_Name_SortList = new SfxEventNamesList; - } - - sal_Bool bFound = sal_False; - ULONG nPos = GetPos_Impl( nId, bFound ); - - if ( bFound ) - { - DBG_ERRORFILE( "RegisterEvent: Event already registered?" ); - return; - } - - gp_Id_SortList->Insert( new SfxEventName( nId, rMacroName, rUIName ), nPos ); - nPos = GetPos_Impl( rMacroName, bFound ); - - DBG_ASSERT( !bFound, "RegisterEvent: Name in List, but ID not?" ); - - gp_Name_SortList->Insert( new SfxEventName( nId, rMacroName, rUIName ), nPos ); - - SFX_APP()->GetEventConfig(); + return SfxEvents_Impl::ConvertToMacro( rElement, pDoc, bBlowUp ); } diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index 34deb24bcc32..48c4b16fbf8c 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -145,16 +145,6 @@ IMPL_LINK(SfxAsyncExec_Impl, TimerHdl, Timer*, pTimer) } class SfxBindings_Impl - -/* [Beschreibung] - - Diese Implementations-Struktur der Klasse SfxBindings dient - der Entkopplung von "Anderungen vom exportierten Interface sowie - der Verringerung von extern sichtbaren Symbolen. - - Eine Instanz exisitiert pro SfxBindings-Instanz f"ur deren Laufzeit. -*/ - { public: ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchRecorder > xRecorder; @@ -186,20 +176,6 @@ public: //-------------------------------------------------------------------- struct SfxFoundCache_Impl - -/* [Beschreibung] - - In Instanzen dieser Struktur werden in - weitere Informationen zu den gemeinsam von einem zu - erfragenden Status gesammelt, deren Ids dort in die Ranges eines - s aufgenommen werden. - - Diese Informationen werden w"ahrend der Suche nach den zusammen - upzudatenden Ids sowieso als Zwischenergebnis ermittelt und nachher - wieder ben"otigt, daher macht es Sinn, sie f"ur diesen kurzen Zeitraum - gleich aufzubewahren. -*/ - { sal_uInt16 nSlotId; // die Slot-Id sal_uInt16 nWhichId; // falls verf"ugbar die Which-Id, sonst nSlotId @@ -242,20 +218,6 @@ SV_IMPL_OP_PTRARR_SORT(SfxFoundCacheArr_Impl, SfxFoundCache_Impl*); //========================================================================== SfxBindings::SfxBindings() - -/* [Beschreibung] - - Konstruktor der Klasse SfxBindings. Genau eine Instanz wird automatisch - von der vor angelegt. Wird - eine Instanz ben"otigt, z.B. zum Invalidieren von Slots, sollte diese - "uber den zugeh"origen besorgt werden. Bestimmte - SfxViewFrame Subklassen (z.B. ) legen ihre eigene - Instanz der SfxBindings an. - - Instanzen k"onnen erst angelegt werden, wenn - die zugeh"orige SfxBindings Instanz existiert. -*/ - : pImp(new SfxBindings_Impl), pDispatcher(0), nRegLevel(1) // geht erst auf 0, wenn Dispatcher gesetzt @@ -324,23 +286,6 @@ SfxBindings::~SfxBindings() //-------------------------------------------------------------------- void SfxBindings::DeleteControllers_Impl() - -/* [Beschreibung] - - Interne Methode zum l"oschen noch existierender - Instanzen, die bei dieser SfxBindings Instanz angemeldet sind. - - Dies sind i.d.R. s. Nich sich selbst geh"orende - SfxControllerItems d"urfen bei Aufruf nur noch existieren, wenn sie - einem der restlichen SfxPopupWindows geh"oren. - - - [Anmerkung] - - Wird beim Beenden der Applikation gerufen, bevor das Applikations- - Fenster gel"oscht wird. -*/ - { // in der ersten Runde den SfxPopupWindows l"oschen sal_uInt16 nCount = pImp->pCaches->Count(); @@ -415,20 +360,6 @@ SfxPopupAction SfxBindings::GetPopupAction_Impl() const //-------------------------------------------------------------------- void SfxBindings::HidePopups( bool bHide ) - -/* [Beschreibung] - - Dieser Methode versteckt und zeigt die , die aus - s dieser SfxBindings-Instanz abgerissen wurden bzw. - floating -Instanzen dieser SfxBindings-Instanz. - - - [Anmerkung] - - Es k"onnten noch weitere Floating-Windows exisitieren, die durch - diese Methode nicht erfa\st werden. -*/ - { // SfxPopupWindows hiden HidePopupCtrls_Impl( bHide ); @@ -469,13 +400,6 @@ void SfxBindings::Update_Impl ( SfxStateCache* pCache // der upzudatende SfxStatusCache ) - -/* [Beschreibung] - - Interne Methode zum Updaten eines Caches und den von derselben - Status-Methode in derselben Shell bedienten und dirty Slots. -*/ - { if( pCache->GetDispatch().is() && pCache->GetItemLink() ) { @@ -558,35 +482,6 @@ void SfxBindings::Update ( sal_uInt16 nId // die gebundene und upzudatende Slot-Id ) - -/* [Beschreibung] - - Diese Methode sorgt f"ur synchrones Updaten der auf die Slot-Id nId - gebundenen Instanzen, die an dieser SfxBindings - Instanz angemeldet sind. Vergleichbar zu Window::Update() - (StarView) erfolgt ein Update nur, wenn entweder ein auf diese - Slot-Id gebundenes SfxContollerItem dirty ist, oder die Slot-Id - selbst dirty ist. Dies kann durch einen vorhergehendes Aufruf von - erzwungen werden. - - - [Anmerkung] - - Es ist g"unstiger, zun"achst alle zu invalidierenden Slot-Ids per - zu invalidieren und dann - Update() aufzurufen, als einzelne abwechselnde Invalidate/Update, - da von derselben Status-Methode bediente Status-Anfragen von - den SfxBindings automatisch zusammengefa"st werden. - - - [Querverweise] - - - - - -*/ - { DBG_MEMTEST(); DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); @@ -654,26 +549,6 @@ void SfxBindings::Update //-------------------------------------------------------------------- void SfxBindings::Update() - -/* [Beschreibung] - - Diese Methode sorgt f"ur synchrones Updaten aller - Instanzen, die an dieser SfxBindings Instanz angemeldet sind. Vergleichbar - zu Window::Update() (StarView) erfolgt ein Update nur, wenn entweder ein - SfxContollerItem dirty ist, in einem Status-Cache der Zeiger auf den - dirty ist. Ersteres kann durch einen Aufruf von - erzwungen werden, letzters durch - . - - - [Querverweise] - - - - - -*/ - { DBG_MEMTEST(); DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); @@ -702,19 +577,6 @@ void SfxBindings::SetState ( const SfxItemSet& rSet // zu setzende Status-Werte ) - -/* [Beschreibung] - - Diese Methode erlaubt das direkte Setzen neuer Status-Werte, ohne - den Umweg "uber und das dann im Update - erfolgende Rufen der Status-Methoden an den s. - - - [Querverweise] - - -*/ - { // wenn gelockt, dann nur invalidieren if ( nRegLevel ) @@ -759,23 +621,6 @@ void SfxBindings::SetState ( const SfxPoolItem& rItem // zu setzender Status-Wert ) - -/* [Beschreibung] - - Diese Methode erlaubt das direkte Setzen eines neuen Status-Wertes, - ohne den Umweg "uber und das dann im Update - erfolgende Rufen der Status-Methoden an den s. - - Mit dieser Methode k"onnen nur s mit Slot, nicht - aber mit Which-Id gesetzt werden, da kein bekannt ist, - "uber den gemappt werden k"onnte. - - - [Querverweise] - - -*/ - { if ( nRegLevel ) { @@ -824,25 +669,6 @@ SfxStateCache* SfxBindings::GetStateCache wurde, bzw. an der es einfef"ugt werden w"urde. */ ) - -/* [Beschreibung] - - Diese Methode sucht die zu einer Slot-Id geh"orige - Instanz. Falls die Slot-Id in keinem Controller gebunden ist, wird - ein 0-Pointer zur"uckgegeben. - - Falls pPos != 0, wird erst ab der Position mit der Suche angefangen. - Dieses ist eine Optimierung, f"ur den Fall, da"s die kleineren - Ids bereits abgearbeitet wurden. - - In *pPos wird der ::com::sun::star::sdbcx::Index innerhalb der SfxBindings zur"uckgegeben, - unter dem dieser Cache z.Zt. abgelegt ist. Dieser ::com::sun::star::sdbcx::Index ist bis zum - n"achsten Aufruf von g"ultig. - W"ahrend der Umkonfiguration ( == sal_True) - kann ist der ::com::sun::star::sdbcx::Index und der R"uckgabewert nur sehr kurzfristig - g"ultig. -*/ - { DBG_MEMTEST(); DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); @@ -870,27 +696,6 @@ void SfxBindings::InvalidateAll sal_False Slot-Server bleiben g"ultig */ ) - -/* [Beschreibung] - - Invalidiert alle Instanzen, die an dieser - SfxBindings Instanz angemeldet sind, und bei bWithMsg == sal_True - ebenfalls die -Caches. - - Es wird daraufhin ein Timer gestartet, bei dessen Ablauf das Updaten - beginnt. Somit k"onnen mehrere Invalidierungen vorgenommen werden, - bevor "uberhaupt etwas passiert. - - - [Querverweise] - - - - - - -*/ - { DBG_PROFSTART(SfxBindingsInvalidateAll); DBG_ASSERT( !pImp->bInUpdate, "SfxBindings::Invalidate while in update" ); @@ -942,26 +747,6 @@ void SfxBindings::Invalidate const sal_uInt16* pIds /* numerisch sortiertes 0-terminiertes Array von Slot-Ids (einzel, nicht als Paare!) */ ) - -/* [Beschreibung] - - Invalidiert die Instanzen der Slot-Ids in 'pIds', - die an dieser SfxBindings Instanz angemeldet sind. - - Es wird daraufhin ein Timer gestartet, bei dessen Ablauf das Updaten - beginnt. Somit k"onnen mehrere Invalidierungen vorgenommen werden, - bevor "uberhaupt etwas passiert. - - - [Querverweise] - - - - - - -*/ - { DBG_PROFSTART(SfxBindingsInvalidateAll); // DBG_ASSERT( !pImp->bInUpdate, "SfxBindings::Invalidate while in update" ); @@ -1032,26 +817,6 @@ void SfxBindings::InvalidateShell Slot-Ids werden invalidiert */ //! MI: z. Zt. immer bDeep ) - -/* [Beschreibung] - - Invalidiert alle Instanzen, die zur Zeit von - der angegebenen SfxShell Instanz bedient werden und an dieser - SfxBindings Instanz angemeldet sind - - Es wird daraufhin ein Timer gestartet, bei dessen Ablauf das Updaten - beginnt. Somit k"onnen mehrere Invalidierungen vorgenommen werden, - bevor "uberhaupt etwas passiert. - - - [Querverweise] - - - - - -*/ - { DBG_ASSERT( !pImp->bInUpdate, "SfxBindings::Invalidate while in update" ); @@ -1108,24 +873,6 @@ void SfxBindings::Invalidate ( sal_uInt16 nId // zu invalidierende Slot-Id ) - -/* [Beschreibung] - - Invalidiert alle Instanzen, die auf die Slot-Id - nId gebunden sind und an dieser SfxBindings Instanz angemeldet sind. - - Es wird daraufhin ein Timer gestartet, bei dessen Ablauf das Updaten - beginnt. Somit k"onnen mehrere Invalidierungen vorgenommen werden, - bevor "uberhaupt etwas passiert. - - - [Querverweise] - - - - -*/ - { DBG_MEMTEST(); // DBG_ASSERT( !pImp->bInUpdate, "SfxBindings::Invalidate while in update" ); @@ -1166,24 +913,6 @@ void SfxBindings::Invalidate sal_Bool bWithItem, // StateCache clearen ? sal_Bool bWithMsg // SlotServer neu holen ? ) - -/* [Beschreibung] - - Invalidiert alle Instanzen, die auf die Slot-Id - nId gebunden sind und an dieser SfxBindings Instanz angemeldet sind, - und bei bWithMsg == sal_True ebenfalls den -Cache. - - Es wird daraufhin ein Timer gestartet, bei dessen Ablauf das Updaten - beginnt. Somit k"onnen mehrere Invalidierungen vorgenommen werden, - bevor "uberhaupt etwas passiert. - - [Querverweise] - - - - -*/ - { DBG_MEMTEST(); DBG_ASSERT( !pImp->bInUpdate, "SfxBindings::Invalidate while in update" ); @@ -1214,52 +943,9 @@ void SfxBindings::Invalidate } } -void SfxBindings::Invalidate -( - sal_uInt16, // zu invalidierende Slot-Id - sal_Bool // SlotServer neu holen ? -) - -/* [Beschreibung] - - Invalidiert alle Instanzen, die auf die Slot-Id - nId gebunden sind und an dieser SfxBindings Instanz angemeldet sind, - und bei bWithMsg == sal_True ebenfalls den -Cache. - - Es wird daraufhin ein Timer gestartet, bei dessen Ablauf das Updaten - beginnt. Somit k"onnen mehrere Invalidierungen vorgenommen werden, - bevor "uberhaupt etwas passiert. - - [Querverweise] - - - - -*/ - -{ - DBG_ERROR( "Methode veraltet!" ); -} - //-------------------------------------------------------------------- sal_Bool SfxBindings::IsBound( sal_uInt16 nSlotId, sal_uInt16 nStartSearchAt ) - -/* [Beschreibung] - - Stellt fest, ob die angegebene Slot-Id in einem - gebunden ist, der an dieser SfxBindings Instanz angemeldet ist. - - - [R"uckgabewert] - - sal_Bool sal_True - Die angegeben Slot-Id ist gebunden. - - sal_False - Die angegeben Slot-Id ist nicht gebunden. -*/ - { DBG_MEMTEST(); DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); @@ -1269,14 +955,6 @@ sal_Bool SfxBindings::IsBound( sal_uInt16 nSlotId, sal_uInt16 nStartSearchAt ) //-------------------------------------------------------------------- sal_uInt16 SfxBindings::GetSlotPos( sal_uInt16 nId, sal_uInt16 nStartSearchAt ) - -/* [Beschreibung] - - Ermittelt den ::com::sun::star::sdbcx::Index der angegebenen Slot-Id in den SfxBindings. - Falls die Slot-Id nicht gebunden ist, wird der ::com::sun::star::sdbcx::Index zur"uckgegeben, - an dem sie eingef"ugt w"urde. -*/ - { DBG_MEMTEST(); DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); @@ -1471,30 +1149,6 @@ const SfxPoolItem* SfxBindings::ExecuteSynchron( sal_uInt16 nId, const SfxPoolIt sal_Bool SfxBindings::Execute( sal_uInt16 nId, const SfxPoolItem** ppItems, sal_uInt16 nModi, SfxCallMode nCallMode, const SfxPoolItem **ppInternalArgs ) - -/* [Beschreibung] - - F"uhrt den Slot mit der Slot-Id nId "uber den Cache - aus. Dies ist nur bei in dieser SfxBindings INstanz gebundenen - Slot-Ids m"oglich. - - - [R"uckgabewert] - - sal_Bool sal_True - Das Execute wurde ausgef"uhrt. - - sal_False - Das Execute konnte nicht ausgef"uhrt werden, - weil der Slot entweder nicht zur Verf"ugung steht - (in keiner aktiven vorhanden oder - disabled) ist oder der Anwender die Ausf"uhrung - abgebrochen hat (Cancel in einem Dialog). - - - [Querverweise] - -*/ { DBG_MEMTEST(); DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); @@ -1716,13 +1370,6 @@ void SfxBindings::Execute_Impl( SfxRequest& aReq, const SfxSlot* pSlot, SfxShell //-------------------------------------------------------------------- void SfxBindings::UpdateSlotServer_Impl() - -/* [Beschreibung] - - Interne Methode zum Updaten der Pointer auf die SlotServer - nach . -*/ - { DBG_PROFSTART(SfxBindingsUpdateServers); DBG_MEMTEST(); @@ -1785,16 +1432,6 @@ SfxItemSet* SfxBindings::CreateSet_Impl const SfxSlotServer** pMsgServer, // out: Slot-Server zu nId SfxFoundCacheArr_Impl& rFound // out: Liste der Caches der Siblings ) - -/* [Beschreibung] - - Diese interne Methode sucht zu pCache die Slot-Ids, die von derselben - Status-Methode bedient werden und ebenfalls gebunden und dirty sind. - Es wird ein SfxItemSet zusammengestellt, das die Slot-Ids (oder falls - vorhanden die mit dem Pool der Shell gemappten Which-Ids) enth"alt. - Die Caches dieser Slots werden in pFoundCaches zur"uckgeliefert. -*/ - { DBG_MEMTEST(); DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); @@ -1942,18 +1579,6 @@ void SfxBindings::UpdateControllers_Impl const SfxPoolItem* pItem, // item to send to controller SfxItemState eState // state of item ) - -/* [Beschreibung] - - Dieses ist eine Hilfsmethode f"ur NextJob_Impl mit der die SfxController, - welche auf nSlotId gebunden sind, upgedated werden. Dabei wird der - Wert aus dem SfxPoolItem unter dem Which-Wert nWhich aus dem Set rSet - genommen. - - Falls zu rSlot Enum-Werte in der Slotmap eingetragen sind, und diese - gebunden sind, werden sie ebenfalls upgedated. -*/ - { DBG_ASSERT( !pFound->pSlot || SFX_KIND_ENUM != pFound->pSlot->GetKind(), "direct update of enum slot isn't allowed" ); @@ -2059,13 +1684,6 @@ void SfxBindings::UpdateControllers_Impl //-------------------------------------------------------------------- IMPL_LINK( SfxBindings, NextJob_Impl, Timer *, pTimer ) - -/* [Beschreibung] - - Die SfxController werden "uber einen Timer updated. Dieses ist der - dazugeh"orige interne TimeOut-Handler. - */ - { #ifdef DBG_UTIL // on Windows very often C++ Exceptions (GPF etc.) are caught by MSVCRT or another MS library @@ -2178,18 +1796,26 @@ IMPL_LINK( SfxBindings, NextJob_Impl, Timer *, pTimer ) } } - // volatiles wieder von vorne starten pImp->nMsgPos = 0; - pImp->aTimer.SetTimeout(TIMEOUT_IDLE); + + // check for volatile slots + bool bVolatileSlotsPresent = false; for ( sal_uInt16 n = 0; n < nCount; ++n ) { SfxStateCache* pCache = (*pImp->pCaches)[n]; const SfxSlotServer *pSlotServer = pCache->GetSlotServer(*pDispatcher, pImp->xProv); - if ( pSlotServer && - pSlotServer->GetSlot()->IsMode(SFX_SLOT_VOLATILE) ) + if ( pSlotServer && pSlotServer->GetSlot()->IsMode(SFX_SLOT_VOLATILE) ) + { pCache->Invalidate(sal_False); + bVolatileSlotsPresent = true; + } } + if (bVolatileSlotsPresent) + pImp->aTimer.SetTimeout(TIMEOUT_IDLE); + else + pImp->aTimer.Stop(); + // Update-Runde ist beendet pImp->bInNextJob = sal_False; Broadcast(SfxSimpleHint(SFX_HINT_UPDATEDONE)); @@ -2210,35 +1836,6 @@ IMPL_LINK( SfxBindings, NextJob_Impl, Timer *, pTimer ) //-------------------------------------------------------------------- sal_uInt16 SfxBindings::EnterRegistrations(const char *pFile, int nLine) - -/* [Beschreibung] - - Die An- oder Abmeldung von Instanzen mu"s in - EnterRegistrations() und LeaveRegistrations() geklammert werden. - W"ahrend dieser Zeit erfolgen keine Udates der - Instanzen (weder der alten noch der neu angemeldeten). - - [Parameter] - - pFile, nLine Dateiname und Zeilennummer der rufenden - Methode (nur Debug) - - [R"uckgabewert] - - sal_uInt16 Level der Registrierung. Dieser kann in - als - Parameter angegeben werden, um die Paarigkeit - der EnterRegistrations() und LeaveRegistrations() - zu pr"ufen. - - - [Querverweise] - - - - -*/ - { (void)pFile; (void)nLine; @@ -2296,36 +1893,6 @@ sal_uInt16 SfxBindings::EnterRegistrations(const char *pFile, int nLine) //-------------------------------------------------------------------- void SfxBindings::LeaveRegistrations( sal_uInt16 nLevel, const char *pFile, int nLine ) - -/* [Beschreibung] - - Die An- oder Abmeldung von Instanzen mu"s in - EnterRegistrations() und LeaveRegistrations() geklammert werden. - W"ahrend dieser Zeit erfolgen keine Udates der - Instanzen (weder der alten noch der neu angemeldeten). - - - [Parameter] - - sal_uInt16 nLevel == USRT_MAX - keine Paarigkeits-Pr"ufung f"ur diese Klammerung - - - pFile, nLine Dateiname und Zeilennummer der rufenden - Methode (nur Debug) - - < USHRT_MAX - R"uckgabewert des zugeh"origen EnterRegistrations() - zum pr"ufen der Paarigkeit. - - - [Querverweise] - - - - -*/ - { (void)nLevel; // unused variable (void)pFile; @@ -2425,26 +1992,6 @@ void SfxBindings::LeaveRegistrations( sal_uInt16 nLevel, const char *pFile, int //-------------------------------------------------------------------- const SfxSlot* SfxBindings::GetSlot(sal_uInt16 nSlotId) - -/* [Beschreibung] - - Diese Methode liefert einen Pointer auf den zur Zeit gecacheten - SfxSlot f"ur die angegebene Slot-Id. - - - [R"uckgabewert] - - const * 0 - Falls die Slot-Id nicht gebunden ist oder - ein solcher Slot momentan in keiner aktiven - vorhanden ist. - - != 0 - Falls die Slot-Id gebunden ist und ein solcher - Slot momentan in einer aktiven - vorhanden ist. -*/ - { DBG_MEMTEST(); DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); @@ -2463,17 +2010,6 @@ const SfxSlot* SfxBindings::GetSlot(sal_uInt16 nSlotId) //-------------------------------------------------------------------- void SfxBindings::SetDispatcher( SfxDispatcher *pDisp ) - -/* [Beschreibung] - - Setzt den zur Zeit von dieser SfxBindings Instanz zu verwendenden - Dispatcher um. - - Falls sich der Dispatcher dadurch "andert, wird intern - mit sal_True gerufen, also jegliche - gecachete Information der Bindings weggeworfen. -*/ - { SfxDispatcher *pOldDispat = pDispatcher; if ( pDisp != pDispatcher ) @@ -2541,17 +2077,11 @@ void SfxBindings::SetDispatcher( SfxDispatcher *pDisp ) //-------------------------------------------------------------------- void SfxBindings::ClearCache_Impl( sal_uInt16 nSlotId ) - -// interne Methode zum forwarden dieses Methodenaufrufs - { GetStateCache(nSlotId)->ClearCache(); } //-------------------------------------------------------------------- - -// interne Methode zum Ansto\sen des Statusupdates - void SfxBindings::StartUpdate_Impl( sal_Bool bComplete ) { if ( pImp->pSubBindings ) @@ -2568,18 +2098,6 @@ void SfxBindings::StartUpdate_Impl( sal_Bool bComplete ) //------------------------------------------------------------------------- SfxItemState SfxBindings::QueryState( sal_uInt16 nSlot, SfxPoolItem* &rpState ) -/* [Beschreibung] - - Wird gerufen, um den Status f"ur 'nSlot' zu erfragen. Wenn der return - value SFX_ITEM_SET ist, wird ein SfxPoolItem zur"uckgegeben, indem der - rpState entsprechend gesetzt wird. Es findet dabei ein Eigent"umer"ubergang - statt, d.h. die aufrufende Methode mu\s das Item l"oschen. - - Anmerkung: diese Methode ist sehr teuer und sollte nur gerufen werden, - wenn kein Controller f"ur das Erfragen des Status angelegt werden kann oder - der Status unbedingt sofort geliefert werden mu\s. -*/ - { ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDisp; SfxStateCache *pCache = GetStateCache( nSlot ); @@ -2870,15 +2388,6 @@ BOOL SfxBindings::ExecuteCommand_Impl( const String& rCommand ) return FALSE; } -//REMOVE SfxConfigManager* SfxBindings::GetConfigManager( USHORT nType ) const -//{ -//REMOVE SfxConfigManager *pMgr = pDispatcher->GetFrame()->GetObjectShell()->GetConfigManager(); -//REMOVE if ( pMgr && pMgr->HasConfigItem( nType ) ) -//REMOVE return pMgr; -//REMOVE else -// return SFX_APP()->GetConfigManager_Impl(); -//} - com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > SfxBindings::GetRecorder() const { return pImp->xRecorder; diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 38808c36c7be..484e953f1cf4 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -1619,7 +1619,7 @@ CustomPropertiesWindow::CustomPropertiesWindow( Window* pParent, const ResId& rR m_aValueEdit ( this, SfxResId( SFX_ED_PROPERTY_VALUE ) ), m_aYesNoButton ( this, SfxResId( SFX_WIN_PROPERTY_YESNO ) ), m_aRemoveButton ( this, SfxResId( SFX_PB_PROPERTY_REMOVE ) ), - + m_nScrollPos (0), m_aNumberFormatter( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLanguage() ) @@ -1676,6 +1676,8 @@ IMPL_LINK( CustomPropertiesWindow, RemoveHdl, CustomPropertiesRemoveButton*, pBu } } } + + m_aRemovedHdl.Call(0); return 0; } @@ -1852,6 +1854,7 @@ void CustomPropertiesWindow::AddLine( const ::rtl::OUString& sName, Any& rAny ) Size aSize = (*pCurrent)->GetSizePixel(); Point aPos = (*pCurrent)->GetPosPixel(); aPos.Y() += nPos; + aPos.Y() += m_nScrollPos; (*pNewCurrent)->SetPosSizePixel( aPos, aSize ); (*pNewCurrent)->Show(); pCurrent++; @@ -1974,10 +1977,12 @@ void CustomPropertiesWindow::ClearAllLines() delete pLine; } m_aCustomPropertiesLines.clear(); + m_nScrollPos = 0; } void CustomPropertiesWindow::DoScroll( sal_Int32 nNewPos ) { + m_nScrollPos += nNewPos; std::vector< CustomPropertyLine* >::iterator pIter; for ( pIter = m_aCustomPropertiesLines.begin(); pIter != m_aCustomPropertiesLines.end(); ++pIter ) @@ -2141,6 +2146,7 @@ CustomPropertiesControl::CustomPropertiesControl( Window* pParent, const ResId& XubString sTEST = m_aHeaderBar.GetItemText( HI_NAME ); m_aPropertiesWin.InitControls( &m_aHeaderBar, &m_aVertScroll ); + m_aPropertiesWin.SetRemovedHdl( LINK( this, CustomPropertiesControl, RemovedHdl ) ); m_aVertScroll.SetRangeMin( 0 ); sal_Int32 nScrollOffset = m_aPropertiesWin.GetLineHeight(); @@ -2156,7 +2162,7 @@ CustomPropertiesControl::CustomPropertiesControl( Window* pParent, const ResId& Link aScrollLink = LINK( this, CustomPropertiesControl, ScrollHdl ); m_aVertScroll.SetScrollHdl( aScrollLink ); - m_aVertScroll.SetEndScrollHdl( aScrollLink ); +// m_aVertScroll.SetEndScrollHdl( aScrollLink ); } CustomPropertiesControl::~CustomPropertiesControl() @@ -2176,10 +2182,20 @@ IMPL_LINK( CustomPropertiesControl, ScrollHdl, ScrollBar*, pScrollBar ) return 0; } -void CustomPropertiesControl::AddLine( const ::rtl::OUString& sName, Any& rAny ) +IMPL_LINK( CustomPropertiesControl, RemovedHdl, void*, EMPTYARG ) +{ + m_aVertScroll.SetRangeMax( m_aPropertiesWin.GetVisibleLineCount() + 1 ); + if ( m_aPropertiesWin.GetOutputSizePixel().Height() < m_aPropertiesWin.GetVisibleLineCount() * m_aPropertiesWin.GetLineHeight() ) + m_aVertScroll.DoScrollAction ( SCROLL_LINEUP ); + return 0; +} + +void CustomPropertiesControl::AddLine( const ::rtl::OUString& sName, Any& rAny, bool bInteractive ) { m_aPropertiesWin.AddLine( sName, rAny ); m_aVertScroll.SetRangeMax( m_aPropertiesWin.GetVisibleLineCount() + 1 ); + if ( bInteractive && m_aPropertiesWin.GetOutputSizePixel().Height() < m_aPropertiesWin.GetVisibleLineCount() * m_aPropertiesWin.GetLineHeight() ) + m_aVertScroll.DoScroll( m_aPropertiesWin.GetVisibleLineCount() + 1 ); } // class SfxCustomPropertiesPage ----------------------------------------- @@ -2200,7 +2216,7 @@ SfxCustomPropertiesPage::SfxCustomPropertiesPage( Window* pParent, const SfxItem IMPL_LINK( SfxCustomPropertiesPage, AddHdl, PushButton*, EMPTYARG ) { Any aAny; - m_aPropertiesCtrl.AddLine( ::rtl::OUString(), aAny ); + m_aPropertiesCtrl.AddLine( ::rtl::OUString(), aAny, true ); return 0; } @@ -2250,7 +2266,7 @@ void SfxCustomPropertiesPage::Reset( const SfxItemSet& rItemSet ) std::vector< CustomProperty* > aCustomProps = pInfoItem->GetCustomProperties(); for ( sal_uInt32 i = 0; i < aCustomProps.size(); i++ ) { - m_aPropertiesCtrl.AddLine( aCustomProps[i]->m_sName, aCustomProps[i]->m_aValue ); + m_aPropertiesCtrl.AddLine( aCustomProps[i]->m_sName, aCustomProps[i]->m_aValue, false ); } } diff --git a/sfx2/source/doc/makefile.mk b/sfx2/source/doc/makefile.mk index 4c893288ebb8..986755558cf2 100644 --- a/sfx2/source/doc/makefile.mk +++ b/sfx2/source/doc/makefile.mk @@ -48,7 +48,7 @@ CFLAGS+=-DSYSTEM_LIBXML $(LIBXML_CFLAGS) SRS1NAME=$(TARGET) SRC1FILES = \ - doc.src new.src doctdlg.src docvor.src doctempl.src sfxbasemodel.src graphhelp.src + doc.src new.src doctdlg.src docvor.src doctempl.src graphhelp.src SLOFILES = \ $(SLO)$/printhelper.obj \ diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 866c7b029cb5..f9c675372307 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -1383,54 +1383,6 @@ void SfxObjectShell::UpdateFromTemplate_Impl( ) } } -/* -SfxEventConfigItem_Impl* SfxObjectShell::GetEventConfig_Impl( BOOL bForce ) -{ - if ( bForce && !pImp->pEventConfig ) - { - pImp->pEventConfig = new SfxEventConfigItem_Impl( SFX_ITEMTYPE_DOCEVENTCONFIG, - SFX_APP()->GetEventConfig(), this ); - if (pImp->pCfgMgr) - pImp->pEventConfig->Connect( pImp->pCfgMgr ); - pImp->pEventConfig->Initialize(); - } - - return pImp->pEventConfig; -} */ - -//REMOVE SvStorageRef SfxObjectShell::GetConfigurationStorage( SotStorage* pStor ) -//REMOVE { -//REMOVE // configuration storage shall be opened in own storage or a new storage, if the -//REMOVE // document is getting stored into this storage -//REMOVE if ( !pStor ) -//REMOVE pStor = GetStorage(); -//REMOVE -//REMOVE if ( pStor->IsOLEStorage() ) -//REMOVE return (SvStorageRef) SotStorageRef(); -//REMOVE -//REMOVE // storage is always opened in transacted mode, so changes must be commited -//REMOVE SotStorageRef xStorage = pStor->OpenSotStorage( DEFINE_CONST_UNICODE("Configurations"), -//REMOVE IsReadOnly() ? STREAM_STD_READ : STREAM_STD_READWRITE ); -//REMOVE if ( xStorage.Is() && xStorage->GetError() ) -//REMOVE xStorage.Clear(); -//REMOVE return (SvStorageRef) xStorage; -//REMOVE } - -//REMOVE SotStorageStreamRef SfxObjectShell::GetConfigurationStream( const String& rName, BOOL bCreate ) -//REMOVE { -//REMOVE SotStorageStreamRef xStream; -//REMOVE SvStorageRef xStorage = GetConfigurationStorage(); -//REMOVE if ( xStorage.Is() ) -//REMOVE { -//REMOVE xStream = xStorage->OpenSotStream( rName, -//REMOVE bCreate ? STREAM_STD_READWRITE|STREAM_TRUNC : STREAM_STD_READ ); -//REMOVE if ( xStream.Is() && xStream->GetError() ) -//REMOVE xStream.Clear(); -//REMOVE } -//REMOVE -//REMOVE return xStream; -//REMOVE } - SfxObjectShellRef MakeObjectShellForOrganizer_Impl( const String& aTargetURL, BOOL bForWriting ) { // check for own format diff --git a/sfx2/source/doc/objembed.cxx b/sfx2/source/doc/objembed.cxx index 235451b8c3dd..7b7a1bea1ea0 100644 --- a/sfx2/source/doc/objembed.cxx +++ b/sfx2/source/doc/objembed.cxx @@ -136,7 +136,7 @@ void SfxObjectShell::SetVisArea( const Rectangle & rVisArea ) if ( IsEnableSetModified() ) SetModified( TRUE ); - SFX_APP()->NotifyEvent(SfxEventHint( SFX_EVENT_VISAREACHANGED, this)); + SFX_APP()->NotifyEvent(SfxEventHint( SFX_EVENT_VISAREACHANGED, GlobalEventConfig::GetEventName(STR_EVENT_VISAREACHANGED), this)); /* Size aSize (GetVisArea().GetSize()); diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 816ece081fc3..5e3ace93372a 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -423,7 +423,7 @@ void SfxObjectShell::ModifyChanged() Invalidate( SID_MACRO_SIGNATURE ); Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED ) ); // xmlsec05, signed state might change in title... - SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_MODIFYCHANGED, this ) ); + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_MODIFYCHANGED, GlobalEventConfig::GetEventName(STR_EVENT_MODIFYCHANGED), this ) ); } //------------------------------------------------------------------------- @@ -1137,8 +1137,10 @@ void SfxObjectShell::PostActivateEvent_Impl( SfxViewFrame* pFrame ) { sal_uInt16 nId = pImp->nEventId; pImp->nEventId = 0; - if ( nId ) - pSfxApp->NotifyEvent(SfxEventHint( nId, this ), sal_False); + if ( nId == SFX_EVENT_OPENDOC ) + pSfxApp->NotifyEvent(SfxEventHint( nId, GlobalEventConfig::GetEventName(STR_EVENT_OPENDOC), this ), sal_False); + else if (nId == SFX_EVENT_CREATEDOC ) + pSfxApp->NotifyEvent(SfxEventHint( nId, GlobalEventConfig::GetEventName(STR_EVENT_CREATEDOC), this ), sal_False); } } } @@ -1432,7 +1434,7 @@ void SfxObjectShell::FinishedLoading( sal_uInt16 nFlags ) } pImp->bInitialized = sal_True; - SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_LOADFINISHED, this ) ); + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_LOADFINISHED, GlobalEventConfig::GetEventName(STR_EVENT_LOADFINISHED), this ) ); // Title is not available until loading has finished Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED ) ); diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 2925090868e8..cd73a92196d7 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -522,7 +522,7 @@ sal_Bool SfxObjectShell::DoInitNew( SfxMedium* pMed ) pImp->bInitialized = sal_True; SetActivateEvent_Impl( SFX_EVENT_CREATEDOC ); - SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_DOCCREATED, this ) ); + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_DOCCREATED, GlobalEventConfig::GetEventName(STR_EVENT_DOCCREATED), this ) ); return sal_True; } @@ -3257,7 +3257,7 @@ uno::Reference< embed::XStorage > SfxObjectShell::GetStorage() SetupStorage( pImp->m_xDocStorage, SOFFICE_FILEFORMAT_CURRENT, sal_False ); pImp->m_bCreateTempStor = sal_False; - SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_STORAGECHANGED, this ) ); + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_STORAGECHANGED, GlobalEventConfig::GetEventName(STR_EVENT_STORAGECHANGED), this ) ); } catch( uno::Exception& ) { @@ -3417,7 +3417,7 @@ sal_Bool SfxObjectShell::SaveCompleted( const uno::Reference< embed::XStorage >& if ( bSendNotification ) { - SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_STORAGECHANGED, this ) ); + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_STORAGECHANGED, GlobalEventConfig::GetEventName(STR_EVENT_STORAGECHANGED), this ) ); } return bResult; diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 95ba194df0cb..36a3673e0d6a 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -61,6 +61,7 @@ #include #include #include +#include #include #include @@ -251,7 +252,6 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,pModule( 0 ) ,pFrame( 0 ) ,pTbxConfig( 0 ) - ,pEventConfig(NULL) ,eFlags( SFXOBJECTSHELL_UNDEFINED ) ,pCloser( 0 ) ,bReadOnlyUI( sal_False ) @@ -597,6 +597,9 @@ sal_uInt16 SfxObjectShell::PrepareClose while ( pFrame && (pFrame->GetFrameType() & SFXFRAME_SERVER ) ) pFrame = SfxViewFrame::GetNext( *pFrame, this ); + SfxApplication *pSfxApp = SFX_APP(); + pSfxApp->NotifyEvent( SfxEventHint(SFX_EVENT_PREPARECLOSEDOC, GlobalEventConfig::GetEventName(STR_EVENT_PREPARECLOSEDOC), this) ); + sal_Bool bClose = sal_False; if ( bUI && IsModified() ) { @@ -886,11 +889,6 @@ SfxObjectShell* SfxObjectShell::GetObjectShell() //-------------------------------------------------------------------- SEQUENCE< OUSTRING > SfxObjectShell::GetEventNames() -{ - return GetEventNames_Impl(); -} - -SEQUENCE< OUSTRING > SfxObjectShell::GetEventNames_Impl() { static uno::Sequence< ::rtl::OUString >* pEventNameContainer = NULL; @@ -899,88 +897,7 @@ SEQUENCE< OUSTRING > SfxObjectShell::GetEventNames_Impl() ::vos::OGuard aGuard( Application::GetSolarMutex() ); if ( !pEventNameContainer ) { - static uno::Sequence< ::rtl::OUString > aEventNameContainer( 27 ); - // SFX_EVENT_STARTAPP - aEventNameContainer[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnStartApp" ) ); - - // SFX_EVENT_CLOSEAPP - aEventNameContainer[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnCloseApp" ) ); - - // SFX_EVENT_CREATEDOC - aEventNameContainer[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnNew" ) ); - - // SFX_EVENT_OPENDOC - aEventNameContainer[3] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnLoad" ) ); - - // SFX_EVENT_SAVEASDOC - aEventNameContainer[4] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnSaveAs" ) ); - - // SFX_EVENT_SAVEASDOCDONE - aEventNameContainer[5] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnSaveAsDone" ) ); - - // SFX_EVENT_SAVEDOC - aEventNameContainer[6] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnSave" ) ); - - // SFX_EVENT_SAVEDOCDONE - aEventNameContainer[7] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnSaveDone" ) ); - - // SFX_EVENT_PREPARECLOSEDOC - aEventNameContainer[8] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnPrepareUnload" ) ); - - // SFX_EVENT_CLOSEDOC - aEventNameContainer[9] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnUnload" ) ); - - // SFX_EVENT_ACTIVATEDOC - aEventNameContainer[10] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnFocus" ) ); - - // SFX_EVENT_DEACTIVATEDOC - aEventNameContainer[11] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnUnfocus" ) ); - - // SFX_EVENT_PRINTDOC - aEventNameContainer[12] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnPrint" ) ); - - // SFX_EVENT_MODIFYCHANGED - aEventNameContainer[13] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnModifyChanged" ) ); - - // SFX_EVENT_SAVETODOC - aEventNameContainer[14] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnCopyTo" ) ); - - // SFX_EVENT_SAVETODOCDONE - aEventNameContainer[15] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnCopyToDone" ) ); - - // SFX_EVENT_VIEWCREATED - aEventNameContainer[16] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnViewCreated" ) ); - - // SFX_EVENT_PREPARECLOSEVIEW - aEventNameContainer[17] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnPrepareViewClosing" ) ); - - // SFX_EVENT_CLOSEVIEW - aEventNameContainer[18] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnViewClosed" ) ); - - // SFX_EVENT_VISAREACHANGED - aEventNameContainer[19] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnVisAreaChanged" ) ); - - // SFX_EVENT_DOCCREATED - aEventNameContainer[20] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnCreate" ) ); - - // SFX_EVENT_LOADFINISHED - aEventNameContainer[21] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnLoadFinished" ) ); - - // SFX_EVENT_SAVEASDOCFAILED - aEventNameContainer[22] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnSaveAsFailed" ) ); - - // SFX_EVENT_SAVEDOCFAILED - aEventNameContainer[23] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnSaveFailed" ) ); - - // SFX_EVENT_SAVETODOCFAILED - aEventNameContainer[24] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnCopyToFailed" ) ); - - // SFX_HINT_TITLECHANGED - aEventNameContainer[25] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnTitleChanged" ) ); - - // SFX_HINT_MODECHANGED - aEventNameContainer[26] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnModeChanged" ) ); - + static uno::Sequence< ::rtl::OUString > aEventNameContainer = GlobalEventConfig().getElementNames(); pEventNameContainer = &aEventNameContainer; } } @@ -988,6 +905,13 @@ SEQUENCE< OUSTRING > SfxObjectShell::GetEventNames_Impl() return *pEventNameContainer; } +SEQUENCE< OUSTRING > SfxObjectShell::GetEventNames_Impl() +{ + if (!pImp->xEventNames.getLength()) + pImp->xEventNames = GetEventNames(); + return pImp->xEventNames; +} + //-------------------------------------------------------------------- void SfxObjectShell::SetModel( SfxBaseModel* pModel ) diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 29219942be01..03e6e9170153 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -1614,7 +1614,7 @@ void SAL_CALL SfxBaseModel::storeSelf( const uno::Sequence< beans::PropertyVa SfxAllItemSet *pParams = new SfxAllItemSet( SFX_APP()->GetPool() ); TransformParameters( SID_SAVEDOC, aSeqArgs, *pParams ); - SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOC, m_pData->m_pObjectShell ) ); + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOC, GlobalEventConfig::GetEventName(STR_EVENT_SAVEDOC), m_pData->m_pObjectShell ) ); sal_Bool bRet = sal_False; @@ -1645,14 +1645,12 @@ void SAL_CALL SfxBaseModel::storeSelf( const uno::Sequence< beans::PropertyVa : ERRCODE_IO_CANTWRITE; m_pData->m_pObjectShell->ResetError(); - SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEFINISHED, m_pData->m_pObjectShell ) ); - if ( bRet ) { m_pData->m_pObjectShell->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "successful saving." ) ) ); m_pData->m_aPreusedFilterName = GetMediumFilterName_Impl(); - SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOCDONE, m_pData->m_pObjectShell ) ); + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOCDONE, GlobalEventConfig::GetEventName(STR_EVENT_SAVEDOCDONE), m_pData->m_pObjectShell ) ); } else { @@ -1660,7 +1658,7 @@ void SAL_CALL SfxBaseModel::storeSelf( const uno::Sequence< beans::PropertyVa m_pData->m_pObjectShell->StoreLog(); // write the contents of the logger to the file - SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOCFAILED, m_pData->m_pObjectShell ) ); + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOCFAILED, GlobalEventConfig::GetEventName(STR_EVENT_SAVEDOCFAILED), m_pData->m_pObjectShell ) ); throw task::ErrorCodeIOException( ::rtl::OUString(), uno::Reference< uno::XInterface >(), nErrCode ); } @@ -2546,7 +2544,7 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC , impl_getPrintHelper(); } - postEvent_Impl( pNamedHint->GetEventId() ); + postEvent_Impl( pNamedHint->GetEventName() ); } if ( pSimpleHint ) @@ -2555,11 +2553,11 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC , { ::rtl::OUString aTitle = m_pData->m_pObjectShell->GetTitle(); addTitle_Impl( m_pData->m_seqArguments, aTitle ); - postEvent_Impl( pSimpleHint->GetId() ); + postEvent_Impl( GlobalEventConfig::GetEventName( STR_EVENT_TITLECHANGED ) ); } if ( pSimpleHint->GetId() == SFX_HINT_MODECHANGED ) { - postEvent_Impl( pSimpleHint->GetId() ); + postEvent_Impl( GlobalEventConfig::GetEventName( STR_EVENT_MODECHANGED ) ); } /* else if ( pSimpleHint->GetId() == SFX_HINT_DYING @@ -2760,7 +2758,7 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL if ( !bSaved && m_pData->m_pObjectShell ) { - SFX_APP()->NotifyEvent( SfxEventHint( bSaveTo ? SFX_EVENT_SAVETODOC : SFX_EVENT_SAVEASDOC, + SFX_APP()->NotifyEvent( SfxEventHint( bSaveTo ? SFX_EVENT_SAVETODOC : SFX_EVENT_SAVEASDOC, GlobalEventConfig::GetEventName( bSaveTo ? STR_EVENT_SAVETODOC : STR_EVENT_SAVEASDOC ), m_pData->m_pObjectShell ) ); SfxAllItemSet *aParams = new SfxAllItemSet( SFX_APP()->GetPool() ); @@ -2860,11 +2858,11 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL if ( !bSaveTo ) { m_pData->m_aPreusedFilterName = GetMediumFilterName_Impl(); - SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEASDOCDONE, m_pData->m_pObjectShell ) ); + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEASDOCDONE, GlobalEventConfig::GetEventName(STR_EVENT_SAVEASDOCDONE), m_pData->m_pObjectShell ) ); } else { - SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVETODOCDONE, m_pData->m_pObjectShell ) ); + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVETODOCDONE, GlobalEventConfig::GetEventName(STR_EVENT_SAVETODOCDONE), m_pData->m_pObjectShell ) ); } } else @@ -2873,7 +2871,7 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL m_pData->m_pObjectShell->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Storing failed!" ) ) ); m_pData->m_pObjectShell->StoreLog(); - SFX_APP()->NotifyEvent( SfxEventHint( bSaveTo ? SFX_EVENT_SAVETODOCFAILED : SFX_EVENT_SAVEASDOCFAILED, + SFX_APP()->NotifyEvent( SfxEventHint( bSaveTo ? SFX_EVENT_SAVETODOCFAILED : SFX_EVENT_SAVEASDOCFAILED, GlobalEventConfig::GetEventName( bSaveTo ? STR_EVENT_SAVETODOCFAILED : STR_EVENT_SAVEASDOCFAILED), m_pData->m_pObjectShell ) ); throw task::ErrorCodeIOException( ::rtl::OUString(), uno::Reference< uno::XInterface >(), nErrCode ); @@ -2883,18 +2881,26 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL //******************************************************************************************************** -void SfxBaseModel::postEvent_Impl( ULONG nEventID ) +void SfxBaseModel::postEvent_Impl( ::rtl::OUString aName ) { // object already disposed? if ( impl_isDisposed() ) return; + DBG_ASSERT( aName.getLength(), "Empty event name!" ); + if (!aName.getLength()) + return; + ::cppu::OInterfaceContainerHelper* pIC = m_pData->m_aInterfaceContainer.getContainer( ::getCppuType((const uno::Reference< XDOCEVENTLISTENER >*)0) ); if( pIC ) { - ::rtl::OUString aName = SfxEventConfiguration::GetEventName_Impl( nEventID ); +#ifdef DBG_UTIL + ByteString aTmp( "SfxEvent: "); + aTmp += ByteString( String(aName), RTL_TEXTENCODING_UTF8 ); + DBG_TRACE( aTmp.GetBuffer() ); +#endif document::EventObject aEvent( (frame::XModel *)this, aName ); ::cppu::OInterfaceContainerHelper aIC( m_aMutex ); uno::Sequence < uno::Reference < uno::XInterface > > aElements = pIC->getElements(); diff --git a/sfx2/source/doc/sfxbasemodel.src b/sfx2/source/doc/sfxbasemodel.src deleted file mode 100644 index cbbfa57b2ad0..000000000000 --- a/sfx2/source/doc/sfxbasemodel.src +++ /dev/null @@ -1,94 +0,0 @@ -/************************************************************************* - * - * 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: sfxbasemodel.src,v $ - * $Revision: 1.10 $ - * - * 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. - * - ************************************************************************/ - -#include -#include "sfxlocal.hrc" - -/* -// the following events names are now hardcoded in the code -StringArray EVENT_NAMES_ARY -{ - ItemList = - { - < "OnStartApp" ; SFX_EVENT_STARTAPP ; > ; - < "OnCloseApp" ; SFX_EVENT_CLOSEAPP ; > ; - < "OnNew" ; SFX_EVENT_CREATEDOC ; > ; - < "OnLoad" ; SFX_EVENT_OPENDOC ; > ; - < "OnSaveAs" ; SFX_EVENT_SAVEASDOC ; > ; - < "OnSaveAsDone" ; SFX_EVENT_SAVEASDOCDONE ; > ; - < "OnSave" ; SFX_EVENT_SAVEDOC ; > ; - < "OnSaveDone" ; SFX_EVENT_SAVEDOCDONE ; > ; - < "OnPrepareUnload" ; SFX_EVENT_PREPARECLOSEDOC ; > ; - < "OnUnload" ; SFX_EVENT_CLOSEDOC ; > ; - < "OnFocus" ; SFX_EVENT_ACTIVATEDOC ; > ; - < "OnUnfocus" ; SFX_EVENT_DEACTIVATEDOC ; > ; - < "OnPrint" ; SFX_EVENT_PRINTDOC ; > ; - < "OnModifyChanged" ; SFX_EVENT_MODIFYCHANGED ; > ; - < "OnCopyTo" ; SFX_EVENT_SAVETODOC ; > ; - < "OnCopyToDone" ; SFX_EVENT_SAVETODOCDONE ; > ; - < "OnViewCreated" ; SFX_EVENT_VIEWCREATED ; > ; - < "OnPrepareViewClosing"; SFX_EVENT_PREPARECLOSEVIEW ; > ; - < "OnViewClosed" ; SFX_EVENT_CLOSEVIEW ; > ; - < "OnVisAreaChanged" ; SFX_EVENT_VISAREACHANGED ; > ; - < "OnCreate" ; SFX_EVENT_DOCCREATED ; > ; - < "OnLoadFinished" ; SFX_EVENT_LOADFINISHED ; > ; - < "OnSaveAsFailed" ; SFX_EVENT_SAVEASDOCFAILED ; > ; - < "OnSaveFailed" ; SFX_EVENT_SAVEDOCFAILED ; > ; - < "OnCopyToFailed" ; SFX_EVENT_SAVETODOCFAILED ; > ; - }; -}; -*/ - -/* - these events are defined by the applications or aren't used - any longer - - < "OnNewMail" ; SFX_EVENT_NEWMESSAGE ; > ; - < "OnError" ; SFX_EVENT_ONERROR ; > ; - < "OnSelect" ; > ; - < "OnInsertStart" ; > ; - < "OnInsertDone" ; > ; - < "OnMailMerge" ; > ; - < "OnAlphaCharInput" ; > ; - < "OnNonAlphaCharInput" ; > ; - < "OnResize" ; > ; - < "OnMove" ; > ; - < "OnPageCountChange" ; > ; - < "OnMouseOver" ; SFX_EVENT_MOUSEOVER_OBJECT ; > ; - < "OnClick" ; SFX_EVENT_MOUSECLICK_OBJECT ; > ; - < "OnMouseOut" ; SFX_EVENT_MOUSEOUT_OBJECT ; > ; - < "OnLoadError" ; > ; - < "OnLoadCancel" ; > ; - < "OnLoadDone" ; > ; - < "OnLoadFinished" ; SFX_EVENT_LOADFINISHED ; > ; - < "OnSaveFinished" ; SFX_EVENT_SAVEFINISHED ; > ; - < "OnModifyChanged" ; SFX_EVENT_MODIFYCHANGED ; > ; - < "OnToggleFullscreen" ; SFX_EVENT_TOGGLEFULLSCREENMODE ; > ; -*/ diff --git a/sfx2/source/inc/eventsupplier.hxx b/sfx2/source/inc/eventsupplier.hxx index 97455a9e6482..0940d4bb66e3 100644 --- a/sfx2/source/inc/eventsupplier.hxx +++ b/sfx2/source/inc/eventsupplier.hxx @@ -187,7 +187,6 @@ class SfxGlobalEvents_Impl : public ModelCollectionMutexBase , ::com::sun::star::document::XEventListener , ::com::sun::star::document::XDocumentEventListener , ::com::sun::star::container::XSet > - , public SfxListener { ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMGR; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > m_xEvents; @@ -197,8 +196,6 @@ class SfxGlobalEvents_Impl : public ModelCollectionMutexBase TModelList m_lModels; GlobalEventConfig* pImp; - void Notify( SfxBroadcaster& aBC, const SfxHint& aHint ); - public: SfxGlobalEvents_Impl(const com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& xSMGR); virtual ~SfxGlobalEvents_Impl(); diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx index 3b92971fabff..77162423cabe 100644 --- a/sfx2/source/inc/objshimp.hxx +++ b/sfx2/source/inc/objshimp.hxx @@ -33,6 +33,8 @@ //#include #include +#include +#include #include #include @@ -72,6 +74,7 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess xBasicLibraries; ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer > xDialogLibraries; + com::sun::star::uno::Sequence < rtl::OUString > xEventNames; ::sfx2::DocumentMacroMode aMacroMode; SfxProgress* pProgress; @@ -141,7 +144,6 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess SfxModule* pModule; SfxFrame* pFrame; SfxToolBoxConfig* pTbxConfig; - SfxEventConfigItem_Impl* pEventConfig; SfxObjectShellFlags eFlags; svtools::AsynchronLink* pCloser; String aBaseURL; diff --git a/sfx2/source/notify/eventsupplier.cxx b/sfx2/source/notify/eventsupplier.cxx index c3c1e83f2aba..a01b1df73c82 100644 --- a/sfx2/source/notify/eventsupplier.cxx +++ b/sfx2/source/notify/eventsupplier.cxx @@ -98,12 +98,6 @@ void SAL_CALL SfxEvents_Impl::replaceByName( const OUSTRING & aName, const ANY & // create Configuration at first, creation might call this method also and that would overwrite everything // we might have stored before! - USHORT nID = (USHORT) SfxEventConfiguration::GetEventId_Impl( aName ); - OSL_ENSURE( nID, "SfxEvents_Impl::replaceByName: no ID for the given event!" ); - if ( !nID ) - // throw? - return; - if ( mpObjShell && !mpObjShell->IsLoading() ) mpObjShell->SetModified( TRUE ); @@ -370,7 +364,7 @@ SfxEvents_Impl::SfxEvents_Impl( SfxObjectShell* pShell, if ( pShell ) maEventNames = pShell->GetEventNames(); else - maEventNames = SfxObjectShell::GetEventNames_Impl(); + maEventNames = GlobalEventConfig().getElementNames(); maEventData = SEQUENCE < ANY > ( maEventNames.getLength() ); @@ -645,24 +639,6 @@ SfxGlobalEvents_Impl::~SfxGlobalEvents_Impl() { } -//----------------------------------------------------------------------------- -void SfxGlobalEvents_Impl::Notify( SfxBroadcaster& /*aBC*/, const SfxHint& aHint ) -{ - SfxEventHint* pNamedHint = PTR_CAST(SfxEventHint, &aHint); - if (!pNamedHint) - return; - - css::uno::Reference< css::document::XEventsSupplier > xSup; - - ::rtl::OUString sName = SfxEventConfiguration::GetEventName_Impl(pNamedHint->GetEventId()); - SfxObjectShell* pShell = pNamedHint->GetObjShell(); - if (pShell) - xSup = css::uno::Reference< css::document::XEventsSupplier >(pShell->GetModel(), UNO_QUERY); - - css::document::EventObject aEvent(xSup, sName); - notifyEvent(aEvent); -} - //----------------------------------------------------------------------------- css::uno::Reference< css::container::XNameReplace > SAL_CALL SfxGlobalEvents_Impl::getEvents() throw(css::uno::RuntimeException) diff --git a/sfx2/source/view/frame.cxx b/sfx2/source/view/frame.cxx index 674c209b65cc..42e9a1d04cb6 100644 --- a/sfx2/source/view/frame.cxx +++ b/sfx2/source/view/frame.cxx @@ -296,7 +296,7 @@ sal_uInt16 SfxFrame::PrepareClose_Impl( sal_Bool bUI, sal_Bool bForBrowsing ) bOther = ( pFrame->GetFrame() != this ); } - SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_PREPARECLOSEVIEW, pCur) ); + SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_PREPARECLOSEVIEW, GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEVIEW ), pCur) ); if ( bOther ) // if there are other views only the current view of this frame must be asked diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index 8d7562b0c495..b91e1e6b4998 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -79,6 +79,7 @@ namespace css = ::com::sun::star; #endif +#include #include #include #include @@ -396,76 +397,88 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const css::uno::Sequence< css::bean return bLoadState; } - String sStandardTemplate = SfxObjectFactory::GetStandardTemplate( aServiceName ); - BOOL bUseDefaultTemplate = (sStandardTemplate.Len()>0); - if( bUseDefaultTemplate ) - { - // #i21583# - // Forget the filter, which was detected for the corresponding "private:factory/xxx" URL. - // We must use the right filter, matching to this document ... not to the private URL! - const SfxFilter* pTemplateFilter = impl_detectFilterForURL(sStandardTemplate, rArgs, rMatcher); - if (pTemplateFilter) - { - pFilter = pTemplateFilter; - aFilterName = pTemplateFilter->GetName(); - // standard template set -> load it "AsTemplate" - aSet.Put( SfxStringItem ( SID_FILE_NAME, sStandardTemplate ) ); - aSet.Put( SfxBoolItem( SID_TEMPLATE, sal_True ) ); - } + String sTemplateURL; + SFX_ITEMSET_ARG( &aSet, pTemplateRegionItem, SfxStringItem, SID_TEMPLATE_REGIONNAME, FALSE ); + SFX_ITEMSET_ARG( &aSet, pTemplateNameItem, SfxStringItem, SID_TEMPLATE_NAME, FALSE ); + if ( pTemplateRegionItem && pTemplateNameItem ) + { + SfxDocumentTemplates aTmpFac; + aTmpFac.GetFull( pTemplateRegionItem->GetValue(), pTemplateNameItem->GetValue(), sTemplateURL ); + } + else + { + sTemplateURL = SfxObjectFactory::GetStandardTemplate( aServiceName ); + } - // #119268# - // something is wrong with the set default template (e.g. unknown format, missing file etcpp) - // The we have to jump into the following special code, where "private:factory/ URL's are handled. - // We cant "load" such private/factory URL's! - else - bUseDefaultTemplate = FALSE; + BOOL bUseTemplate = (sTemplateURL.Len()>0); + if( bUseTemplate ) + { + // #i21583# + // Forget the filter, which was detected for the corresponding "private:factory/xxx" URL. + // We must use the right filter, matching to this document ... not to the private URL! + const SfxFilter* pTemplateFilter = impl_detectFilterForURL(sTemplateURL, rArgs, rMatcher); + if (pTemplateFilter) + { + pFilter = pTemplateFilter; + aFilterName = pTemplateFilter->GetName(); + // standard template set -> load it "AsTemplate" + aSet.Put( SfxStringItem ( SID_FILE_NAME, sTemplateURL ) ); + aSet.Put( SfxBoolItem( SID_TEMPLATE, sal_True ) ); } - if ( !bUseDefaultTemplate ) - { - // execute "NewDocument" request - /* Attention! - #107913# - Pointers can't be used to check if two objects are equals! - E.g. the memory manager can reuse freed memory ... - and then the holded copy of a pointer will point to another - (and different!) object - may using the same type then before. - In such case we compare one object with itself ... - */ - SfxRequest aReq( SID_NEWDOCDIRECT, SFX_CALLMODE_SYNCHRON, aSet ); - aReq.AppendItem( SfxFrameItem( SID_DOCFRAME, pFrame ) ); - aReq.AppendItem( SfxStringItem( SID_NEWDOCDIRECT, aFact ) ); - - if ( pDocumentTitleItem ) - aReq.AppendItem( *pDocumentTitleItem ); - - const SfxPoolItem* pRet = pApp->NewDocDirectExec_ImplOld(aReq); - if (pRet) - { - // default must be set to true, because some return values - // cant be checked ... but indicates "success"! - bLoadState = sal_True; + // #119268# + // something is wrong with the set default template (e.g. unknown format, missing file etcpp) + // The we have to jump into the following special code, where "private:factory/ URL's are handled. + // We cant "load" such private/factory URL's! + else + bUseTemplate = FALSE; + } - // On the other side some special slots return a boolean state, - // which can be set to FALSE. - SfxBoolItem *pItem = PTR_CAST( SfxBoolItem, pRet ); - if (pItem) - bLoadState = pItem->GetValue(); - } - else - bLoadState = sal_False; + if ( !bUseTemplate ) + { + // execute "NewDocument" request + /* Attention! + #107913# + Pointers can't be used to check if two objects are equals! + E.g. the memory manager can reuse freed memory ... + and then the holded copy of a pointer will point to another + (and different!) object - may using the same type then before. + In such case we compare one object with itself ... + */ + SfxRequest aReq( SID_NEWDOCDIRECT, SFX_CALLMODE_SYNCHRON, aSet ); + aReq.AppendItem( SfxFrameItem( SID_DOCFRAME, pFrame ) ); + aReq.AppendItem( SfxStringItem( SID_NEWDOCDIRECT, aFact ) ); + + if ( pDocumentTitleItem ) + aReq.AppendItem( *pDocumentTitleItem ); + + const SfxPoolItem* pRet = pApp->NewDocDirectExec_ImplOld(aReq); + if (pRet) + { + // default must be set to true, because some return values + // cant be checked ... but indicates "success"! + bLoadState = sal_True; - if ( !bLoadState && bFrameCreated && wFrame && !wFrame->GetCurrentDocument() ) - { - css::uno::Reference< css::frame::XFrame > axFrame; - wFrame->SetFrameInterface_Impl( axFrame ); - wFrame->DoClose(); - } + // On the other side some special slots return a boolean state, + // which can be set to FALSE. + SfxBoolItem *pItem = PTR_CAST( SfxBoolItem, pRet ); + if (pItem) + bLoadState = pItem->GetValue(); + } + else + bLoadState = sal_False; - xFrame.clear(); - xListener.clear(); - return bLoadState; + if ( !bLoadState && bFrameCreated && wFrame && !wFrame->GetCurrentDocument() ) + { + css::uno::Reference< css::frame::XFrame > axFrame; + wFrame->SetFrameInterface_Impl( axFrame ); + wFrame->DoClose(); } + + xFrame.clear(); + xListener.clear(); + return bLoadState; + } } else { diff --git a/sfx2/source/view/prnmon.cxx b/sfx2/source/view/prnmon.cxx index 9fdd29db2805..21d484e550ab 100644 --- a/sfx2/source/view/prnmon.cxx +++ b/sfx2/source/view/prnmon.cxx @@ -388,7 +388,7 @@ IMPL_LINK_INLINE_END( SfxPrintProgress, PrintErrorNotify, void *, EMPTYARG ) IMPL_LINK( SfxPrintProgress, StartPrintNotify, void *, EMPTYARG ) { SfxObjectShell *pObjShell = pImp->pViewShell->GetObjectShell(); - SFX_APP()->NotifyEvent(SfxEventHint(SFX_EVENT_PRINTDOC, pObjShell)); + SFX_APP()->NotifyEvent(SfxEventHint(SFX_EVENT_PRINTDOC, GlobalEventConfig::GetEventName( STR_EVENT_PRINTDOC ), pObjShell)); pObjShell->Broadcast( SfxPrintingHint( com::sun::star::view::PrintableState_JOB_STARTED, NULL, NULL ) ); return 0; } diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index ca9b4149339e..54ccd29a7dd7 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -1148,9 +1148,9 @@ void SAL_CALL SfxBaseController::dispose() throw( ::com::sun::star::uno::Runtime if ( m_pData->m_bIsFrameReleasedWithController ) { - SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_CLOSEVIEW, pDoc ) ); + SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_CLOSEVIEW, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEVIEW ), pDoc ) ); if ( !pView ) - SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_CLOSEDOC, pDoc) ); + SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), pDoc) ); } REFERENCE< XMODEL > xModel = pDoc->GetModel(); diff --git a/sfx2/source/view/topfrm.cxx b/sfx2/source/view/topfrm.cxx index 205fdf788ba1..01c48f8f2be0 100644 --- a/sfx2/source/view/topfrm.cxx +++ b/sfx2/source/view/topfrm.cxx @@ -210,6 +210,9 @@ long SfxTopWindow_Impl::Notify( NotifyEvent& rNEvt ) if ( nHelpId ) SfxHelp::OpenHelpAgent( pFrame, nHelpId ); + // if focus was on an external window, the clipboard content might have been changed + pView->GetBindings().Invalidate( SID_PASTE ); + pView->GetBindings().Invalidate( SID_PASTE_SPECIAL ); return sal_True; } else if( rNEvt.GetType() == EVENT_KEYINPUT ) @@ -1016,7 +1019,7 @@ sal_Bool SfxTopFrame::InsertDocument( SfxObjectShell* pDoc ) GetCurrentViewFrame()->Resize(TRUE); } - SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_VIEWCREATED, pDoc ) ); + SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_VIEWCREATED, GlobalEventConfig::GetEventName( STR_EVENT_VIEWCREATED ), pDoc ) ); return sal_True; } diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 1097ae9cdc8f..592926bca1ce 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -867,7 +867,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) if ( xNewObj.Is() ) { // Propagate document closure. - SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_CLOSEDOC, xOldObj ) ); + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), xOldObj ) ); } // als erledigt recorden @@ -1145,7 +1145,7 @@ void SfxViewFrame::SetObjectShell_Impl SwitchToViewShell_Impl( !IsRestoreView_Impl() ? (sal_uInt16) 0 : GetCurViewId() ); rObjSh.PostActivateEvent_Impl( this ); if ( Current() == this ) - SFX_APP()->NotifyEvent(SfxEventHint(SFX_EVENT_ACTIVATEDOC, &rObjSh ) ); + SFX_APP()->NotifyEvent(SfxEventHint(SFX_EVENT_ACTIVATEDOC, GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC ), &rObjSh ) ); Notify( rObjSh, SfxSimpleHint(SFX_HINT_TITLECHANGED) ); Notify( rObjSh, SfxSimpleHint(SFX_HINT_DOCCHANGED) ); @@ -1518,6 +1518,8 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) case SFX_HINT_MODECHANGED: { // r/o Umschaltung? + SfxBindings& rBind = GetBindings(); + rBind.Invalidate( SID_RELOAD ); SfxDispatcher *pDispat = GetDispatcher(); sal_Bool bWasReadOnly = pDispat->GetReadOnly_Impl(); sal_Bool bIsReadOnly = xObjSh->IsReadOnly(); @@ -1525,8 +1527,9 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { // Dann auch TITLE_CHANGED UpdateTitle(); - GetBindings().Invalidate( SID_FILE_NAME ); - GetBindings().Invalidate( SID_DOCINFO_TITLE ); + rBind.Invalidate( SID_FILE_NAME ); + rBind.Invalidate( SID_DOCINFO_TITLE ); + rBind.Invalidate( SID_EDITDOC ); pDispat->GetBindings()->InvalidateAll(sal_True); pDispat->SetReadOnly_Impl( bIsReadOnly ); @@ -1547,8 +1550,11 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) case SFX_HINT_TITLECHANGED: { UpdateTitle(); - GetBindings().Invalidate( SID_FILE_NAME ); - GetBindings().Invalidate( SID_DOCINFO_TITLE ); + SfxBindings& rBind = GetBindings(); + rBind.Invalidate( SID_FILE_NAME ); + rBind.Invalidate( SID_DOCINFO_TITLE ); + rBind.Invalidate( SID_EDITDOC ); + rBind.Invalidate( SID_RELOAD ); break; } @@ -1576,12 +1582,16 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) rBind.Invalidate( SID_DOC_MODIFIED ); rBind.Invalidate( SID_SAVEDOC ); rBind.Invalidate( SID_RELOAD ); + rBind.Invalidate( SID_EDITDOC ); break; } case SFX_EVENT_OPENDOC: case SFX_EVENT_CREATEDOC: { + SfxBindings& rBind = GetBindings(); + rBind.Invalidate( SID_RELOAD ); + rBind.Invalidate( SID_EDITDOC ); if ( !xObjSh->IsReadOnly() ) { // Im Gegensatz zu oben (TITLE_CHANGED) mu\s das UI nicht diff --git a/sfx2/source/view/viewimp.hxx b/sfx2/source/view/viewimp.hxx index 5188f84a43b6..f75d68fe1413 100644 --- a/sfx2/source/view/viewimp.hxx +++ b/sfx2/source/view/viewimp.hxx @@ -45,6 +45,8 @@ #include #include +#include + // forward --------------------------------------------------------------- class SfxOfficeDispatch; @@ -54,6 +56,20 @@ typedef SfxShell* SfxShellPtr_Impl; SV_DECL_PTRARR( SfxShellArr_Impl, SfxShellPtr_Impl, 4, 4 ) // struct SfxViewShell_Impl ---------------------------------------------- +class SfxAsyncPrintExec_Impl : public SfxListener +{ + SfxViewShell* pView; + ::std::queue < SfxRequest*> aReqs; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + +public: + SfxAsyncPrintExec_Impl( SfxViewShell* pShell) + : pView( pShell ) + {} + + void AddRequest( SfxRequest& rReq ); +}; struct SfxViewShell_Impl { @@ -78,6 +94,7 @@ struct SfxViewShell_Impl USHORT nFamily; SfxBaseController* pController; ::svt::AcceleratorExecute* pAccExec; + SfxAsyncPrintExec_Impl* pPrinterCommandQueue; com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > aPrintOpts; SfxViewShell_Impl() diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 3c2054a4a881..c944264dd20c 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -53,6 +53,7 @@ #include #include +#include #include "viewimp.hxx" #include #include @@ -71,6 +72,43 @@ TYPEINIT1(SfxPrintingHint, SfxHint); // ----------------------------------------------------------------------- +void SfxAsyncPrintExec_Impl::AddRequest( SfxRequest& rReq ) +{ + if ( rReq.GetArgs() ) + { + // only queue API requests + if ( aReqs.empty() ) + StartListening( *pView->GetObjectShell() ); + + aReqs.push( new SfxRequest( rReq ) ); + } +} + +void SfxAsyncPrintExec_Impl::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) +{ + if ( &rBC == pView->GetObjectShell() ) + { + SfxPrintingHint* pPrintHint = PTR_CAST( SfxPrintingHint, &rHint ); + if ( pPrintHint && pPrintHint->GetWhich() == com::sun::star::view::PrintableState_JOB_COMPLETED ) + { + while ( aReqs.front() ) + { + SfxRequest* pReq = aReqs.front(); + aReqs.pop(); + pView->GetViewFrame()->GetDispatcher()->Execute( pReq->GetSlot(), SFX_CALLMODE_ASYNCHRON, *pReq->GetArgs() ); + USHORT nSlot = pReq->GetSlot(); + delete pReq; + if ( nSlot == SID_PRINTDOC || nSlot == SID_PRINTDOCDIRECT ) + // print jobs must be executed before the next command can be dispatched + break; + } + + if ( aReqs.empty() ) + EndListening( *pView->GetObjectShell() ); + } + } +} + void DisableRanges( PrintDialog& rDlg, SfxPrinter* pPrinter ) /* [Beschreibung] @@ -389,13 +427,19 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) { USHORT nCopies=1; USHORT nDialogRet = RET_CANCEL; - BOOL bCollate=FALSE; + BOOL bCollate=TRUE; SfxPrinter* pPrinter = 0; PrintDialog* pPrintDlg = 0; SfxDialogExecutor_Impl* pExecutor = 0; bool bSilent = false; BOOL bIsAPI = rReq.GetArgs() && rReq.GetArgs()->Count(); + if ( bIsAPI && GetPrinter( FALSE ) && GetPrinter( FALSE )->IsPrinting() ) + { + pImp->pPrinterCommandQueue->AddRequest( rReq ); + return; + } + const USHORT nId = rReq.GetSlot(); switch( nId ) { @@ -866,8 +910,11 @@ ErrCode SfxViewShell::DoPrint( SfxPrinter *pPrinter, else if ( pDocPrinter != pPrinter ) { pProgress->RestoreOnEndPrint( pDocPrinter->Clone() ); - SetPrinter( pPrinter, SFX_PRINTER_PRINTER ); + USHORT nError = SetPrinter( pPrinter, SFX_PRINTER_PRINTER ); + if ( nError != SFX_PRINTERROR_NONE ) + return PRINTER_ACCESSDENIED; } + pProgress->SetWaitMode(FALSE); // Drucker starten diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 70bbc4a28d02..299c928c748b 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -47,6 +47,9 @@ #include #include #include +#include +#include +#include #include #include @@ -112,6 +115,68 @@ DBG_NAME(SfxViewShell) //========================================================================= +class SfxClipboardChangeListener : public ::cppu::WeakImplHelper1< + datatransfer::clipboard::XClipboardListener > +{ + SfxViewShell* pViewShell; + + // XEventListener + virtual void SAL_CALL disposing( const lang::EventObject& rEventObject ) + throw ( uno::RuntimeException ); + + // XClipboardListener + virtual void SAL_CALL changedContents( const datatransfer::clipboard::ClipboardEvent& rEventObject ) + throw ( uno::RuntimeException ); + +public: + SfxClipboardChangeListener( SfxViewShell* pView ); + virtual ~SfxClipboardChangeListener(); +}; + +SfxClipboardChangeListener::SfxClipboardChangeListener( SfxViewShell* pView ) +: pViewShell( 0 ) +{ + uno::Reference < lang::XComponent > xCtrl( pView->GetController(), uno::UNO_QUERY ); + if ( xCtrl.is() ) + { + xCtrl->addEventListener( uno::Reference < lang::XEventListener > ( static_cast < lang::XEventListener* >( this ) ) ); + pViewShell = pView; + } +} + +SfxClipboardChangeListener::~SfxClipboardChangeListener() +{ +} + +void SAL_CALL SfxClipboardChangeListener::disposing( const lang::EventObject& /*rEventObject*/ ) +throw ( uno::RuntimeException ) +{ + // either clipboard or ViewShell is going to be destroyed -> no interest in listening anymore + const ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if ( pViewShell ) + { + uno::Reference < lang::XComponent > xCtrl( pViewShell->GetController(), uno::UNO_QUERY ); + if ( xCtrl.is() ) + xCtrl->removeEventListener( uno::Reference < lang::XEventListener > ( static_cast < lang::XEventListener* >( this ) ) ); + pViewShell->AddRemoveClipboardListener( uno::Reference < datatransfer::clipboard::XClipboardListener > (this), FALSE ); + pViewShell = 0; + } +} + +void SAL_CALL SfxClipboardChangeListener::changedContents( const datatransfer::clipboard::ClipboardEvent& ) + throw ( RuntimeException ) +{ + const ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if( pViewShell ) + { + SfxBindings& rBind = pViewShell->GetViewFrame()->GetBindings(); + rBind.Invalidate( SID_PASTE ); + rBind.Invalidate( SID_PASTE_SPECIAL ); + rBind.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS ); + } +} + + static ::rtl::OUString RetrieveLabelFromCommand( const ::rtl::OUString& rCommandURL, const css::uno::Reference< css::frame::XFrame >& rFrame ) @@ -687,6 +752,7 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet ) case SID_PRINTDOC: case SID_PRINTDOCDIRECT: case SID_SETUPPRINTER: + case SID_PRINTER_NAME: { BOOL bEnabled = pImp->bCanPrint && !pImp->nPrinterLocks; bEnabled = bEnabled && !Application::GetSettings().GetMiscSettings().GetDisablePrinting(); @@ -720,9 +786,10 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet ) } if ( !bEnabled ) { - rSet.DisableItem( SID_PRINTDOC ); + // will now be handled by requeing the request + /* rSet.DisableItem( SID_PRINTDOC ); rSet.DisableItem( SID_PRINTDOCDIRECT ); - rSet.DisableItem( SID_SETUPPRINTER ); + rSet.DisableItem( SID_SETUPPRINTER ); */ } break; } @@ -1187,6 +1254,7 @@ SfxViewShell::SfxViewShell { DBG_CTOR(SfxViewShell, 0); + pImp->pPrinterCommandQueue = new SfxAsyncPrintExec_Impl( this ); pImp->pController = 0; pImp->bIsShowView = !(SFX_VIEW_NO_SHOW == (nFlags & SFX_VIEW_NO_SHOW)); @@ -1240,6 +1308,8 @@ SfxViewShell::~SfxViewShell() delete pImp->pAccExec; pImp->pAccExec = 0; } + + delete pImp->pPrinterCommandQueue; delete pImp; delete pIPClientList; } @@ -1926,6 +1996,8 @@ void SfxViewShell::SetController( SfxBaseController* pController ) pImp->pController = pController; pImp->pController->acquire(); pImp->bControllerSet = TRUE; + + AddRemoveClipboardListener( new SfxClipboardChangeListener( this ), TRUE ); } Reference < XController > SfxViewShell::GetController() @@ -2128,3 +2200,25 @@ BOOL SfxViewShell::Escape() { return GetViewFrame()->GetBindings().Execute( SID_TERMINATE_INPLACEACTIVATION ); } + +void SfxViewShell::AddRemoveClipboardListener( const uno::Reference < datatransfer::clipboard::XClipboardListener >& rClp, BOOL bAdd ) +{ + try + { + uno::Reference< datatransfer::clipboard::XClipboard > xClipboard( GetViewFrame()->GetWindow().GetClipboard() ); + if( !xClipboard.is() ) + return; + + uno::Reference< datatransfer::clipboard::XClipboardNotifier > xClpbrdNtfr( xClipboard, uno::UNO_QUERY ); + if( xClpbrdNtfr.is() ) + { + if( bAdd ) + xClpbrdNtfr->addClipboardListener( rClp ); + else + xClpbrdNtfr->removeClipboardListener( rClp ); + } + } + catch( const uno::Exception& ) + { + } +} -- cgit From 1afd62eb12424c9ada63aa9513e46c49dff9db62 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Fri, 18 Sep 2009 11:54:06 +0000 Subject: CWS-TOOLING: integrate CWS dtrans2vcl 2009-09-09 19:47:56 +0200 pl r276016 : merge fix for #i104390# into moved code 2009-09-07 12:50:47 +0200 pl r275891 : remove nonexistant header 2009-09-04 16:47:05 +0200 pl r275819 : forgot calling convention for Windoze 2009-09-04 13:27:36 +0200 pl r275800 : #150926# remove X11 dependency 2009-09-04 13:19:08 +0200 pl r275799 : #150926# move mac dtrans service to vcl to be used in service implementation 2009-09-03 21:19:01 +0200 pl r275774 : fix warning, adjust comment 2009-09-03 18:36:01 +0200 pl r275768 : no more sjlib 2009-09-03 17:56:49 +0200 pl r275767 : remove unused X11 link dependency 2009-09-03 17:43:35 +0200 pl r275766 : headless not used in X11 case 2009-09-03 17:34:36 +0200 pl r275765 : #150926# bye bye sj2 2009-09-03 16:19:04 +0200 pl r275761 : #150926# bye bye sj2, x11 dependenices removed where not necessary 2009-09-01 17:22:54 +0200 pl r275674 : #150926# step 1: move X11 code from dtrans to vcl, adapt glue code --- sfx2/inc/pch/precompiled_sfx2.hxx | 1 - sfx2/source/appl/appcfg.cxx | 5 ++++- sfx2/source/appl/appuno.cxx | 6 +++++- sfx2/source/doc/makefile.mk | 3 ++- sfx2/util/makefile.mk | 1 - 5 files changed, 11 insertions(+), 5 deletions(-) (limited to 'sfx2') diff --git a/sfx2/inc/pch/precompiled_sfx2.hxx b/sfx2/inc/pch/precompiled_sfx2.hxx index 0de2e2e208d1..03f38a27fe4f 100644 --- a/sfx2/inc/pch/precompiled_sfx2.hxx +++ b/sfx2/inc/pch/precompiled_sfx2.hxx @@ -485,7 +485,6 @@ #include "sal/types.h" #include "setup_native/qswin32.h" #include "shell/systemshell.hxx" -#include "sj2/sjapplet.hxx" #include "sot/clsids.hxx" #include "sot/exchange.hxx" #include "sot/factory.hxx" diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx index c191f765200f..725b9034add0 100644 --- a/sfx2/source/appl/appcfg.cxx +++ b/sfx2/source/appl/appcfg.cxx @@ -62,7 +62,7 @@ #include //#include -#include +//#include #include #include @@ -850,6 +850,8 @@ void SfxApplication::SetOptions_Impl( const SfxItemSet& rSet ) // INet Session neu aufsetzen if ( bResetSession ) { + // no more sj2 + #if 0 try { SjApplet2::settingsChanged(); @@ -858,6 +860,7 @@ void SfxApplication::SetOptions_Impl( const SfxItemSet& rSet ) { DBG_ERRORFILE( "SjApplet2::settingsChanged() throws an exception" ); } + #endif } // geaenderte Daten speichern diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 90b12b484a01..c9814eb50e6a 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -137,7 +137,7 @@ using namespace ::com::sun::star::io; #include "brokenpackageint.hxx" #include "eventsupplier.hxx" #include "xpackcreator.hxx" -#include "applet.hxx" +// #include "applet.hxx" #include "plugin.hxx" #include "iframe.hxx" #include @@ -2150,6 +2150,7 @@ SFX2_DLLPUBLIC sal_Bool SAL_CALL component_writeInfo( xNewKey = xKey->createKey( aTempStr ); xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.frame.SpecialEmbeddedObject") ); + #if 0 // AppletObject aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); aImpl += ::sfx2::AppletObject::impl_getStaticImplementationName(); @@ -2158,6 +2159,7 @@ SFX2_DLLPUBLIC sal_Bool SAL_CALL component_writeInfo( aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES")); xNewKey = xKey->createKey( aTempStr ); xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.frame.SpecialEmbeddedObject") ); + #endif // IFrameObject aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); @@ -2324,11 +2326,13 @@ SFX2_DLLPUBLIC void* SAL_CALL component_getFactory( IF_NAME_CREATECOMPONENTFACTORY( TestMouseClickHandler ) #endif IF_NAME_CREATECOMPONENTFACTORY( OPackageStructureCreator ) + #if 0 if ( ::sfx2::AppletObject::impl_getStaticImplementationName().equals( ::rtl::OUString::createFromAscii( pImplementationName ) ) ) { xFactory = ::sfx2::AppletObject::impl_createFactory(); } + #endif IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::PluginObject ) IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::IFrameObject ) IF_NAME_CREATECOMPONENTFACTORY( ::sfx2::OwnSubFilterService ) diff --git a/sfx2/source/doc/makefile.mk b/sfx2/source/doc/makefile.mk index 986755558cf2..1b42844491e0 100644 --- a/sfx2/source/doc/makefile.mk +++ b/sfx2/source/doc/makefile.mk @@ -55,7 +55,6 @@ SLOFILES = \ $(SLO)$/docinf.obj \ $(SLO)$/oleprops.obj \ $(SLO)$/iframe.obj \ - $(SLO)$/applet.obj \ $(SLO)$/plugin.obj \ $(SLO)$/docfile.obj \ $(SLO)$/objuno.obj \ @@ -90,6 +89,8 @@ SLOFILES = \ $(SLO)$/docstoragemodifylistener.obj \ $(SLO)$/querytemplate.obj +# $(SLO)$/applet.obj \ + # --- Tagets ------------------------------------------------------- diff --git a/sfx2/util/makefile.mk b/sfx2/util/makefile.mk index 5ee6e64daca0..6bdb4a8122a6 100644 --- a/sfx2/util/makefile.mk +++ b/sfx2/util/makefile.mk @@ -98,7 +98,6 @@ SHL1STDLIBS+=\ $(CPPULIB) \ $(VOSLIB) \ $(SALLIB) \ - $(SJLIB) \ $(LIBXML2LIB) \ -- cgit From 63ef7f15b56bf3f040f50c31d257f1d958dd5523 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Fri, 18 Sep 2009 12:31:43 +0000 Subject: CWS-TOOLING: integrate CWS calc32stopper1 2009-09-15 15:43:23 +0200 dr r276180 : newpic 2009-09-15 15:41:13 +0200 dr r276179 : newpic 2009-09-15 14:58:14 +0200 dr r276178 : #i104905# fixed note handling while importing from external data 2009-09-15 13:47:43 +0200 dr r276173 : #i104905# fixed note handling while importing from database 2009-09-15 11:56:00 +0200 dr r276164 : #i104155# prevent crash loading docx 2009-09-15 10:40:43 +0200 dr r276154 : #i104990# 2009-09-15 10:27:31 +0200 dr r276152 : #i104990# enable saving BIFF8 with password/encryption 2009-09-15 10:26:40 +0200 dr r276151 : #i104990# enable saving BIFF8 with password/encryption 2009-09-14 19:13:11 +0200 dr r276145 : #i105007# missing cleanup for deleted headers 2009-09-14 19:06:57 +0200 dr r276144 : #i105007# missing cleanup for deleted headers 2009-09-14 18:53:39 +0200 dr r276143 : #i104915# prevent crashes and misbehaviour when dealing with note cells: enter matrix, enter mult.op 2009-09-14 13:57:00 +0200 dr r276109 : #160184# make drilldown working in exported pivottables, ported to DEV300 2009-09-11 15:16:08 +0200 nn r276068 : #i104987# MoveBlock: pass bCut parameter 2009-09-11 15:15:22 +0200 nn r276067 : #i104986# CopyToClip: correct order of parameters 2009-09-11 09:45:59 +0200 dr r276053 : correct milestone --- sfx2/inc/sfx2/docfilt.hxx | 14 ++++++++ sfx2/source/dialog/filedlghelper.cxx | 66 +++++++++++++++--------------------- sfx2/source/doc/docfilt.cxx | 14 ++++++++ 3 files changed, 56 insertions(+), 38 deletions(-) (limited to 'sfx2') diff --git a/sfx2/inc/sfx2/docfilt.hxx b/sfx2/inc/sfx2/docfilt.hxx index dbeba0763c67..47c1cba003e5 100644 --- a/sfx2/inc/sfx2/docfilt.hxx +++ b/sfx2/inc/sfx2/docfilt.hxx @@ -74,6 +74,20 @@ #include +//======================================================================== + +namespace sfx2 { + +/** Returns true if the passed string is the name of a Microsoft Office file + format filter supporting export of password protected documents. + + This function is just a hack for #i105076# is fixed and needs to be removed + then. + */ +SFX2_DLLPUBLIC bool CheckMSPasswordCapabilityForExport( const String& rFilterName ); + +} // namespace sfx2 + //======================================================================== class SfxFilterContainer; class SotStorage; diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index d8989c6a21ea..5a0d2f4a69a0 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -467,6 +467,31 @@ sal_Bool FileDialogHelper_Impl::isInOpenMode() const // ------------------------------------------------------------------------ +namespace { + +bool lclCheckODFPasswordCapability( const SfxFilter* pFilter ) +{ + return pFilter && pFilter->IsOwnFormat() && pFilter->UsesStorage() && (pFilter->GetVersion() >= SOFFICE_FILEFORMAT_60); +} + +bool lclCheckMSPasswordCapability( const SfxFilter* pFilter ) +{ + // TODO #i105076# this should be in the filter configuration!!! + return pFilter && CheckMSPasswordCapabilityForExport( pFilter->GetFilterName() ); +} + +bool lclCheckPasswordCapability( const SfxFilter* pFilter ) +{ + return + lclCheckODFPasswordCapability( pFilter ) || + // TODO #i105076# this should be in the filter configuration!!! + lclCheckMSPasswordCapability( pFilter ); +} + +} + +// ------------------------------------------------------------------------ + void FileDialogHelper_Impl::updateFilterOptionsBox() { if ( !m_bHaveFilterOptions ) @@ -549,40 +574,6 @@ void FileDialogHelper_Impl::updateSelectionBox() } } -// ------------------------------------------------------------------------ - -namespace { - -bool lclCheckMSPasswordCapability( const String rFilterName ) -{ - return rFilterName.EqualsAscii("MS Word 97"); -} - -} // namespace - -// ------------------------------------------------------------------------ -struct CheckPasswordCapability -{ - sal_Bool operator() ( const SfxFilter* _pFilter ) - { - if (!_pFilter) - return false; - -#if 0 // to be enabled in the future - if (_pFilter->GetFilterName().EqualsAscii("MS Excel 97")) - // For now, we eanble password protection for Excel 97 as a - // special case. If we start having more filters supporting - // export encryption with password, we should probably switch to - // using a filter flag instead. - return true; -#endif - - return ( _pFilter->IsOwnFormat() && _pFilter->UsesStorage() - && ( SOFFICE_FILEFORMAT_60 <= _pFilter->GetVersion() ) ) - || lclCheckMSPasswordCapability( _pFilter->GetFilterName() ); - } -}; - // ------------------------------------------------------------------------ void FileDialogHelper_Impl::enablePasswordBox( sal_Bool bInit ) { @@ -593,7 +584,7 @@ void FileDialogHelper_Impl::enablePasswordBox( sal_Bool bInit ) mbIsPwdEnabled = updateExtendedControl( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, - CheckPasswordCapability()( getCurentSfxFilter() ) + lclCheckPasswordCapability( getCurentSfxFilter() ) ); if( bInit ) @@ -1665,9 +1656,8 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, if( xInteractionHandler.is() ) { - // TODO: find out a way to set the 1-15 char limits on MS Excel 97 filter. - - bool bMSType = lclCheckMSPasswordCapability( rFilter ); + // TODO: need a save way to distinguish MS filters from other filters + bool bMSType = CheckMSPasswordCapabilityForExport( rFilter ); ::comphelper::DocPasswordRequestType eType = bMSType ? ::comphelper::DocPasswordRequestType_MS : ::comphelper::DocPasswordRequestType_STANDARD; diff --git a/sfx2/source/doc/docfilt.cxx b/sfx2/source/doc/docfilt.cxx index 929e486f824a..d8b6d23b8d03 100644 --- a/sfx2/source/doc/docfilt.cxx +++ b/sfx2/source/doc/docfilt.cxx @@ -52,6 +52,20 @@ using namespace ::com::sun::star; +namespace sfx2 { + +// TODO #i105076# this should be in the filter configuration!!! +bool CheckMSPasswordCapabilityForExport( const String& rFilterName ) +{ + return + rFilterName.EqualsAscii( "MS Word 97" ) || + rFilterName.EqualsAscii( "MS Word 97 Vorlage" ) || + rFilterName.EqualsAscii( "MS Excel 97" ) || + rFilterName.EqualsAscii( "MS Excel 97 Vorlage/Template" ); +} + +} // namespace sfx2 + // STATIC DATA ----------------------------------------------------------- DBG_NAME(SfxFilter) -- cgit From d316e5f2e9b6900d270a156597cf5eb533c4c4a1 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Fri, 18 Sep 2009 12:52:22 +0000 Subject: #i10000# buildfix --- sfx2/source/doc/objxtor.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sfx2') diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 36a3673e0d6a..c670f07aba0f 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -582,7 +582,7 @@ sal_uInt16 SfxObjectShell::PrepareClose } } - SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_PREPARECLOSEDOC, this) ); + SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_PREPARECLOSEDOC, GlobalEventConfig::GetEventName(STR_EVENT_PREPARECLOSEDOC), this) ); if( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) { -- cgit From 4c15b643ea7e0300f5e68f830fad9aebf9429e8c Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Fri, 18 Sep 2009 14:21:10 +0000 Subject: #i10000# fix of the fix --- sfx2/source/doc/objxtor.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index c670f07aba0f..950ecf9ea239 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -582,7 +582,8 @@ sal_uInt16 SfxObjectShell::PrepareClose } } - SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_PREPARECLOSEDOC, GlobalEventConfig::GetEventName(STR_EVENT_PREPARECLOSEDOC), this) ); + SfxApplication *pSfxApp = SFX_APP(); + pSfxApp->NotifyEvent( SfxEventHint(SFX_EVENT_PREPARECLOSEDOC, GlobalEventConfig::GetEventName(STR_EVENT_PREPARECLOSEDOC), this) ); if( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) { @@ -597,9 +598,6 @@ sal_uInt16 SfxObjectShell::PrepareClose while ( pFrame && (pFrame->GetFrameType() & SFXFRAME_SERVER ) ) pFrame = SfxViewFrame::GetNext( *pFrame, this ); - SfxApplication *pSfxApp = SFX_APP(); - pSfxApp->NotifyEvent( SfxEventHint(SFX_EVENT_PREPARECLOSEDOC, GlobalEventConfig::GetEventName(STR_EVENT_PREPARECLOSEDOC), this) ); - sal_Bool bClose = sal_False; if ( bUI && IsModified() ) { -- cgit From fc5be954f3a2fa52e57174c03a5004c9012fce0c Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Mon, 21 Sep 2009 10:29:39 +0000 Subject: #i10000# removed debug code --- sfx2/source/appl/appcfg.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx index 725b9034add0..af31659ec24c 100644 --- a/sfx2/source/appl/appcfg.cxx +++ b/sfx2/source/appl/appcfg.cxx @@ -1049,10 +1049,10 @@ void SfxApplication::NotifyEvent( const SfxEventHint& rEventHint, FASTBOOL bSync return; #ifdef DBG_UTIL - ::rtl::OUString aName = SfxEventConfiguration::GetEventName_Impl( rEventHint.GetEventId() ); - ByteString aTmp( "SfxEvent: "); - aTmp += ByteString( String(aName), RTL_TEXTENCODING_UTF8 ); - DBG_TRACE( aTmp.GetBuffer() ); + //::rtl::OUString aName = SfxEventConfiguration::GetEventName_Impl( rEventHint.GetEventId() ); + //ByteString aTmp( "SfxEvent: "); + //aTmp += ByteString( String(aName), RTL_TEXTENCODING_UTF8 ); + //DBG_TRACE( aTmp.GetBuffer() ); #endif if ( bSynchron ) -- cgit