diff options
341 files changed, 10765 insertions, 12355 deletions
diff --git a/avmedia/source/quicktime/makefile.mk b/avmedia/source/quicktime/makefile.mk index fd472b99f041..a087e8007520 100644 --- a/avmedia/source/quicktime/makefile.mk +++ b/avmedia/source/quicktime/makefile.mk @@ -45,7 +45,7 @@ CDEFS+= -DVERBOSE # --- Files ---------------------------------- -CFLAGSCXX += -x objective-c++ -fobjc-exceptions +CFLAGSCXX+=$(OBJCXXFLAGS) SLOFILES= \ $(SLO)$/quicktimeuno.obj \ diff --git a/basic/prj/build.lst b/basic/prj/build.lst index ec6bd0e83930..994901580c86 100644 --- a/basic/prj/build.lst +++ b/basic/prj/build.lst @@ -1,4 +1,4 @@ -sb basic : l10n offuh svtools sj2 xmlscript framework NULL +sb basic : l10n offuh svtools xmlscript framework NULL sb basic usr1 - all sb_mkout NULL sb basic\inc nmake - all sb_inc NULL sb basic\source\app nmake - all sb_app sb_class sb_inc NULL diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 7ff7cb76c7c5..af056b884826 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -303,6 +303,33 @@ SbxObject* SbTypeFactory::cloneTypeObjectImpl( const SbxObject& rTypeObj ) if( pProp ) { SbxProperty* pNewProp = new SbxProperty( *pProp ); + if( pVar->GetType() & SbxARRAY )
+ {
+ SbxBase* pParObj = pVar->GetObject();
+ SbxDimArray* pSource = PTR_CAST(SbxDimArray,pParObj);
+ SbxDimArray* pDest = new SbxDimArray( pVar->GetType() );
+ INT32 lb = 0;
+ INT32 ub = 0;
+
+ pDest->setHasFixedSize( pSource->hasFixedSize() );
+ if ( pSource->GetDims() && pSource->hasFixedSize() )
+ {
+ for ( INT32 j = 1 ; j <= pSource->GetDims(); ++j )
+ {
+ pSource->GetDim32( (INT32)j, lb, ub );
+ pDest->AddDim32( lb, ub );
+ }
+ }
+ else
+ pDest->unoAddDim( 0, -1 ); // variant array
+
+ USHORT nSavFlags = pVar->GetFlags();
+ pNewProp->ResetFlag( SBX_FIXED );
+ // need to reset the FIXED flag
+ // when calling PutObject ( because the type will not match Object )
+ pNewProp->PutObject( pDest );
+ pNewProp->SetFlags( nSavFlags );
+ } pProps->PutDirect( pNewProp, i ); } } diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index a1bdb687b002..a6ae8cac29af 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -750,7 +750,11 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) // SbUnoObject instanzieren String aName; SbUnoObject* pSbUnoObject = new SbUnoObject( aName, aValue ); - if ( SbiRuntime::isVBAEnabled() ) + //If this is called externally e.g. from the scripting
+ //framework then there is no 'active' runtime the default property will not be set up
+ //only a vba object will have XDefaultProp set anyway so... this
+ //test seems a bit of overkill
+ //if ( SbiRuntime::isVBAEnabled() )
{ String sDfltPropName; diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx index d242071784b6..54e98f401594 100644 --- a/basic/source/comp/dim.cxx +++ b/basic/source/comp/dim.cxx @@ -212,7 +212,7 @@ void SbiParser::DefVar( SbiOpcode eOp, BOOL bStatic ) // #110004 It can also be a sub/function if( !bConst && (eCurTok == SUB || eCurTok == FUNCTION || eCurTok == PROPERTY || - eCurTok == STATIC || eCurTok == ENUM ) ) + eCurTok == STATIC || eCurTok == ENUM || eCurTok == DECLARE) ) { // Next token is read here, because !bConst bool bPrivate = ( eFirstTok == PRIVATE ); @@ -241,6 +241,12 @@ void SbiParser::DefVar( SbiOpcode eOp, BOOL bStatic ) DefEnum( bPrivate ); return; } + else if( eCurTok == DECLARE )
+ {
+ Next();
+ DefDeclare( bPrivate );
+ return;
+ }
} #ifdef SHARED @@ -546,7 +552,7 @@ void SbiParser::DefType( BOOL bPrivate ) SbxObject *pType = new SbxObject(aSym); SbiSymDef* pElem; - SbiDimList* pDim; + SbiDimList* pDim = NULL; BOOL bDone = FALSE; while( !bDone && !IsEof() ) @@ -570,13 +576,6 @@ void SbiParser::DefType( BOOL bPrivate ) pElem = VarDecl(&pDim,FALSE,FALSE); if( !pElem ) bDone = TRUE; // Error occured - if( pDim ) - { - // HOT FIX, to be updated - delete pDim; - Error( SbERR_NO_STRINGS_ARRAYS ); - } - } if( pElem ) { @@ -586,6 +585,43 @@ void SbiParser::DefType( BOOL bPrivate ) else { SbxProperty *pTypeElem = new SbxProperty (pElem->GetName(),pElem->GetType()); + if( pDim )
+ {
+ SbxDimArray* pArray = new SbxDimArray( pElem->GetType() );
+ if ( pDim->GetSize() )
+ {
+ // Dimension the target array
+
+ for ( short i=0; i<pDim->GetSize();++i )
+ {
+ INT32 ub = -1;
+ INT32 lb = nBase;
+ SbiExprNode* pNode = pDim->Get(i)->GetExprNode();
+ ub = pNode->GetNumber();
+ if ( !pDim->Get( i )->IsBased() ) // each dim is low/up
+ {
+ if ( ++i >= pDim->GetSize() ) // trouble
+ StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
+ pNode = pDim->Get(i)->GetExprNode();
+ lb = ub;
+ ub = pNode->GetNumber();
+ }
+ else if ( !bCompatible )
+ ub += nBase;
+ pArray->AddDim32( lb, ub );
+ }
+ pArray->setHasFixedSize( true );
+ }
+ else
+ pArray->unoAddDim( 0, -1 ); // variant array
+ USHORT nSavFlags = pTypeElem->GetFlags();
+ // need to reset the FIXED flag
+ // when calling PutObject ( because the type will not match Object )
+ pTypeElem->ResetFlag( SBX_FIXED );
+ pTypeElem->PutObject( pArray );
+ pTypeElem->SetFlags( nSavFlags );
+ }
+ delete pDim; pTypeMembers->Insert( pTypeElem, pTypeMembers->Count() ); } delete pElem; @@ -872,6 +908,11 @@ SbiProcDef* SbiParser::ProcDecl( BOOL bDecl ) void SbiParser::Declare() { + DefDeclare( FALSE );
+}
+
+void SbiParser::DefDeclare( BOOL bPrivate )
+{
Next(); if( eCurTok != SUB && eCurTok != FUNCTION ) Error( SbERR_UNEXPECTED, eCurTok ); @@ -892,12 +933,16 @@ void SbiParser::Declare() // Als Variable deklariert Error( SbERR_BAD_DECLARATION, pDef->GetName() ); delete pDef; + pDef = NULL; } else pDef->Match( p ); } else aPublics.Add( pDef ); + + if ( pDef )
+ pDef->SetPublic( !bPrivate );
} } } diff --git a/basic/source/inc/expr.hxx b/basic/source/inc/expr.hxx index 319af5cbfbc5..b66006cb639a 100644 --- a/basic/source/inc/expr.hxx +++ b/basic/source/inc/expr.hxx @@ -144,6 +144,7 @@ public: SbiExprNode* GetRealNode(); // letzter Knoten in x.y.z short GetDepth(); // Tiefe eines Baumes berechnen const String& GetString() { return aStrVal; } + short GetNumber() { return (short)nVal; }
SbiExprList* GetParameters() { return aVar.pPar; } SbiExprListVector* GetMoreParameters() { return aVar.pvMorePar; } diff --git a/basic/source/inc/parser.hxx b/basic/source/inc/parser.hxx index 5f2ef47080c3..379ae962834b 100644 --- a/basic/source/inc/parser.hxx +++ b/basic/source/inc/parser.hxx @@ -66,6 +66,7 @@ class SbiParser : public SbiTokenizer void StmntBlock( SbiToken ); // Statement-Block abarbeiten void DefType( BOOL bPrivate ); // Parse type declaration void DefEnum( BOOL bPrivate ); // Parse enum declaration + void DefDeclare( BOOL bPrivate );
void EnableCompatibility(); public: SbxArrayRef rTypeArray; // das Type-Array diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx index 2c9c22f7f44a..dbd66a61575c 100644 --- a/basic/source/runtime/methods1.cxx +++ b/basic/source/runtime/methods1.cxx @@ -662,12 +662,15 @@ RTLFUNC(Array) } // Parameter ins Array uebernehmen - for( short i = 0 ; i < nArraySize ; i++ ) + // ATTENTION: Using type USHORT for loop variable is + // mandatory to workaround a problem with the + // Solaris Intel compiler optimizer! See i104354 + for( USHORT i = 0 ; i < nArraySize ; i++ ) { SbxVariable* pVar = rPar.Get(i+1); SbxVariable* pNew = new SbxVariable( *pVar ); pNew->SetFlag( SBX_WRITE ); - short index = i; + short index = static_cast< short >(i); if ( bIncIndex ) ++index; pArray->Put( pNew, &index ); diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx index 7c3bd3b057ba..ca21908ece78 100644 --- a/basic/source/sbx/sbxvalue.cxx +++ b/basic/source/sbx/sbxvalue.cxx @@ -1470,7 +1470,7 @@ BOOL SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const bRes = TRUE; } else if( GetType() == SbxEMPTY && rOp.GetType() == SbxEMPTY ) - bRes = TRUE; + bRes = !bVBAInterop ? TRUE : ( eOp == SbxEQ ? TRUE : FALSE ); // Sonderregel 1: Ist ein Operand Null, ist das Ergebnis FALSE else if( GetType() == SbxNULL || rOp.GetType() == SbxNULL ) bRes = FALSE; diff --git a/configmgr/source/backendhelper/makefile.mk b/configmgr/source/backendhelper/makefile.mk index 44b502b451b4..f9a27c8167b0 100644 --- a/configmgr/source/backendhelper/makefile.mk +++ b/configmgr/source/backendhelper/makefile.mk @@ -39,6 +39,7 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings --- .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" .INCLUDE : $(PRJ)$/makefile.pmk DLLPRE = @@ -66,6 +67,7 @@ DEF1EXPORTFILE=exports.dxp DEF1DES=Configuration: Backend Helper # --- Targets --- +.ENDIF # L10N_framework .INCLUDE : target.mk diff --git a/configmgr/source/platformbe/makefile.mk b/configmgr/source/platformbe/makefile.mk index 19796b2442c2..9cbe53f5cf7d 100644 --- a/configmgr/source/platformbe/makefile.mk +++ b/configmgr/source/platformbe/makefile.mk @@ -42,6 +42,7 @@ SYSMGR_MAJOR=1 # --- Settings --- .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" .INCLUDE : $(PRJ)$/makefile.pmk DLLPRE = @@ -69,6 +70,7 @@ DEF1EXPORTFILE=exports.dxp DEF1DES=Configuration: System Integration Manager # --- Targets --- +.ENDIF # L10N_framework .INCLUDE : target.mk diff --git a/configmgr/util/makefile.mk b/configmgr/util/makefile.mk index 6fd7c63195a4..eaea5d343503 100644 --- a/configmgr/util/makefile.mk +++ b/configmgr/util/makefile.mk @@ -36,6 +36,7 @@ TARGET=configmgr ENABLE_EXCEPTIONS=TRUE .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" .INCLUDE : $(PRJ)$/makefile.pmk .INCLUDE : $(PRJ)$/version.mk DLLPRE = @@ -75,6 +76,7 @@ DEF1NAME= $(SHL1TARGET) DEF1EXPORTFILE= exports.dxp # --- Targets ---------------------------------- +.ENDIF # L10N_framework .INCLUDE : target.mk diff --git a/connectivity/source/commontools/RowFunctionParser.cxx b/connectivity/source/commontools/RowFunctionParser.cxx index 541df8e6b2cc..15221ed0e260 100644 --- a/connectivity/source/commontools/RowFunctionParser.cxx +++ b/connectivity/source/commontools/RowFunctionParser.cxx @@ -40,7 +40,7 @@ #include <typeinfo> #define BOOST_SPIRIT_DEBUG #endif -#include <boost/spirit/core.hpp> +#include <boost/spirit/include/classic_core.hpp> #include "RowFunctionParser.hxx" #include <rtl/ustring.hxx> #include <tools/fract.hxx> diff --git a/connectivity/source/commontools/makefile.mk b/connectivity/source/commontools/makefile.mk index ee335705e651..cb5a4ad3f7aa 100644 --- a/connectivity/source/commontools/makefile.mk +++ b/connectivity/source/commontools/makefile.mk @@ -49,6 +49,8 @@ ENVCFLAGS+=/FR$(SLO)$/ NOOPTFILES= $(SLO)$/RowFunctionParser.obj .ENDIF +ENVCFLAGS += -DBOOST_SPIRIT_USE_OLD_NAMESPACE + # --- Files -------------------------------------------------------- EXCEPTIONSFILES=\ $(SLO)$/predicateinput.obj \ diff --git a/connectivity/source/drivers/ado/APreparedStatement.cxx b/connectivity/source/drivers/ado/APreparedStatement.cxx index 839c34513c62..1eeb59befc1f 100644 --- a/connectivity/source/drivers/ado/APreparedStatement.cxx +++ b/connectivity/source/drivers/ado/APreparedStatement.cxx @@ -49,6 +49,10 @@ if(!x) \ ADOS::ThrowException(*m_pConnection->getConnection(),*this); +#ifdef max +# undef max +#endif + //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ using namespace connectivity::ado; diff --git a/desktop/prj/build.lst b/desktop/prj/build.lst index 1e289c260576..704fa0391cb7 100644 --- a/desktop/prj/build.lst +++ b/desktop/prj/build.lst @@ -1,4 +1,4 @@ -dt desktop : l10n sfx2 stoc uui BERKELEYDB:berkeleydb sysui SO:sysui_so BOOST:boost svx xmlhelp configmgr2 NULL +dt desktop : l10n sfx2 stoc uui BERKELEYDB:berkeleydb sysui SO:sysui_so BOOST:boost svx xmlhelp sal unoil officecfg configmgr2 NULL dt desktop usr1 - all dt_mkout NULL dt desktop\inc nmake - all dt_inc NULL dt desktop\prj get - all dt_prj NULL @@ -38,3 +38,7 @@ dt desktop\source\deployment\registry\executable nmake - all dt_dp_registry_exe dt desktop\scripts nmake - u dt_scripts dt_inc NULL dt desktop\util nmake - all dt_util dt_app dt_so_comp dt_spl dt_wrapper.w dt_officeloader.w dt_officeloader_unx.u dt_migr dt_rebase.w NULL dt desktop\zipintro nmake - all dt_zipintro NULL +dt desktop\registry\data\org\openoffice\Office nmake - all sn_regconfig NULL +dt desktop\source\registration\com\sun\star\servicetag\resources get - all sn_svctagres NULL +dt desktop\source\registration\com\sun\star\servicetag nmake - all sn_svctag NULL +dt desktop\source\registration\com\sun\star\registration nmake - all sn_regjob sn_svctag NULL diff --git a/desktop/prj/d.lst b/desktop/prj/d.lst index eb0d93886e8a..fe688e2c4b44 100644 --- a/desktop/prj/d.lst +++ b/desktop/prj/d.lst @@ -134,3 +134,12 @@ mkdir: %COMMON_DEST%\pck%_EXT%\broffice_nologo ..\scripts\basis-link %_DEST%\bin%_EXT%\c08\basis-link ..\scripts\so-basis-link %_DEST%\bin%_EXT%\so\basis-link ..\scripts\odf-basis-link %_DEST%\bin%_EXT%\odf4ms\basis-link + +mkdir: %_DEST%\xml%_EXT%\registry\spool +mkdir: %_DEST%\xml%_EXT%\registry\spool\org +mkdir: %_DEST%\xml%_EXT%\registry\spool\org\openoffice +mkdir: %_DEST%\xml%_EXT%\registry\spool\org\openoffice\Office +mkdir: %_DEST%\xml%_EXT%\registry\spool\org\openoffice\Office\Jobs + +..\%__SRC%\class\*.jar %_DEST%\bin%_EXT%\*.jar +..\%__SRC%\misc\registry\spool\org\openoffice\Office\Jobs\*.xcu %_DEST%\xml%_EXT%\registry\spool\org\openoffice\Office\Jobs diff --git a/desktop/registry/data/org/openoffice/Office/Jobs.xcu b/desktop/registry/data/org/openoffice/Office/Jobs.xcu new file mode 100644 index 000000000000..628e3dcdf70a --- /dev/null +++ b/desktop/registry/data/org/openoffice/Office/Jobs.xcu @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--*********************************************************************** + * + * 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: Jobs.xcu,v $ + * + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************ --> +<oor:component-data oor:name="Jobs" oor:package="org.openoffice.Office" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <node oor:name="Jobs"> + <node oor:name="ProductRegistration" oor:op="replace"> + <prop oor:name="Service"> + <value>com.sun.star.comp.framework.DoRegistrationJob</value> + </prop> + <node oor:name="Arguments"> + <prop oor:name="ProductName" oor:op="replace" oor:type="xs:string"> + <value>${SERVICETAG_PRODUCTNAME}</value> + </prop> + <prop oor:name="ProductVersion" oor:op="replace" oor:type="xs:string"> + <value>${SERVICETAG_PRODUCTVERSION}</value> + </prop> + <prop oor:name="ProductURN" oor:op="replace" oor:type="xs:string"> + <value>${SERVICETAG_URN}</value> + </prop> + <prop oor:name="ProductSource" oor:op="replace" oor:type="xs:string"> + <value>${SERVICETAG_SOURCE}</value> + </prop> + <prop oor:name="ProductParent" oor:op="replace" oor:type="xs:string"> + <value>${SERVICETAG_PARENTNAME}</value> + </prop> + <prop oor:name="Vendor" oor:op="replace" oor:type="xs:string"> + <value>Sun Microsystems, Inc.</value> + </prop> + <prop oor:name="RegistrationData" oor:op="replace" oor:type="xs:string"> + <value>$(user)/registration.xml</value> + </prop> + <prop oor:name="RegistrationURL" oor:op="replace" oor:type="xs:string"> + <value>${REGISTRATION_HOST}/register/${registry_urn}?product=${REGISTRATION_PRODUCT}&locale=${locale}&cid=${REGISTRATION_CID}</value> + </prop> + </node> + </node> + </node> + <node oor:name="Events"> + <node oor:name="onRegisterNow" oor:op="fuse"> + <node oor:name="JobList"> + <node oor:name="ProductRegistration" oor:op="replace"/> + </node> + </node> + <node oor:name="onRegisterLater" oor:op="fuse"> + <node oor:name="JobList"> + <node oor:name="ProductRegistration" oor:op="replace"/> + </node> + </node> + </node> +</oor:component-data> diff --git a/sj2/stardiv/app/makefile.mk b/desktop/registry/data/org/openoffice/Office/makefile.mk index 4e4b5f36a344..651c731fa4a9 100644 --- a/sj2/stardiv/app/makefile.mk +++ b/desktop/registry/data/org/openoffice/Office/makefile.mk @@ -8,7 +8,7 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.4 $ +# $Revision: 1.5 $ # # This file is part of OpenOffice.org. # @@ -29,41 +29,53 @@ # #************************************************************************* -PRJ=..$/.. +PRJ=..$/..$/..$/..$/.. +PRJNAME=setup_native +TARGET=data_registration +PACKAGE=org.openoffice.Office -PRJNAME=sj2 -TARGET=app +ABSXCSROOT=$(SOLARXMLDIR) +XCSROOT=.. +DTDDIR=$(ABSXCSROOT) +XSLDIR=$(ABSXCSROOT)$/processing +PROCESSOUT=$(MISC)$/$(TARGET) +PROCESSORDIR=$(SOLARBINDIR) -PACKAGE=stardiv$/app -JARFILES=sandbox.jar +.INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" -.INCLUDE : $(PRJ)$/util$/makefile.pmk +# --- Files ------------------------------------------------------- -.IF "$(JDK)" == "gcj" -all: - @echo This dir cannot be build with gcj because of sun.net.ftp.FtpClient -.ELSE -# --- Files -------------------------------------------------------- +.IF "$(BUILD_SPECIAL)"!="" -JAVAFILES= \ - AppletViewer.java \ - AppletViewerFactory.java \ - AppletProps.java \ - AppletMessageHandler.java \ - MsgAppletViewer.java +XCUFILES= \ + Jobs.xcu -JAVACLASSFILES= \ - $(CLASSDIR)$/$(PACKAGE)$/AppletViewer.class \ - $(CLASSDIR)$/$(PACKAGE)$/AppletViewerFactory.class \ - $(CLASSDIR)$/$(PACKAGE)$/AppletProps.class \ - $(CLASSDIR)$/$(PACKAGE)$/AppletMessageHandler.class \ - $(CLASSDIR)$/$(PACKAGE)$/MsgAppletViewer.class +MODULEFILES= +LOCALIZEDFILES= + +PACKAGEDIR=$(subst,.,$/ $(PACKAGE)) +SPOOLDIR=$(MISC)$/registry$/spool + +MYXCUFILES= \ + $(SPOOLDIR)$/$(PACKAGEDIR)$/Jobs$/Jobs-registration.xcu + +.ELSE # "$(BUILD_SPECIAL)"!="" + +dummy: + @echo "Nothing to build" + +.ENDIF # "$(BUILD_SPECIAL)"!="" # --- Targets ------------------------------------------------------ -.ENDIF .INCLUDE : target.mk -.INCLUDE : $(PRJ)$/util$/target.pmk +.ENDIF # L10N_framework +ALLTAR : $(MYXCUFILES) + +$(SPOOLDIR)$/$(PACKAGEDIR)$/Jobs$/Jobs-registration.xcu : $(PROCESSOUT)$/registry$/data$/$/$(PACKAGEDIR)$/Jobs.xcu + @-$(MKDIRHIER) $(@:d) + @$(COPY) $< $@ diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 9002a7b32210..d4e0a91c1d17 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1257,6 +1257,7 @@ void Desktop::Main() std::auto_ptr<SvtLanguageOptions> pLanguageOptions; std::auto_ptr<SvtPathOptions> pPathOptions; + Reference < css::document::XEventListener > xGlobalBroadcaster; try { RegisterServices( xSMgr ); @@ -1379,7 +1380,8 @@ void Desktop::Main() } // create service for loadin SFX (still needed in startup) - Reference < css::document::XEventListener > xGlobalBroadcaster( xSMgr->createInstance( + xGlobalBroadcaster = Reference < css::document::XEventListener > + ( xSMgr->createInstance( DEFINE_CONST_UNICODE( "com.sun.star.frame.GlobalEventBroadcaster" ) ), UNO_QUERY ); // initialize test-tool library (if available) @@ -1617,6 +1619,13 @@ void Desktop::Main() FatalError( MakeStartupErrorMessage(exAnyCfg.Message) ); } + if (xGlobalBroadcaster.is()) + { + css::document::EventObject aEvent; + aEvent.EventName = ::rtl::OUString::createFromAscii("OnCloseApp"); + xGlobalBroadcaster->notifyEvent(aEvent); + } + delete pResMgr; // Restore old value diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx index 0c6de1db2225..c1dd167ea39a 100644 --- a/desktop/source/app/dispatchwatcher.cxx +++ b/desktop/source/app/dispatchwatcher.cxx @@ -122,7 +122,7 @@ DispatchWatcher* DispatchWatcher::GetDispatchWatcher() DispatchWatcher::DispatchWatcher() - : m_nRequestCount(1) + : m_nRequestCount(0) { } @@ -437,12 +437,13 @@ sal_Bool DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatch } ::osl::ClearableMutexGuard aGuard( GetMutex() ); - m_nRequestCount--; + bool bEmpty = (m_nRequestCount == 0); + aGuard.clear(); // No more asynchronous requests? // The requests are removed from the request container after they called back to this // implementation via statusChanged!! - if ( !m_nRequestCount && ! bNoTerminate /*m_aRequestContainer.empty()*/ ) + if ( bEmpty && !bNoTerminate /*m_aRequestContainer.empty()*/ ) { // We have to check if we have an open task otherwise we have to shutdown the office. Reference< XFramesSupplier > xTasksSupplier( xDesktop, UNO_QUERY ); diff --git a/desktop/source/app/langselect.cxx b/desktop/source/app/langselect.cxx index 3c6d6124d178..e9a39207cb50 100644 --- a/desktop/source/app/langselect.cxx +++ b/desktop/source/app/langselect.cxx @@ -104,7 +104,7 @@ bool LanguageSelection::prepareLanguage() ::rtl::OUString sWin16SysLocale; aWin16SysLocale >>= sWin16SysLocale; if( sWin16SysLocale.getLength()) - setDefaultLocale(sWin16SysLocale); + setDefaultLanguage(sWin16SysLocale); } catch(const Exception&) { @@ -116,9 +116,8 @@ bool LanguageSelection::prepareLanguage() OUString usLocale; Reference< XPropertySet > xLocaleProp(getConfigAccess( "org.openoffice.System/L10N", sal_True), UNO_QUERY_THROW); - // "org.openoffice.Office.Linguistic/General", sal_True), UNO_QUERY_THROW); xLocaleProp->getPropertyValue(OUString::createFromAscii("Locale")) >>= usLocale; - setDefaultLocale(usLocale); + setDefaultLanguage(usLocale); } catch (Exception&) { @@ -160,88 +159,32 @@ bool LanguageSelection::prepareLanguage() // #i32939# setting of default document locale // #i32939# this should not be based on the UI language - setDefaultLocale(aLocaleString); - - // fallback: set en-US as default Western locale if no Western locale is set - OUString usWesternName = OUString::createFromAscii("DefaultLocale"); - try - { - Reference< XPropertySet > xProp(getConfigAccess( - "org.openoffice.Office.Linguistic/General/", sal_True), UNO_QUERY_THROW); - OUString usValue; - xProp->getPropertyValue(usWesternName) >>= usValue; - if (usValue.getLength() == 0) - { - // there is no western document language selected - // if the selected locale is a western locale, this - // will become the default western docuemnt language - // otherwise, fall back to en-US - OUString usDefault = OUString::createFromAscii("en-US"); - try - { - xProp->setPropertyValue(usWesternName, makeAny(usDefault)); - Reference< XChangesBatch >(xProp,UNO_QUERY_THROW)->commitChanges(); - } - catch ( PropertyVetoException ) - { - // we are not allowed to change this - } - } - } - catch ( Exception& ) - { - } + setDefaultLanguage(aLocaleString); return bSuccess; } -void LanguageSelection::setDefaultLocale(const OUString& usUILocale) +void LanguageSelection::setDefaultLanguage(const OUString& sLocale) { - // #i32939# setting of default document locale - // org.openoffice.Office.Linguistic/General/DefaultLocale - // org.openoffice.Office.Linguistic/General/DefaultLocale_CJK - // org.openoffice.Office.Linguistic/General/DefaultLocale_CTL + // #i32939# setting of default document language + // + // See #i42730# for rules for determining source of settings - // determine script type of UI locale - LanguageType ltUILocale = MsLangId::convertIsoStringToLanguage(usUILocale); - sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage(ltUILocale); + // determine script type of locale + LanguageType nLang = MsLangId::convertIsoStringToLanguage(sLocale); + sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage(nLang); - try - { - Reference< XPropertySet > xProp(getConfigAccess( - "org.openoffice.Office.Linguistic/General/", sal_True), UNO_QUERY_THROW); - OUString usName = OUString::createFromAscii("DefaultLocale"); - switch (nScriptType) - { - case SCRIPTTYPE_ASIAN: - usName = OUString::createFromAscii("DefaultLocale_CJK"); - break; - case SCRIPTTYPE_COMPLEX: - usName = OUString::createFromAscii("DefaultLocale_CTL"); - break; - } - OUString usValue; - xProp->getPropertyValue(usName) >>= usValue; - if (usValue.getLength() == 0) - { - // there is no document language set, for the script type selected - // in the UI - // covert the LanguageType we've got from the LanguageTable back to - // an iso string and store it - OUString usDefault = MsLangId::convertLanguageToIsoString(ltUILocale); - try - { - xProp->setPropertyValue(usName, makeAny(usDefault)); - Reference< XChangesBatch >(xProp, UNO_QUERY_THROW)->commitChanges(); - } - catch ( PropertyVetoException ) - { - // we are not allowed to change this - } - } - } - catch ( Exception& ) + switch (nScriptType) { + case SCRIPTTYPE_ASIAN: + MsLangId::setConfiguredAsianFallback( nLang ); + break; + case SCRIPTTYPE_COMPLEX: + MsLangId::setConfiguredComplexFallback( nLang ); + break; + default: + MsLangId::setConfiguredWesternFallback( nLang ); + break; } } diff --git a/desktop/source/app/langselect.hxx b/desktop/source/app/langselect.hxx index 0a112545f38b..d0867529ab1b 100644 --- a/desktop/source/app/langselect.hxx +++ b/desktop/source/app/langselect.hxx @@ -60,7 +60,7 @@ private: static rtl::OUString getUserLanguage(); static rtl::OUString getSystemLanguage(); static void resetUserLanguage(); - static void setDefaultLocale(const rtl::OUString&); + static void setDefaultLanguage(const rtl::OUString&); public: static com::sun::star::lang::Locale IsoStringToLocale(const rtl::OUString& str); diff --git a/desktop/source/app/makefile.mk b/desktop/source/app/makefile.mk index 36993bfdf355..238685649cf9 100644 --- a/desktop/source/app/makefile.mk +++ b/desktop/source/app/makefile.mk @@ -40,10 +40,6 @@ ENABLE_EXCEPTIONS=TRUE .INCLUDE : settings.mk -.IF "$(GUIBASE)"=="aqua" -CFLAGS+=-x objective-c++ -.ENDIF - .IF "$(ENABLE_GNOMEVFS)"=="TRUE" CFLAGS+=-DGNOME_VFS_ENABLED .ENDIF diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index 05e514305415..d7177f90dc77 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -314,6 +314,18 @@ Reference<deployment::XPackageManager> PackageManagerImpl::create( } } + //Workaround. See issue http://www.openoffice.org/issues/show_bug.cgi?id=99257 + //This prevents the copying of the common.rdbf and native rdbs. It disables the + //feature to add shared extensions in a running office. + if (!that->m_readOnly && context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") )) + { + OUString sNoRdb; + ::rtl::Bootstrap::get(OUSTR("NORDBCOPY"), sNoRdb); + if (sNoRdb.equalsIgnoreAsciiCase(OUSTR("true")) + && dp_misc::office_is_running()) + that->m_readOnly = true; + } + if (!that->m_readOnly && logFile.getLength() > 0) { const Any any_logFile(logFile); diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index 573c1c639de1..dd9e009e90cc 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -40,7 +40,7 @@ #include "comphelper/servicedecl.hxx" #include "svtools/inettype.hxx" -#include <xmlhelp/compilehelp.hxx> +#include <transex3/compilehelp.hxx> #include <com/sun/star/ucb/XSimpleFileAccess.hpp> #include <com/sun/star/util/XMacroExpander.hpp> #include <com/sun/star/uri/XUriReferenceFactory.hpp> diff --git a/desktop/source/migration/pages.cxx b/desktop/source/migration/pages.cxx index 0122caba945e..80c5849ee4d9 100644 --- a/desktop/source/migration/pages.cxx +++ b/desktop/source/migration/pages.cxx @@ -100,9 +100,10 @@ WelcomePage::WelcomePage( svt::OWizardMachine* parent, const ResId& resid, sal_B // we need to choose the welcome text that is diplayed // choices are the default text, default text+migradtion, // OEM and extended OEM - switch (checkOEM()) - { - case OEM_NONE: + // No OEM is built, remove the check +// switch (checkOEM()) +// { +// case OEM_NONE: // check for migration if (Migration::checkMigration()) { @@ -112,27 +113,11 @@ WelcomePage::WelcomePage( svt::OWizardMachine* parent, const ResId& resid, sal_B m_ftBody.SetText( aText ); } else - if (bIsEvalVersion && (! bNoEvalText)) - { - String aText(WizardResId(STR_WELCOME_EVAL)); - aText.SearchAndReplaceAll( UniString::CreateFromAscii("%EVALDAYS"), UniString::CreateFromAscii("90")); - m_ftBody.SetText( aText ); - } - else if ( ! m_bLicenseNeedsAcceptance ) { String aText(WizardResId(STR_WELCOME_WITHOUT_LICENSE)); m_ftBody.SetText( aText ); } - break; - case OEM_NORMAL: - m_ftBody.SetText(String(WizardResId(STR_WELCOME_OEM))); - break; - case OEM_EXTENDED: - m_ftBody.SetText(String(WizardResId(STR_WELCOME_OEM_EXT))); - break; - } - } diff --git a/desktop/source/migration/wizard.hrc b/desktop/source/migration/wizard.hrc index 317465736f6e..cdd045164123 100644 --- a/desktop/source/migration/wizard.hrc +++ b/desktop/source/migration/wizard.hrc @@ -88,13 +88,13 @@ #define STR_STATE_MIGRATION RID_FIRSTSTSTART_START+102 #define STR_STATE_REGISTRATION RID_FIRSTSTSTART_START+103 #define STR_WELCOME_MIGRATION RID_FIRSTSTSTART_START+104 -#define STR_WELCOME_OEM RID_FIRSTSTSTART_START+105 -#define STR_WELCOME_OEM_EXT RID_FIRSTSTSTART_START+106 +// FREE RID_FIRSTSTSTART_START+105 +// FREE RID_FIRSTSTSTART_START+106 #define STR_LICENSE_ACCEPT RID_FIRSTSTSTART_START+107 #define STR_LICENSE_DECLINE RID_FIRSTSTSTART_START+108 #define STR_FINISH RID_FIRSTSTSTART_START+109 #define STR_STATE_USER RID_FIRSTSTSTART_START+110 -#define STR_WELCOME_EVAL RID_FIRSTSTSTART_START+111 +// FREE RID_FIRSTSTSTART_START+111 #define STR_STATE_UPDATE_CHECK RID_FIRSTSTSTART_START+112 #define STR_WELCOME_WITHOUT_LICENSE RID_FIRSTSTSTART_START+113 #define STR_REGISTRATION_OOO RID_FIRSTSTSTART_START+114 diff --git a/desktop/source/migration/wizard.src b/desktop/source/migration/wizard.src index 3b49e070fa6d..634c8fe12dcb 100644 --- a/desktop/source/migration/wizard.src +++ b/desktop/source/migration/wizard.src @@ -79,24 +79,6 @@ String STR_WELCOME_MIGRATION Text [ en-US ] = "This wizard will guide you through the license agreement, the transfer of user data from %OLD_VERSION and the registration of %PRODUCTNAME.\n\nClick 'Next' to continue."; }; -String STR_WELCOME_OEM -{ - Text [ en-US ] = "This wizard will guide you through the license agreement and the registration of %PRODUCTNAME.\n\nImportant information is contained in the readme file which is located in the %PRODUCTNAME product directory. Please read this file carefully.\n\nYou can also find detailed information on the Sun Internet pages at\n\nhttp://www.sun.com/%PRODUCTNAME.\n\nClick 'Next' to continue."; -}; -String STR_WELCOME_OEM_EXT -{ - Text [ en-US ] = "This wizard will guide you through the license agreement and the registration of %PRODUCTNAME.\n\n" - "Important information is contained in the readme files which are located in the %PRODUCTNAME product directory. " - "Please read these files carefully. You can also find detailed information on the Sun website \n\n" - "http://www.sun.com/%PRODUCTNAME.\n\nSupport:\n\nGet FREE software support valid for 60 days from " - "date of purchase. To take advantage of this offer, visit the website below.\n\n" - "http://www.sun.com/star/service\n\nClick 'Next' to continue."; -}; - -String STR_WELCOME_EVAL -{ - Text [ en-US ] = "This wizard will guide you through the license agreement and the registration of %PRODUCTNAME.\n\nThis version lets you evaluate the full functionality. However, since it is an evaluation version, you will be able to start it within %EVALDAYS days after installation. To find out more about the %PRODUCTNAME product, visit www.sun.com/%PRODUCTNAME\n\nClick 'Next' to continue."; -}; String STR_WELCOME_WITHOUT_LICENSE { diff --git a/desktop/source/registration/com/sun/star/registration/Registration.java b/desktop/source/registration/com/sun/star/registration/Registration.java new file mode 100644 index 000000000000..afcb1b99660e --- /dev/null +++ b/desktop/source/registration/com/sun/star/registration/Registration.java @@ -0,0 +1,342 @@ +/************************************************************************* + * + * 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: Registration.java,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.registration; + +import com.sun.star.beans.NamedValue; +import com.sun.star.comp.loader.FactoryHelper; +import com.sun.star.frame.DispatchResultEvent; +import com.sun.star.frame.DispatchResultState; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XMultiComponentFactory; +import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.registry.*; +import com.sun.star.servicetag.*; +import com.sun.star.system.*; +import com.sun.star.task.*; +import com.sun.star.uno.*; +import com.sun.star.uri.XExternalUriReferenceTranslator; +import com.sun.star.util.XStringSubstitution; + +import java.io.*; +import java.net.URI; +import java.net.URL; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Locale; +import java.util.Set; +import java.net.HttpURLConnection; + +public class Registration { + + public static XSingleServiceFactory __getServiceFactory(String implName, + XMultiServiceFactory multiFactory, XRegistryKey regKey) { + XSingleServiceFactory xSingleServiceFactory = null; + + if (implName.equals(Registration.class.getName())) { + xSingleServiceFactory = FactoryHelper.getServiceFactory(_Registration.class, _serviceName, multiFactory, regKey); + } + + return xSingleServiceFactory; + } + + public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { + return FactoryHelper.writeRegistryServiceInfo(Registration.class.getName(), _serviceName, regKey); + } + + static final String _serviceName = "com.sun.star.comp.framework.DoRegistrationJob"; + + static public class _Registration implements XJob { + XComponentContext xComponentContext; + + XStringSubstitution xPathSubstService = null; + XExternalUriReferenceTranslator xUriTranslator = null; + + RegistrationData theRegistrationData = null; + + public _Registration(XComponentContext xComponentContext) { + this.xComponentContext = xComponentContext; + } + + private String resolvePath(String path) { + try { + if( xPathSubstService == null || xUriTranslator == null ) { + XMultiComponentFactory theServiceManager = xComponentContext.getServiceManager(); + if( xPathSubstService == null ) { + Object o = theServiceManager.createInstanceWithContext( + "com.sun.star.util.PathSubstitution", + xComponentContext ); + xPathSubstService = (XStringSubstitution) + UnoRuntime.queryInterface(XStringSubstitution.class, o); + } + + if( xUriTranslator == null ) { + Object o = theServiceManager.createInstanceWithContext( + "com.sun.star.uri.ExternalUriReferenceTranslator", + xComponentContext ); + xUriTranslator = (XExternalUriReferenceTranslator) + UnoRuntime.queryInterface(XExternalUriReferenceTranslator.class, o); + } + } + + String s = xPathSubstService.substituteVariables(path, true); + return xUriTranslator.translateToExternal(s); + } catch (java.lang.Exception e) { + return path; + } + } + + private void openBrowser(String url) { + try { + XMultiComponentFactory theServiceManager = xComponentContext.getServiceManager(); + + Object o = theServiceManager.createInstanceWithContext( + "com.sun.star.system.SystemShellExecute", + xComponentContext ); + + XSystemShellExecute xShellExecuteService = (XSystemShellExecute) + UnoRuntime.queryInterface(XSystemShellExecute.class, o); + + xShellExecuteService.execute( url, "", SystemShellExecuteFlags.DEFAULTS ); + } catch (java.lang.Exception e) { + } + } + + private ServiceTag getServiceTagFromRegistrationData(File xmlFile, String productURN) { + try { + RegistrationData storedRegData = RegistrationData.loadFromXML(new FileInputStream(xmlFile)); + Set<ServiceTag> storedServiceTags = storedRegData.getServiceTags(); + + Iterator<ServiceTag> tagIterator = storedServiceTags.iterator(); + while( tagIterator.hasNext() ) { + ServiceTag tag = tagIterator.next(); + if( tag.getProductURN().equals(productURN) ) { + theRegistrationData = storedRegData; + return tag; + } + } + + // product URN has changed, remove registration data file + xmlFile.delete(); + } catch (IOException e) { + // fall through intentionally + } catch (IllegalArgumentException e) { + // file is damaged (or a name clash appeared) + xmlFile.delete(); + } + return null; + } + + /* + * XJob + * + * NOTE: as this Job hets triggered by the the JobExecutor service from first start + * wizard and registration reminder code (because their frames do not implement + * XDispatchProvider), making this an XAsyncJob doesn't make sense as the + * JobExecutor waits for the jobFinished call on the listener passed. + */ + public Object execute(NamedValue[] args) + throws com.sun.star.lang.IllegalArgumentException, com.sun.star.uno.Exception { + + final NamedValue[] f_args = args; + + new Thread( + new Runnable () { + public void run() { + try { + executeImpl(f_args); + } catch(com.sun.star.uno.Exception e) { + } + } + } + ).start(); + + NamedValue ret[] = new NamedValue[1]; + ret[0] = new NamedValue( "Deactivate", new Boolean(false) ); + return ret; + } + + public synchronized void executeImpl(NamedValue[] args) + throws com.sun.star.lang.IllegalArgumentException, com.sun.star.uno.Exception { + + // extract the interesting part of the argument list + NamedValue[] theJobConfig = null; + NamedValue[] theEnvironment = null; + + int c = args.length; + for (int i=0; i<c; ++i) { + if (args[i].Name.equals("JobConfig")) + theJobConfig = (NamedValue[]) AnyConverter.toArray(args[i].Value); + else if (args[i].Name.equals("Environment")) + theEnvironment = (NamedValue[]) AnyConverter.toArray(args[i].Value); + } + + if (theEnvironment==null) + throw new com.sun.star.lang.IllegalArgumentException("no environment"); + + boolean saveConfig = false; + + String productName = ""; + String productVersion = ""; + String productURN = ""; + String productParent = ""; + String productParentURN = ""; + String productDefinedInstanceID = ""; + String productSource = ""; + String vendor = ""; + + String urlRegData = null; + String registrationURL = null; + + c = theJobConfig.length; + for (int i=0; i<c; ++i) { + if( theJobConfig[i].Name.equals("ProductName") ) { + productName = AnyConverter.toString(theJobConfig[i].Value); + } else if( theJobConfig[i].Name.equals("ProductVersion") ) { + productVersion = AnyConverter.toString(theJobConfig[i].Value); + } else if( theJobConfig[i].Name.equals("ProductURN") ) { + productURN = AnyConverter.toString(theJobConfig[i].Value); + } else if( theJobConfig[i].Name.equals("ProductParent") ) { + productParent = AnyConverter.toString(theJobConfig[i].Value); + } else if( theJobConfig[i].Name.equals("ProductParentURN") ) { + productParentURN = AnyConverter.toString(theJobConfig[i].Value); + } else if( theJobConfig[i].Name.equals("ProductSource") ) { + productSource = AnyConverter.toString(theJobConfig[i].Value); + } else if( theJobConfig[i].Name.equals("Vendor") ) { + vendor = AnyConverter.toString(theJobConfig[i].Value); + } else if( theJobConfig[i].Name.equals("RegistrationData") ) { + urlRegData = resolvePath(AnyConverter.toString(theJobConfig[i].Value)); + } else if( theJobConfig[i].Name.equals("RegistrationURL") ) { + registrationURL = AnyConverter.toString(theJobConfig[i].Value); + } else { + System.err.println( theJobConfig[i].Name + " = " + AnyConverter.toString(theJobConfig[i].Value) ); + } + } + + if (registrationURL==null) + throw new com.sun.star.lang.IllegalArgumentException("no registration url"); + + boolean local_only = false; + + c = theEnvironment.length; + for (int i=0; i<c; ++i) { + if( theEnvironment[i].Name.equals("EventName") ) { + if( ! AnyConverter.toString(theEnvironment[i].Value).equals("onRegisterNow") ) { + local_only = true; + } + } + } + + try { + + /* ensure only one thread accesses/writes registration.xml at a time + * regardless how many instances of this Job exist. + */ + synchronized( _serviceName ) { + + File xmlRegData = new File( new URI( urlRegData ) ); + + ServiceTag tag = getServiceTagFromRegistrationData(xmlRegData, productURN); + if( tag == null ) { + tag = ServiceTag.newInstance( + ServiceTag.generateInstanceURN(), + productName, + productVersion, + productURN, + productParent, + productParentURN, + productDefinedInstanceID, + vendor, + System.getProperty("os.arch"), + Installer.getZoneName(), + productSource); + + theRegistrationData = new RegistrationData(); + theRegistrationData.addServiceTag(tag); + theRegistrationData.storeToXML( new FileOutputStream( xmlRegData ) ); + } + + // Store the service tag in local registry, which might have been installed later + if( Registry.isSupported() ) { + // ignore communication failures with local service tag client + try { + if( Registry.getSystemRegistry().getServiceTag(tag.getInstanceURN()) == null ) { + Registry.getSystemRegistry().addServiceTag(tag); + } + } catch( java.io.IOException e) { + e.printStackTrace(); + } catch (java.lang.RuntimeException e) { + e.printStackTrace(); + } + } + } + + if( ! local_only ) { + registrationURL = registrationURL.replaceAll("\\$\\{registry_urn\\}", theRegistrationData.getRegistrationURN()); + registrationURL = registrationURL.replaceAll("\\$\\{locale\\}", Locale.getDefault().getLanguage()); + + HttpURLConnection con = (HttpURLConnection) new URL(registrationURL).openConnection(); + con.setDoInput(true); + con.setDoOutput(true); + con.setUseCaches(false); + con.setAllowUserInteraction(false); + con.setRequestMethod("POST"); + + con.setRequestProperty("Content-Type", "text/xml;charset=\"utf-8\""); + try { + con.connect(); + + OutputStream out = con.getOutputStream(); + theRegistrationData.storeToXML(out); + out.flush(); + out.close(); + + int returnCode = con.getResponseCode(); +// if (returnCode == HttpURLConnection.HTTP_OK); + } catch(java.lang.Exception e) { + // IOException and UnknownHostException + } + openBrowser(registrationURL); + } + } catch (java.net.MalformedURLException e) { + e.printStackTrace(); + throw new com.sun.star.lang.IllegalArgumentException( e.toString() ); + } catch (java.net.URISyntaxException e) { + e.printStackTrace(); + throw new com.sun.star.lang.IllegalArgumentException( e.toString() ); + } catch (java.io.IOException e) { + e.printStackTrace(); + throw new com.sun.star.uno.RuntimeException( e.toString() ); + } catch (java.lang.RuntimeException e) { + e.printStackTrace(); + throw new com.sun.star.uno.RuntimeException( e.toString() ); + } + } + } +} diff --git a/sj2/source/jscpp/makefile.mk b/desktop/source/registration/com/sun/star/registration/makefile.mk index 841b775c1176..f20eaf71adce 100644 --- a/sj2/source/jscpp/makefile.mk +++ b/desktop/source/registration/com/sun/star/registration/makefile.mk @@ -8,7 +8,7 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.9 $ +# $Revision: 1.2 $ # # This file is part of OpenOffice.org. # @@ -29,29 +29,31 @@ # #************************************************************************* -PRJ=..$/.. +PRJNAME = setup_native +PRJ = ..$/..$/..$/..$/..$/.. +TARGET = productregistration +PACKAGE = com$/sun$/star$/registration -PRJNAME=sj2 -TARGET=jscpp # --- Settings ----------------------------------------------------- -.INCLUDE : $(PRJ)$/util$/makefile.pmk +.INCLUDE : settings.mk -# --- Files -------------------------------------------------------- +.IF "$(ENABLE_SVCTAGS)" == "YES" -.IF "$(GUIBASE)"=="aqua" -OBJCXXFLAGS=-x objective-c++ -fobjc-exceptions -CFLAGSCXX+=$(OBJCXXFLAGS) -.ENDIF # "$(GUIBASE)"=="aqua" +JARFILES = jurt.jar unoil.jar ridl.jar +JAVAFILES = \ + Registration.java -SLOFILES= \ - $(SLO)$/sjapplet.obj \ - $(SLO)$/sjapplet_impl.obj +JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) +JARTARGET = $(TARGET).jar +JARCOMPRESS = TRUE +JARCLASSDIRS = $(PACKAGE) com$/sun$/star$/servicetag +CUSTOMMANIFESTFILE = manifest +.ENDIF # "$(ENABLE_SVCTAGS)" == "YES" # --- Targets ------------------------------------------------------ -.INCLUDE : target.mk -.INCLUDE : $(PRJ)$/util$/target.pmk +.INCLUDE : target.mk diff --git a/desktop/source/registration/com/sun/star/registration/manifest b/desktop/source/registration/com/sun/star/registration/manifest new file mode 100644 index 000000000000..952aaa804e96 --- /dev/null +++ b/desktop/source/registration/com/sun/star/registration/manifest @@ -0,0 +1,2 @@ +RegistrationClassName: com.sun.star.registration.Registration +UNO-Type-Path: diff --git a/desktop/source/registration/com/sun/star/servicetag/BrowserSupport.java b/desktop/source/registration/com/sun/star/servicetag/BrowserSupport.java new file mode 100644 index 000000000000..c97d5f2cd4f0 --- /dev/null +++ b/desktop/source/registration/com/sun/star/servicetag/BrowserSupport.java @@ -0,0 +1,205 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: BrowserSupport.java,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.servicetag; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; +import java.io.IOException; +import java.net.URI; + +/** + * BrowserSupport class. + * + * The implementation of the com.sun.servicetag API needs to be + * compiled with JDK 5 as well since the consumer of this API + * may require to support JDK 5 (e.g. NetBeans). + * + * The Desktop.browse() method can be backported in this class + * if needed. The current implementation only supports JDK 6. + */ +class BrowserSupport { + private static boolean isBrowseSupported = false; + private static Method browseMethod = null; + private static Object desktop = null; + private static volatile Boolean result = false; + + + private static void initX() { + if (desktop != null) { + return; + } + boolean supported = false; + Method browseM = null; + Object desktopObj = null; + try { + // Determine if java.awt.Desktop is supported + Class desktopCls = Class.forName("java.awt.Desktop", true, null); + Method getDesktopM = desktopCls.getMethod("getDesktop"); + browseM = desktopCls.getMethod("browse", URI.class); + + Class actionCls = Class.forName("java.awt.Desktop$Action", true, null); + final Method isDesktopSupportedMethod = desktopCls.getMethod("isDesktopSupported"); + Method isSupportedMethod = desktopCls.getMethod("isSupported", actionCls); + Field browseField = actionCls.getField("BROWSE"); + // isDesktopSupported calls getDefaultToolkit which can block + // infinitely, see 6636099 for details, to workaround we call + // in a thread and time it out, noting that the issue is specific + // to X11, it does not hurt for Windows. + Thread xthread = new Thread() { + public void run() { + try { + // support only if Desktop.isDesktopSupported() and + // Desktop.isSupported(Desktop.Action.BROWSE) return true. + result = (Boolean) isDesktopSupportedMethod.invoke(null); + } catch (IllegalAccessException e) { + // should never reach here + InternalError x = + new InternalError("Desktop.getDesktop() method not found"); + x.initCause(e); + } catch (InvocationTargetException e) { + // browser not supported + if (Util.isVerbose()) { + e.printStackTrace(); + } + } + } + }; + // set it to daemon, so that the vm will exit. + xthread.setDaemon(true); + xthread.start(); + try { + xthread.join(5 * 1000); + } catch (InterruptedException ie) { + // ignore the exception + } + if (result.booleanValue()) { + desktopObj = getDesktopM.invoke(null); + result = (Boolean) isSupportedMethod.invoke(desktopObj, browseField.get(null)); + supported = result.booleanValue(); + } + } catch (ClassNotFoundException e) { + // browser not supported + if (Util.isVerbose()) { + e.printStackTrace(); + } + } catch (NoSuchMethodException e) { + // browser not supported + if (Util.isVerbose()) { + e.printStackTrace(); + } + } catch (NoSuchFieldException e) { + // browser not supported + if (Util.isVerbose()) { + e.printStackTrace(); + } + } catch (IllegalAccessException e) { + // should never reach here + InternalError x = + new InternalError("Desktop.getDesktop() method not found"); + x.initCause(e); + throw x; + } catch (InvocationTargetException e) { + // browser not supported + if (Util.isVerbose()) { + e.printStackTrace(); + } + } + isBrowseSupported = supported; + browseMethod = browseM; + desktop = desktopObj; + } + + static boolean isSupported() { + initX(); + return isBrowseSupported; + } + + /** + * Launches the default browser to display a {@code URI}. + * If the default browser is not able to handle the specified + * {@code URI}, the application registered for handling + * {@code URIs} of the specified type is invoked. The application + * is determined from the protocol and path of the {@code URI}, as + * defined by the {@code URI} class. + * <p> + * This method calls the Desktop.getDesktop().browse() method. + * <p> + * @param uri the URI to be displayed in the user default browser + * + * @throws NullPointerException if {@code uri} is {@code null} + * @throws UnsupportedOperationException if the current platform + * does not support the {@link Desktop.Action#BROWSE} action + * @throws IOException if the user default browser is not found, + * or it fails to be launched, or the default handler application + * failed to be launched + * @throws IllegalArgumentException if the necessary permissions + * are not available and the URI can not be converted to a {@code URL} + */ + static void browse(URI uri) throws IOException { + if (uri == null) { + throw new NullPointerException("null uri"); + } + if (!isSupported()) { + throw new UnsupportedOperationException("Browse operation is not supported"); + } + + // Call Desktop.browse() method + try { + if (Util.isVerbose()) { + System.out.println("desktop: " + desktop + ":browsing..." + uri); + } + browseMethod.invoke(desktop, uri); + } catch (IllegalAccessException e) { + // should never reach here + InternalError x = + new InternalError("Desktop.getDesktop() method not found"); + x.initCause(e); + throw x; + } catch (InvocationTargetException e) { + Throwable x = e.getCause(); + if (x != null) { + if (x instanceof UnsupportedOperationException) { + throw (UnsupportedOperationException) x; + } else if (x instanceof IllegalArgumentException) { + throw (IllegalArgumentException) x; + } else if (x instanceof IOException) { + throw (IOException) x; + } else if (x instanceof SecurityException) { + throw (SecurityException) x; + } else { + // ignore + } + } + } + } +} diff --git a/desktop/source/registration/com/sun/star/servicetag/Installer.java b/desktop/source/registration/com/sun/star/servicetag/Installer.java new file mode 100644 index 000000000000..02825dfec69d --- /dev/null +++ b/desktop/source/registration/com/sun/star/servicetag/Installer.java @@ -0,0 +1,947 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: Installer.java,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.servicetag; + +import java.io.*; +import java.util.HashSet; +import java.util.Locale; +import java.util.Properties; +import java.util.Set; +import java.util.List; +import java.util.ArrayList; +import static com.sun.star.servicetag.Util.*; + +/** + * Service Tag Installer for Java SE. + */ +public class Installer { + // System properties for testing + private static String SVCTAG_DIR_PATH = + "servicetag.dir.path"; + private static String SVCTAG_ENABLE_REGISTRATION = + "servicetag.registration.enabled"; + private final static String SUN_VENDOR = "Sun Microsystems"; + private final static String REGISTRATION_XML = "registration.xml"; + private final static String SERVICE_TAG_FILE = "servicetag"; + private final static String REGISTRATION_HTML_NAME = "register"; + + private final static Locale[] knownSupportedLocales = + new Locale[] { Locale.ENGLISH, + Locale.JAPANESE, + Locale.SIMPLIFIED_CHINESE}; + + private final static String javaHome = System.getProperty("java.home"); + private static File svcTagDir; + private static File serviceTagFile; + private static File regXmlFile; + private static RegistrationData registration; + private static boolean supportRegistration; + private static String registerHtmlParent; + private static Set<Locale> supportedLocales = new HashSet<Locale>(); + private static Properties swordfishProps = null; + private static String[] jreArchs = null; + static { + String dir = System.getProperty(SVCTAG_DIR_PATH); + if (dir == null) { + svcTagDir = new File(getJrePath(), "lib" + File.separator + SERVICE_TAG_FILE); + } else { + svcTagDir = new File(dir); + } + serviceTagFile = new File(svcTagDir, SERVICE_TAG_FILE); + regXmlFile = new File(svcTagDir, REGISTRATION_XML); + if (System.getProperty(SVCTAG_ENABLE_REGISTRATION) == null) { + supportRegistration = isJdk(); + } else { + supportRegistration = true; + } + } + + private Installer() { + } + + // Implementation of ServiceTag.getJavaServiceTag(String) method + static ServiceTag getJavaServiceTag(String source) throws IOException { + if (!System.getProperty("java.vendor").startsWith(SUN_VENDOR)) { + // Products bundling this implementation may run on + // Mac OS which is not a Sun JDK + return null; + } + boolean cleanup = false; + try { + // Check if we have the swordfish entries for this JRE version + if (loadSwordfishEntries() == null) { + return null; + } + + ServiceTag st = getJavaServiceTag(); + // Check if the service tag created by this bundle owner + if (st != null && st.getSource().equals(source)) { + // Install the system service tag if supported + // stclient may be installed after the service tag creation + if (Registry.isSupported()) { + installSystemServiceTag(); + } + return st; + } + + // in case any exception thrown during the cleanup + cleanup = true; + + // re-create a new one for this bundle owner + // first delete the registration data + deleteRegistrationData(); + cleanup = false; + + // create service tag and generate new register.html pages + return createServiceTag(source); + } finally { + if (cleanup) { + if (regXmlFile.exists()) { + regXmlFile.delete(); + } + if (serviceTagFile.exists()) { + serviceTagFile.delete(); + } + } + } + } + + /** + * Returns the Java SE registration data located in + * the <JRE>/lib/servicetag/registration.xml by default. + * + * @throws IllegalArgumentException if the registration data + * is of invalid format. + */ + private static synchronized RegistrationData getRegistrationData() + throws IOException { + if (registration != null) { + return registration; + } + if (regXmlFile.exists()) { + BufferedInputStream in = null; + try { + in = new BufferedInputStream(new FileInputStream(regXmlFile)); + registration = RegistrationData.loadFromXML(in); + } catch (IllegalArgumentException ex) { + System.err.println("Error: Bad registration data \"" + + regXmlFile + "\":" + ex.getMessage()); + throw ex; + } finally { + if (in != null) { + in.close(); + } + } + } else { + registration = new RegistrationData(); + } + return registration; + } + + /** + * Write the registration data to the registration.xml file. + * + * The offline registration page has to be regenerated with + * the new registration data. + * + * @throws java.io.IOException + */ + private static synchronized void writeRegistrationXml() + throws IOException { + if (!svcTagDir.exists()) { + // This check is for NetBeans or other products that + // bundles this com.sun.servicetag implementation for + // pre-6u5 release. + if (!svcTagDir.mkdir()) { + throw new IOException("Failed to create directory: " + svcTagDir); + } + } + + // regenerate the new offline registration page + deleteRegistrationHtmlPage(); + getRegistrationHtmlPage(); + + BufferedOutputStream out = null; + try { + out = new BufferedOutputStream(new FileOutputStream(regXmlFile)); + getRegistrationData().storeToXML(out); + } catch (IllegalArgumentException ex) { + System.err.println("Error: Bad registration data \"" + + regXmlFile + "\":" + ex.getMessage()); + throw ex; + } finally { + if (out != null) { + out.close(); + } + } + } + + /** + * Returns the instance urn(s) stored in the servicetag file + * or empty set if file not exists. + */ + private static Set<String> getInstalledURNs() throws IOException { + Set<String> urnSet = new HashSet<String>(); + if (serviceTagFile.exists()) { + BufferedReader in = null; + try { + in = new BufferedReader(new FileReader(serviceTagFile)); + String urn; + while ((urn = in.readLine()) != null) { + urn = urn.trim(); + if (urn.length() > 0) { + urnSet.add(urn); + } + } + } finally { + if (in != null) { + in.close(); + } + } + } + return urnSet; + } + + /** + * Return the Java SE service tag(s) if it exists. + * Typically only one Java SE service tag but it could have two for + * Solaris 32-bit and 64-bit on the same install directory. + * + * @return the service tag(s) for Java SE + */ + private static ServiceTag[] getJavaServiceTagArray() throws IOException { + RegistrationData regData = getRegistrationData(); + Set<ServiceTag> svcTags = regData.getServiceTags(); + Set<ServiceTag> result = new HashSet<ServiceTag>(); + + Properties props = loadSwordfishEntries(); + String jdkUrn = props.getProperty("servicetag.jdk.urn"); + String jreUrn = props.getProperty("servicetag.jre.urn"); + for (ServiceTag st : svcTags) { + if (st.getProductURN().equals(jdkUrn) || + st.getProductURN().equals(jreUrn)) { + result.add(st); + } + } + return result.toArray(new ServiceTag[0]); + } + + /** + * Returns the Java SE service tag for this running platform; + * or null if not exist. + * This method will return the 64-bit service tag if the JDK + * supports both 32-bit and 64-bit if already created. + */ + private static ServiceTag getJavaServiceTag() throws IOException { + String definedId = getProductDefinedId(); + for (ServiceTag st : getJavaServiceTagArray()) { + if (st.getProductDefinedInstanceID().equals(definedId)) { + return st; + } + } + return null; + } + + /** + * Create a service tag for Java SE and install in the system + * service tag registry if supported. + * + * A registration data <JRE>/lib/servicetag/registration.xml + * will be created to storeToXML the XML entry for Java SE service tag. + * If the system supports service tags, this method will install + * the Java SE service tag in the system service tag registry and + * its <tt>instance_urn</tt> will be stored to <JRE>/lib/servicetag/servicetag. + * + * If <JRE>/lib/servicetag/registration.xml exists but is not installed + * in the system service tag registry (i.e. servicetag doesn't exist), + * this method will install it as described above. + * + * If the system supports service tag, stclient will be used + * to create the Java SE service tag. + * + * A Solaris 32-bit and 64-bit JDK will be installed in the same + * directory but the registration.xml will have 2 service tags. + * The servicetag file will also contain 2 instance_urns for that case. + */ + private static ServiceTag createServiceTag(String svcTagSource) + throws IOException { + // determine if a new service tag is needed to be created + ServiceTag newSvcTag = null; + if (getJavaServiceTag() == null) { + newSvcTag = newServiceTag(svcTagSource); + } + + // Add the new service tag in the registration data + if (newSvcTag != null) { + RegistrationData regData = getRegistrationData(); + + // Add the service tag to the registration data in JDK/JRE + newSvcTag = regData.addServiceTag(newSvcTag); + + // add if there is a service tag for the OS + ServiceTag osTag = SolarisServiceTag.getServiceTag(); + if (osTag != null && regData.getServiceTag(osTag.getInstanceURN()) == null) { + regData.addServiceTag(osTag); + } + // write to the registration.xml + writeRegistrationXml(); + } + + // Install the system service tag if supported + if (Registry.isSupported()) { + installSystemServiceTag(); + } + return newSvcTag; + } + + private static void installSystemServiceTag() throws IOException { + // only install the service tag in the registry if + // it has permission to write the servicetag file. + if ((!serviceTagFile.exists() && !svcTagDir.canWrite()) || + (serviceTagFile.exists() && !serviceTagFile.canWrite())) { + return; + } + + Set<String> urns = getInstalledURNs(); + ServiceTag[] javaSvcTags = getJavaServiceTagArray(); + if (urns.size() < javaSvcTags.length) { + for (ServiceTag st : javaSvcTags) { + // Add the service tag in the system service tag registry + // if not installed + String instanceURN = st.getInstanceURN(); + if (!urns.contains(instanceURN)) { + Registry.getSystemRegistry().addServiceTag(st); + } + } + } + writeInstalledUrns(); + } + + private static ServiceTag newServiceTag(String svcTagSource) throws IOException { + // Load the swoRDFish information for the service tag creation + Properties props = loadSwordfishEntries(); + + // Determine the product URN and name + String productURN; + String productName; + + if (isJdk()) { + // <HOME>/jre exists which implies it's a JDK + productURN = props.getProperty("servicetag.jdk.urn"); + productName = props.getProperty("servicetag.jdk.name"); + } else { + // Otherwise, it's a JRE + productURN = props.getProperty("servicetag.jre.urn"); + productName = props.getProperty("servicetag.jre.name"); + } + + return ServiceTag.newInstance(ServiceTag.generateInstanceURN(), + productName, + System.getProperty("java.version"), + productURN, + props.getProperty("servicetag.parent.name"), + props.getProperty("servicetag.parent.urn"), + getProductDefinedId(), + SUN_VENDOR, + System.getProperty("os.arch"), + getZoneName(), + svcTagSource); + } + + /** + * Delete the registration data, the offline registration pages and + * the service tags in the system service tag registry if installed. + * + * The registration.xml and servicetag file will be removed. + */ + private static synchronized void deleteRegistrationData() + throws IOException { + try { + // delete the offline registration page + deleteRegistrationHtmlPage(); + + // Remove the service tag from the system ST registry if exists + Set<String> urns = getInstalledURNs(); + if (urns.size() > 0 && Registry.isSupported()) { + for (String u : urns) { + Registry.getSystemRegistry().removeServiceTag(u); + } + } + registration = null; + } finally { + // Delete the registration.xml and servicetag files if exists + if (regXmlFile.exists()) { + if (!regXmlFile.delete()) { + throw new IOException("Failed to delete " + regXmlFile); + } + } + if (serviceTagFile.exists()) { + if (!serviceTagFile.delete()) { + throw new IOException("Failed to delete " + serviceTagFile); + } + } + } + } + + /** + * Updates the registration data to contain one single service tag + * for the running Java runtime. + */ + private static synchronized void updateRegistrationData(String svcTagSource) + throws IOException { + RegistrationData regData = getRegistrationData(); + ServiceTag curSvcTag = newServiceTag(svcTagSource); + + ServiceTag[] javaSvcTags = getJavaServiceTagArray(); + Set<String> urns = getInstalledURNs(); + for (ServiceTag st : javaSvcTags) { + if (!st.getProductDefinedInstanceID().equals(curSvcTag.getProductDefinedInstanceID())) { + String instanceURN = st.getInstanceURN(); + regData.removeServiceTag(instanceURN); + + // remove it from the system service tag registry if exists + if (urns.contains(instanceURN) && Registry.isSupported()) { + Registry.getSystemRegistry().removeServiceTag(instanceURN); + } + } + } + writeRegistrationXml(); + writeInstalledUrns(); + } + + private static void writeInstalledUrns() throws IOException { + // if the Registry is not supported, + // remove the servicetag file + if (!Registry.isSupported() && serviceTagFile.exists()) { + serviceTagFile.delete(); + return; + } + + PrintWriter out = null; + try { + out = new PrintWriter(serviceTagFile); + + ServiceTag[] javaSvcTags = getJavaServiceTagArray(); + for (ServiceTag st : javaSvcTags) { + // Write the instance_run to the servicetag file + String instanceURN = st.getInstanceURN(); + out.println(instanceURN); + } + } finally { + if (out != null) { + out.close(); + } + } + } + + /** + * Load the values associated with the swoRDFish metadata entries + * for Java SE. The swoRDFish metadata entries are different for + * different release. + * + * @param version Version of Java SE + */ + private static synchronized Properties loadSwordfishEntries() throws IOException { + if (swordfishProps != null) { + return swordfishProps; + } + + // The version string for Java SE 6 is 1.6.0 + // We just need the minor number in the version string + int version = Util.getJdkVersion(); + + String filename = "/com/sun/servicetag/resources/javase_" + + version + "_swordfish.properties"; + InputStream in = Installer.class.getClass().getResourceAsStream(filename); + if (in == null) { + return null; + } + swordfishProps = new Properties(); + try { + swordfishProps.load(in); + } finally { + in.close(); + } + return swordfishProps; + } + + /** + * Returns the product defined instance ID for Java SE. + * It is a list of comma-separated name/value pairs: + * "id=<full-version> <arch> [<arch>]*" + * "dir=<java.home system property value>" + * + * where <full-version> is the full version string of the JRE, + * <arch> is the architecture that the runtime supports + * (i.e. "sparc", "sparcv9", "i386", "amd64" (ISA list)) + * + * For Solaris, it can be dual mode that can support both + * 32-bit and 64-bit. the "id" will be set to + * "1.6.0_03-b02 sparc sparcv9" + * + * The "dir" property is included in the service tag to enable + * the Service Tag software to determine if a service tag for + * Java SE is invalid and perform appropriate service tag + * cleanup if necessary. See RFE# 6574781 Service Tags Enhancement. + * + */ + private static String getProductDefinedId() { + StringBuilder definedId = new StringBuilder(); + definedId.append("id="); + definedId.append(System.getProperty("java.runtime.version")); + + String[] archs = getJreArchs(); + for (String name : archs) { + definedId.append(" " + name); + } + + String location = ",dir=" + javaHome; + if ((definedId.length() + location.length()) < 256) { + definedId.append(",dir="); + definedId.append(javaHome); + } else { + // if it exceeds the limit, we will not include the location + if (isVerbose()) { + System.err.println("Warning: Product defined instance ID exceeds the field limit:"); + } + } + + return definedId.toString(); + } + + /** + * Returns the architectures that the runtime supports + * (i.e. "sparc", "sparcv9", "i386", "amd64" (ISA list)) + * The directory name where libjava.so is located. + * + * On Windows, returns the "os.arch" system property value. + */ + private synchronized static String[] getJreArchs() { + if (jreArchs != null) { + return jreArchs; + } + + Set<String> archs = new HashSet<String>(); + + String os = System.getProperty("os.name"); + if (os.equals("SunOS") || os.equals("Linux")) { + // Traverse the directories under <JRE>/lib. + // If <JRE>/lib/<arch>/libjava.so exists, add <arch> + // to the product defined ID + File dir = new File(getJrePath() + File.separator + "lib"); + if (dir.isDirectory()) { + String[] children = dir.list(); + for (String name : children) { + File f = new File(dir, name + File.separator + "libjava.so"); + if (f.exists()) { + archs.add(name); + } + } + } + } else { + // Windows - append the os.arch + archs.add(System.getProperty("os.arch")); + } + jreArchs = archs.toArray(new String[0]); + return jreArchs; + } + + /** + * Return the zonename if zone is supported; otherwise, return + * "global". + */ + public static String getZoneName() throws IOException { + String zonename = "global"; + + String command = "/usr/bin/zonename"; + File f = new File(command); + // com.sun.servicetag package has to be compiled with JDK 5 as well + // JDK 5 doesn't support the File.canExecute() method. + // Risk not checking isExecute() for the zonename command is very low. + if (f.exists()) { + ProcessBuilder pb = new ProcessBuilder(command); + Process p = pb.start(); + String output = commandOutput(p); + if (p.exitValue() == 0) { + zonename = output.trim(); + } + + } + return zonename; + } + + private synchronized static String getRegisterHtmlParent() throws IOException { + if (registerHtmlParent == null) { + File htmlDir; // register.html is put under the JDK directory + if (getJrePath().endsWith(File.separator + "jre")) { + htmlDir = new File(getJrePath(), ".."); + } else { + // j2se non-image build + htmlDir = new File(getJrePath()); + } + + // initialize the supported locales + initSupportedLocales(htmlDir); + + // Determine the location of the offline registration page + String path = System.getProperty(SVCTAG_DIR_PATH); + if (path == null) { + // Default is <JDK>/register.html + registerHtmlParent = htmlDir.getCanonicalPath(); + } else { + File f = new File(path); + registerHtmlParent = f.getCanonicalPath(); + if (!f.isDirectory()) { + throw new InternalError("Path " + path + " set in \"" + + SVCTAG_DIR_PATH + "\" property is not a directory"); + } + } + } + return registerHtmlParent; + } + + /** + * Returns the File object of the offline registration page localized + * for the default locale in the JDK directory. + */ + static synchronized File getRegistrationHtmlPage() throws IOException { + if (!supportRegistration) { + // No register.html page generated if JRE + return null; + } + + String parent = getRegisterHtmlParent(); + + // check if the offline registration page is already generated + File f = new File(parent, REGISTRATION_HTML_NAME + ".html"); + if (!f.exists()) { + // Generate the localized version of the offline registration Page + generateRegisterHtml(parent); + } + + String name = REGISTRATION_HTML_NAME; + List<Locale> candidateLocales = getCandidateLocales(Locale.getDefault()); + for (Locale l : candidateLocales) { + if (supportedLocales.contains(l)) { + name = REGISTRATION_HTML_NAME + "_" + l.toString(); + break; + } + } + File htmlFile = new File(parent, name + ".html"); + if (isVerbose()) { + System.out.print("Offline registration page: " + htmlFile); + System.out.println((htmlFile.exists() ? + "" : " not exist. Use register.html")); + } + if (htmlFile.exists()) { + return htmlFile; + } else { + return new File(parent, + REGISTRATION_HTML_NAME + ".html"); + } + } + + private static List<Locale> getCandidateLocales(Locale locale) { + String language = locale.getLanguage(); + String country = locale.getCountry(); + String variant = locale.getVariant(); + + List<Locale> locales = new ArrayList<Locale>(3); + if (variant.length() > 0) { + locales.add(locale); + } + if (country.length() > 0) { + locales.add((locales.size() == 0) ? + locale : new Locale(language, country, "")); + } + if (language.length() > 0) { + locales.add((locales.size() == 0) ? + locale : new Locale(language, "", "")); + } + return locales; + } + + // Remove the offline registration pages + private static void deleteRegistrationHtmlPage() throws IOException { + String parent = getRegisterHtmlParent(); + if (parent == null) { + return; + } + + for (Locale locale : supportedLocales) { + String name = REGISTRATION_HTML_NAME; + if (!locale.equals(Locale.ENGLISH)) { + name += "_" + locale.toString(); + } + File f = new File(parent, name + ".html"); + if (f.exists()) { + if (!f.delete()) { + throw new IOException("Failed to delete " + f); + } + } + } + } + + private static void initSupportedLocales(File jdkDir) { + if (supportedLocales.isEmpty()) { + // initialize with the known supported locales + for (Locale l : knownSupportedLocales) { + supportedLocales.add(l); + } + } + + // Determine unknown supported locales if any + // by finding the localized version of README.html + // This prepares if a new locale in JDK is supported in + // e.g. in the OpenSource world + FilenameFilter ff = new FilenameFilter() { + public boolean accept(File dir, String name) { + String fname = name.toLowerCase(); + if (fname.startsWith("readme") && fname.endsWith(".html")) { + return true; + } + return false; + } + }; + + String[] readmes = jdkDir.list(ff); + for (String name : readmes) { + String basename = name.substring(0, name.length() - ".html".length()); + String[] ss = basename.split("_"); + switch (ss.length) { + case 1: + // English version + break; + case 2: + supportedLocales.add(new Locale(ss[1])); + break; + case 3: + supportedLocales.add(new Locale(ss[1], ss[2])); + break; + default: + // ignore + break; + } + } + if (isVerbose()) { + System.out.println("Supported locales: "); + for (Locale l : supportedLocales) { + System.out.println(l); + } + } + } + + private static final String JDK_HEADER_PNG_KEY = "@@JDK_HEADER_PNG@@"; + private static final String JDK_VERSION_KEY = "@@JDK_VERSION@@"; + private static final String REGISTRATION_URL_KEY = "@@REGISTRATION_URL@@"; + private static final String REGISTRATION_PAYLOAD_KEY = "@@REGISTRATION_PAYLOAD@@"; + + @SuppressWarnings("unchecked") + private static void generateRegisterHtml(String parent) throws IOException { + int version = Util.getJdkVersion(); + int update = Util.getUpdateVersion(); + String jdkVersion = "Version " + version; + if (update > 0) { + // product name is not translated + jdkVersion += " Update " + update; + } + RegistrationData regData = getRegistrationData(); + String registerURL = SunConnection.getRegistrationURL( + regData.getRegistrationURN()).toString(); + // Make sure it uses the canonical path before getting the URI. + File img = new File(svcTagDir.getCanonicalPath(), "jdk_header.png"); + String headerImageSrc = img.toURI().toString(); + + // Format the registration data in one single line + StringBuilder payload = new StringBuilder(); + String xml = regData.toString().replaceAll("\"", "%22"); + BufferedReader reader = new BufferedReader(new StringReader(xml)); + try { + String line = null; + while ((line = reader.readLine()) != null) { + payload.append(line.trim()); + } + } finally { + reader.close(); + } + + String resourceFilename = "/com/sun/star/servicetag/resources/register"; + for (Locale locale : supportedLocales) { + String name = REGISTRATION_HTML_NAME; + String resource = resourceFilename; + if (!locale.equals(Locale.ENGLISH)) { + name += "_" + locale.toString(); + resource += "_" + locale.toString(); + } + File f = new File(parent, name + ".html"); + InputStream in = null; + BufferedReader br = null; + PrintWriter pw = null; + try { + in = Installer.class.getClass().getResourceAsStream(resource + ".html"); + if (in == null) { + // if the resource file is missing + if (isVerbose()) { + System.out.println("Missing resouce file: " + resource + ".html"); + } + continue; + } + if (isVerbose()) { + System.out.println("Generating " + f + " from " + resource + ".html"); + } + + br = new BufferedReader(new InputStreamReader(in, "UTF-8")); + pw = new PrintWriter(f, "UTF-8"); + String line = null; + while ((line = br.readLine()) != null) { + String output = line; + if (line.contains(JDK_VERSION_KEY)) { + output = line.replace(JDK_VERSION_KEY, jdkVersion); + } else if (line.contains(JDK_HEADER_PNG_KEY)) { + output = line.replace(JDK_HEADER_PNG_KEY, headerImageSrc); + } else if (line.contains(REGISTRATION_URL_KEY)) { + output = line.replace(REGISTRATION_URL_KEY, registerURL); + } else if (line.contains(REGISTRATION_PAYLOAD_KEY)) { + output = line.replace(REGISTRATION_PAYLOAD_KEY, payload.toString()); + } + pw.println(output); + } + f.setReadOnly(); + pw.flush(); + } finally { + if (pw != null) { + pw.close(); + } + if (in != null) { + in.close(); + } + if (br!= null) { + br.close(); + } + } + } + } + + /** + * A utility class to create a service tag for Java SE. + * <p> + * <b>Usage:</b><br> + * <blockquote><tt> + * <JAVA_HOME>/bin/java com.sun.servicetag.Installer + * </tt></blockquote> + * <p> + */ + public static void main(String[] args) { + String source = "Manual"; + + // Parse the options (arguments starting with "-" ) + boolean delete = false; + boolean update = false; + boolean register = false; + int count = 0; + while (count < args.length) { + String arg = args[count]; + if (arg.trim().length() == 0) { + // skip empty arguments + count++; + continue; + } + + if (arg.equals("-source")) { + source = args[++count]; + } else if (arg.equals("-delete")) { + delete = true; + } else if (arg.equals("-register")) { + register = true; + } else { + usage(); + return; + } + count++; + } + try { + if (delete) { + deleteRegistrationData(); + } else { + ServiceTag[] javaSvcTags = getJavaServiceTagArray(); + String[] archs = getJreArchs(); + if (javaSvcTags.length > archs.length) { + // 64-bit has been uninstalled + // so remove the service tag + updateRegistrationData(source); + } else { + // create the service tag + createServiceTag(source); + } + } + + if (register) { + // Registration is only supported by JDK + // For testing purpose, override with a "servicetag.enable.registration" property + + RegistrationData regData = getRegistrationData(); + if (supportRegistration && !regData.getServiceTags().isEmpty()) { + SunConnection.register(regData); + } + } + System.exit(0); + } catch (IOException e) { + System.err.println("I/O Error: " + e.getMessage()); + if (isVerbose()) { + e.printStackTrace(); + } + } catch (IllegalArgumentException ex) { + if (isVerbose()) { + ex.printStackTrace(); + } + } catch (Exception e) { + System.err.println("Error: " + e.getMessage()); + if (isVerbose()) { + e.printStackTrace(); + } + } + System.exit(1); + } + + private static void usage() { + System.out.println("Usage:"); + System.out.print(" " + Installer.class.getName()); + System.out.println(" [-delete|-source <source>|-register]"); + System.out.println(" to create a service tag for the Java platform"); + System.out.println(""); + System.out.println("Internal Options:"); + System.out.println(" -source: to specify the source of the service tag to be created"); + System.out.println(" -delete: to delete the service tag "); + System.out.println(" -register: to register the JDK"); + System.out.println(" -help: to print this help message"); + } +} diff --git a/desktop/source/registration/com/sun/star/servicetag/LinuxSystemEnvironment.java b/desktop/source/registration/com/sun/star/servicetag/LinuxSystemEnvironment.java new file mode 100644 index 000000000000..90e38021c103 --- /dev/null +++ b/desktop/source/registration/com/sun/star/servicetag/LinuxSystemEnvironment.java @@ -0,0 +1,194 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LinuxSystemEnvironment.java,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.servicetag; + +// The Service Tags team maintains the latest version of the implementation +// for system environment data collection. JDK will include a copy of +// the most recent released version for a JDK release. We rename +// the package to com.sun.servicetag so that the Sun Connection +// product always uses the latest version from the com.sun.scn.servicetags +// package. JDK and users of the com.sun.servicetag API +// (e.g. NetBeans and SunStudio) will use the version in JDK. + +import java.io.*; + +/** + * Linux implementation of the SystemEnvironment class. + */ +class LinuxSystemEnvironment extends SystemEnvironment { + LinuxSystemEnvironment() { + setHostId(getLinuxHostId()); + setSystemModel(getCommandOutput("/bin/uname", "-i")); + setSystemManufacturer(getLinuxSystemManufacturer()); + setCpuManufacturer(getLinuxCpuManufacturer()); + setSerialNumber(getLinuxSN()); + } + private String dmiInfo = null; + + private static final int SN = 1; + private static final int SYS = 2; + private static final int CPU = 3; + + private String getLinuxHostId() { + String output = getCommandOutput("/usr/bin/hostid"); + // trim off the leading 0x + if (output.startsWith("0x")) { + output = output.substring(2); + } + return output; + } + + /** + * Tries to obtain and return the cpu manufacturer. + * @return The cpu manufacturer (an empty string if not found or an error occurred) + */ + private String getLinuxCpuManufacturer() { + String tmp = getLinuxPSNInfo(CPU); + if (tmp.length() > 0) { + return tmp; + } + + String contents = getFileContent("/proc/cpuinfo"); + for (String line : contents.split("\n")) { + if (line.contains("vendor_id")) { + String[] ss = line.split(":", 2); + if (ss.length > 1) { + return ss[1].trim(); + } + } + } + + // returns an empty string if it can't be found or an error happened + return getLinuxDMIInfo("dmi type 4", "manufacturer"); + } + + + /** + * Tries to obtain and return the system manufacturer. + * @return The system manufacturer (an empty string if not found or an error occurred) + */ + private String getLinuxSystemManufacturer() { + String tmp = getLinuxPSNInfo(SYS); + if (tmp.length() > 0) { + return tmp; + } + + // returns an empty string if it can't be found or an error happened + return getLinuxDMIInfo("dmi type 1", "manufacturer"); + } + + /** + * Tries to obtain and return the serial number of the system. + * @return The serial number (an empty string if not found or an error occurred) + */ + private String getLinuxSN() { + String tmp = getLinuxPSNInfo(SN); + if (tmp.length() > 0) { + return tmp; + } + + // returns an empty string if it can't be found or an error happened + return getLinuxDMIInfo("dmi type 1", "serial number"); + } + + private String getLinuxPSNInfo(int target) { + // try to read from the psn file if it exists + String contents = getFileContent("/var/run/psn"); + String[] ss = contents.split("\n"); + if (target <= ss.length) { + return ss[target-1]; + } + + // default case is to return "" + return ""; + } + + // reads from dmidecode with the given type and target + // returns an empty string if nothing was found or an error occurred + // + // Sample output segment: + // Handle 0x0001 + // DMI type 1, 25 bytes. + // System Information + // Manufacturer: System manufacturer + // Product Name: System Product Name + // Version: System Version + // Serial Number: System Serial Number + // UUID: 3091D719-B25B-D911-959D-6D1B12C7686E + // Wake-up Type: Power Switch + + private synchronized String getLinuxDMIInfo(String dmiType, String target) { + // only try to get dmidecode information once, after that, we can + // reuse the output + if (dmiInfo == null) { + Thread dmidecodeThread = new Thread() { + public void run() { + dmiInfo = getCommandOutput("/usr/sbin/dmidecode"); + } + }; + dmidecodeThread.start(); + + try { + dmidecodeThread.join(2000); + if (dmidecodeThread.isAlive()) { + dmidecodeThread.interrupt(); + dmiInfo = ""; + } + } catch (InterruptedException ie) { + dmidecodeThread.interrupt(); + } + } + + if (dmiInfo.length() == 0) { + return ""; + } + boolean dmiFlag = false; + for (String s : dmiInfo.split("\n")) { + String line = s.toLowerCase(); + if (dmiFlag) { + if (line.contains(target)) { + String key = target + ":"; + int indx = line.indexOf(key) + key.length(); + if (line.contains(key) && indx < line.length()) { + return line.substring(indx).trim(); + } + String[] ss = line.split(":"); + return ss[ss.length-1]; + } + } else if (line.contains(dmiType)) { + dmiFlag = true; + } + } + return ""; + } + +} diff --git a/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java b/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java new file mode 100644 index 000000000000..57be724a78a3 --- /dev/null +++ b/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java @@ -0,0 +1,473 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: RegistrationData.java,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.servicetag; + +import java.io.*; +import java.net.UnknownHostException; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +import static com.sun.star.servicetag.RegistrationDocument.*; + +/** + * A {@code RegistrationData} object is a container of one or more + * {@link #getServiceTags service tags} that identify the + * components for product registration. + * Each {@code RegistrationData} object has a {@link #getRegistrationURN + * uniform resource name} (URN) as its identifier. + * <a name="EnvMap"></a> + * It also has an <i>environment map</i> with + * the following elements: + * <blockquote> + * <table border=0> + * <tr> + * <td><tt>hostname</tt></td> + * <td>Hostname of the system</td> + * <td>e.g. woody</td> + * </tr> + * <tr> + * <td><tt>hostId</tt></td> + * <td>Host ID of the system</td> + * <td>e.g. 83abc1ab</td> + * </tr> + * <tr> + * <td><tt>osName</tt></td> + * <td>Operating system name</td> + * <td> e.g. SunOS</td> + * </tr> + * <tr> + * <td><tt>osVersion</tt></td> + * <td>Operating system version</td> + * <td> e.g. 5.10</td> + * </tr> + * <tr> + * <td><tt>osArchitecture</tt></td> + * <td>Operating system architecture</td> + * <td> e.g. sparc</td> + * </tr> + * <tr> + * <td><tt>systemModel</tt></td> + * <td>System model</td> + * <td> e.g. SUNW,Sun-Fire-V440</td> + * </tr> + * <tr> + * <td><tt>systemManufacturer</tt></td> + * <td>System manufacturer</td> + * <td> e.g. Sun Microsystems</td> + * </tr> + * <tr> + * <td><tt>cpuManufacturer</tt></td> + * <td>CPU manufacturer</td> + * <td> e.g. Sun Microsystems</td> + * </tr> + * <tr> + * <td><tt>serialNumber</tt></td> + * <td>System serial number</td> + * <td> e.g. BEL078932</td> + * </tr> + * </table> + * </blockquote> + * The <tt>hostname</tt> and <tt>osName</tt> element must have a non-empty value. + * If an element is not available on a system and their value will be + * empty. + * <p> + * <a name="XMLSchema"> + * <b>Registration XML Schema</b></a> + * <p> + * A {@code RegistrationData} object can be {@link #loadFromXML loaded} from + * and {@link #storeToXML stored} into an XML file in the format described + * by the + * <a href="https://sn-tools.central.sun.com/twiki/pub/ServiceTags/RegistrationRelayService/product_registration.xsd"> + * registration data schema</a>. The registration data schema is defined by the + * Service Tags Technology. + * <p> + * Typically the registration data is constructed at installation time + * and stored in an XML file for later service tag lookup or registration. + * + * <p> + * <b>Example Usage</b> + * <p> + * The examples below show how the {@code RegistrationData} can be + * used for product registration. + * Exception handling is not shown in these examples for clarity. + * <ol> + * <li>This example shows how the JDK creates a JDK service tag, installs it + * in the system service tag registry and adds it to the registration data. + * <br> + * <blockquote><pre> + * // create a service tag object with an instance_urn + * ServiceTag st = ServiceTag.newInstance(ServiceTag.generateInstanceURN(), + * ....); + * // Adds to the system service tag registry if supported + * if (Registry.isSupported()) { + * Registry.getSystemRegistry().addServiceTag(st); + * } + * + * // add to the registration data + * RegistrationData registration = new RegistrationData(); + * registration.addServiceTag(st); + * </pre></blockquote> + * </li> + * <li>At this point, the registration data is ready to + * send to Sun Connection for registration. This example shows how to register + * the JDK via the <i>Registration Relay Service</i>. + * <p> + * There are several registration services for Sun Connection. For example, + * the <a href="https://sn-tools.central.sun.com/twiki/bin/view/ServiceTags/RegistrationRelayService"> + * Registration Relay Service</a> is a web application interface that + * processes the registration data payload sent via HTTP post + * and hosts the registration user interface for a specified + * registration URL. Refer to the + * Registration Relay Service Specification for details. + * <p> + * <blockquote><pre> + * // Open the connection to the URL of the registration service + * HttpsURLConnection con = (HttpsURLConnection) url.openConnection(); + * con.setDoInput(true); + * con.setDoOutput(true); + * con.setUseCaches(false); + * con.setAllowUserInteraction(false); + * con.setRequestMethod("POST"); + * con.setRequestProperty("Content-Type", "text/xml;charset=\"utf-8\""); + * con.connect(); + * + * // send the registration data to the registration service + * OutputStream out = con.getOutputStream(); + * registration.storeToXML(out); + * out.close(); + * </pre></blockquote> + * </li> + * <li>This example shows how to store the registration data in an XML file. + * for later service tag lookup or registration. + * <br> + * <blockquote><pre> + * BufferedOutputStream out = new BufferedOutputStream( + * new FileOutputStream(""<JAVA_HOME>/lib/servicetag/registration.xml")); + * registration.storeToXML(out); + * out.close(); + * </pre></blockquote> + * </li> + * <li>This example shows how to install service tags that are in the + * registration data in the system service tag registry when determined + * to be available. The system service tag registry might not have existed + * when the registration data was constructed. + * <br> + * <blockquote><pre> + * if (Registry.isSupported()) { + * Set<ServiceTag> svctags = registration.getServiceTags(); + * for (ServiceTag st : svctags) { + * Registry.getSystemRegistry().addServiceTag(st); + * } + * } + * </pre></blockquote> + * </li> + * </ol> + * + * @see <a href="https://sunconnection.sun.com/inventory">Sun Connection Inventory Channel</a> + */ +public class RegistrationData { + private final Map<String, String> environment; + private final Map<String, ServiceTag> svcTagMap; + private final String urn; + + /** + * Creates a {@code RegistrationData} object with a generated + * {@link #getRegistrationURN registration URN}. + * The following keys in the {@link #getEnvironmentMap environment map} + * will be initialized for the configuration of the + * running system: + * <blockquote> + * <tt>hostname</tt>, <tt>osName</tt>, <tt>osVersion</tt> and + * <tt>osArchitecture</tt> + * </blockquote> + * and the value of other keys may be empty. + */ + public RegistrationData() { + this(Util.generateURN()); + } + + // package private + RegistrationData(String urn) { + this.urn = urn; + this.environment = initEnvironment(); + this.svcTagMap = new LinkedHashMap<String, ServiceTag>(); + } + + private Map<String, String> initEnvironment() { + Map<String, String> map = new LinkedHashMap<String, String>(); + SystemEnvironment sysEnv = SystemEnvironment.getSystemEnvironment(); + map.put(ST_NODE_HOSTNAME, sysEnv.getHostname()); + map.put(ST_NODE_HOST_ID, sysEnv.getHostId()); + map.put(ST_NODE_OS_NAME, sysEnv.getOsName()); + map.put(ST_NODE_OS_VERSION, sysEnv.getOsVersion()); + map.put(ST_NODE_OS_ARCH, sysEnv.getOsArchitecture()); + map.put(ST_NODE_SYSTEM_MODEL, sysEnv.getSystemModel()); + map.put(ST_NODE_SYSTEM_MANUFACTURER, sysEnv.getSystemManufacturer()); + map.put(ST_NODE_CPU_MANUFACTURER, sysEnv.getCpuManufacturer()); + map.put(ST_NODE_SERIAL_NUMBER, sysEnv.getSerialNumber()); + return map; + } + + /** + * Returns the uniform resource name of this registration data + * in this format: + * <tt>urn:st:<32-char {@link java.util.UUID uuid}></tt> + * + * @return the URN of this registration data. + */ + public String getRegistrationURN() { + return urn; + } + + /** + * Returns a map containing the environment information for this + * registration data. See the set of <a href="#EnvMap">keys</a> + * in the environment map. Subsequent update to the environment + * map via the {@link #setEnvironment setEnvironment} method will not be reflected + * in the returned map. + * + * @return an environment map for this registration data. + */ + public Map<String, String> getEnvironmentMap() { + return new LinkedHashMap<String,String>(environment); + } + + /** + * Sets an element of the specified {@code name} in the environment map + * with the given {@code value}. + * + * @throws IllegalArgumentException if {@code name} is not a valid key + * in the environment map, or {@code value} is not valid. + */ + public void setEnvironment(String name, String value) { + if (name == null) { + throw new NullPointerException("name is null"); + } + if (value == null) { + throw new NullPointerException("value is null"); + } + if (environment.containsKey(name)) { + if (name.equals(ST_NODE_HOSTNAME) || name.equals(ST_NODE_OS_NAME)) { + if (value.length() == 0) { + throw new IllegalArgumentException("\"" + + name + "\" requires non-empty value."); + } + } + environment.put(name, value); + } else { + throw new IllegalArgumentException("\"" + + name + "\" is not an environment element."); + } + } + + /** + * Returns all service tags in this registration data. + * + * @return a {@link Set Set} of the service tags + * in this registration data. + */ + public Set<ServiceTag> getServiceTags() { + return new HashSet<ServiceTag>(svcTagMap.values()); + } + + /** + * Adds a service tag to this registration data. + * If the given service tag has an empty <tt>instance_urn</tt>, + * this method will generate a URN and place it in the copy + * of the service tag in this registration data. + * This method will return the {@code ServiceTag} object + * added to this registration data. + * + * @param st {@code ServiceTag} object to be added. + * @return a {@code ServiceTag} object added to this registration data. + * + * @throws IllegalArgumentException if + * a service tag of the same {@link ServiceTag#getInstanceURN + * <tt>instance_urn</tt>} already exists in the registry. + */ + public synchronized ServiceTag addServiceTag(ServiceTag st) { + ServiceTag svcTag = ServiceTag.newInstanceWithUrnTimestamp(st); + + String instanceURN = svcTag.getInstanceURN(); + if (svcTagMap.containsKey(instanceURN)) { + throw new IllegalArgumentException("Instance_urn = " + instanceURN + + " already exists in the registration data."); + } else { + svcTagMap.put(instanceURN, svcTag); + } + return svcTag; + } + + /** + * Returns a service tag of the given <tt>instance_urn</tt> in this registration + * data. + * + * @param instanceURN the <tt>instance_urn</tt> of the service tag + * @return the {@code ServiceTag} object of the given <tt>instance_urn</tt> + * if exists; otherwise return {@code null}. + */ + public synchronized ServiceTag getServiceTag(String instanceURN) { + if (instanceURN == null) { + throw new NullPointerException("instanceURN is null"); + } + return svcTagMap.get(instanceURN); + } + + /** + * Removes a service tag of the given <tt>instance_urn</tt> from this + * registration data. + * + * @param instanceURN the <tt>instance_urn</tt> of + * the service tag to be removed. + * + * @return the removed {@code ServiceTag} object; + * or {@code null} if the service tag does not exist in this + * registration data. + */ + public synchronized ServiceTag removeServiceTag(String instanceURN) { + if (instanceURN == null) { + throw new NullPointerException("instanceURN is null"); + } + + ServiceTag svcTag = null; + if (svcTagMap.containsKey(instanceURN)) { + svcTag = svcTagMap.remove(instanceURN); + } + return svcTag; + } + + /** + * Updates the <tt>product_defined_instance_id</tt> in the service tag + * of the given <tt>instance_urn</tt> in this registration data. + * + * @param instanceURN the <tt>instance_urn</tt> of the service tag to be updated. + * @param productDefinedInstanceID the value of the + * <tt>product_defined_instance_id</tt> to be set. + * + * @return the updated {@code ServiceTag} object; + * or {@code null} if the service tag does not exist in this + * registration data. + */ + public synchronized ServiceTag updateServiceTag(String instanceURN, + String productDefinedInstanceID) { + ServiceTag svcTag = getServiceTag(instanceURN); + if (svcTag == null) { + return null; + } + + svcTag = ServiceTag.newInstanceWithUrnTimestamp(svcTag); + // update the product defined instance ID field + svcTag.setProductDefinedInstanceID(productDefinedInstanceID); + svcTagMap.put(instanceURN, svcTag); + return svcTag; + } + + /** + * Reads the registration data from the XML document on the + * specified input stream. The XML document must be + * in the format described by the <a href="#XMLSchema"> + * registration data schema</a>. + * The specified stream is closed after this method returns. + * + * @param in the input stream from which to read the XML document. + * @return a {@code RegistrationData} object read from the input + * stream. + * + * @throws IllegalArgumentException if the input stream + * contains an invalid registration data. + * + * @throws IOException if an error occurred when reading from the input stream. + */ + public static RegistrationData loadFromXML(InputStream in) throws IOException { + try { + return RegistrationDocument.load(in); + } finally { + in.close(); + } + } + + /** + * Writes the registration data to the specified output stream + * in the format described by the <a href="#XMLSchema"> + * registration data schema</a> with "UTF-8" encoding. + * The specified stream remains open after this method returns. + * + * @param os the output stream on which to write the XML document. + * + * @throws IOException if an error occurred when writing to the output stream. + */ + public void storeToXML(OutputStream os) throws IOException { + RegistrationDocument.store(os, this); + os.flush(); + } + + /** + * Returns a newly allocated byte array containing the registration + * data in XML format. + * + * @return a newly allocated byte array containing the registration + * data in XML format. + */ + public byte[] toXML() { + try { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + storeToXML(out); + return out.toByteArray(); + } catch (IOException e) { + // should not reach here + return new byte[0]; + } + } + + /** + * Returns a string representation of this registration data in XML + * format. + * + * @return a string representation of this registration data in XML + * format. + */ + @Override + public String toString() { + try { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + storeToXML(out); + return out.toString("UTF-8"); + } catch (IOException e) { + // should not reach here + return "Error creating the return string."; + } + } +} diff --git a/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java b/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java new file mode 100644 index 000000000000..240eebf4e65c --- /dev/null +++ b/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java @@ -0,0 +1,374 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: RegistrationDocument.java,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.servicetag; + +import java.io.*; +import java.net.URL; +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; +import org.xml.sax.InputSource; + +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; + +// For write operation +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +/** + * XML Support Class for Product Registration. + */ +class RegistrationDocument { + + private static final String REGISTRATION_DATA_SCHEMA = + "/com/sun/star/servicetag/resources/product_registration.xsd"; + private static final String REGISTRATION_DATA_VERSION = "1.0"; + private static final String SERVICE_TAG_VERSION = "1.0"; + final static String ST_NODE_REGISTRATION_DATA = "registration_data"; + final static String ST_ATTR_REGISTRATION_VERSION = "version"; + final static String ST_NODE_ENVIRONMENT = "environment"; + final static String ST_NODE_HOSTNAME = "hostname"; + final static String ST_NODE_HOST_ID = "hostId"; + final static String ST_NODE_OS_NAME = "osName"; + final static String ST_NODE_OS_VERSION = "osVersion"; + final static String ST_NODE_OS_ARCH = "osArchitecture"; + final static String ST_NODE_SYSTEM_MODEL = "systemModel"; + final static String ST_NODE_SYSTEM_MANUFACTURER = "systemManufacturer"; + final static String ST_NODE_CPU_MANUFACTURER = "cpuManufacturer"; + final static String ST_NODE_SERIAL_NUMBER = "serialNumber"; + final static String ST_NODE_REGISTRY = "registry"; + final static String ST_ATTR_REGISTRY_URN = "urn"; + final static String ST_ATTR_REGISTRY_VERSION = "version"; + final static String ST_NODE_SERVICE_TAG = "service_tag"; + final static String ST_NODE_INSTANCE_URN = "instance_urn"; + final static String ST_NODE_PRODUCT_NAME = "product_name"; + final static String ST_NODE_PRODUCT_VERSION = "product_version"; + final static String ST_NODE_PRODUCT_URN = "product_urn"; + final static String ST_NODE_PRODUCT_PARENT_URN = "product_parent_urn"; + final static String ST_NODE_PRODUCT_PARENT = "product_parent"; + final static String ST_NODE_PRODUCT_DEFINED_INST_ID = "product_defined_inst_id"; + final static String ST_NODE_PRODUCT_VENDOR = "product_vendor"; + final static String ST_NODE_PLATFORM_ARCH = "platform_arch"; + final static String ST_NODE_TIMESTAMP = "timestamp"; + final static String ST_NODE_CONTAINER = "container"; + final static String ST_NODE_SOURCE = "source"; + final static String ST_NODE_INSTALLER_UID = "installer_uid"; + + static RegistrationData load(InputStream in) throws IOException { + Document document = initializeDocument(in); + + // Gets the registration URN + Element root = getRegistrationDataRoot(document); + Element registryRoot = + getSingletonElementFromRoot(root, ST_NODE_REGISTRY); + String urn = registryRoot.getAttribute(ST_ATTR_REGISTRY_URN); + + // Construct a new RegistrationData object from the DOM tree + // Initialize the environment map and service tags + RegistrationData regData = new RegistrationData(urn); + addServiceTags(registryRoot, regData); + + Element envRoot = getSingletonElementFromRoot(root, ST_NODE_ENVIRONMENT); + buildEnvironmentMap(envRoot, regData); + return regData; + } + + static void store(OutputStream os, RegistrationData registration) + throws IOException { + // create a new document with the root node + Document document = initializeDocument(); + + // create the nodes for the environment map and the service tags + // in the registration data + addEnvironmentNodes(document, + registration.getEnvironmentMap()); + addServiceTagRegistry(document, + registration.getRegistrationURN(), + registration.getServiceTags()); + transform(document, os); + } + + // initialize a document from an input stream + private static Document initializeDocument(InputStream in) throws IOException { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + try { + // XML schema for validation + SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + URL xsdUrl = RegistrationDocument.class.getResource(REGISTRATION_DATA_SCHEMA); + Schema schema = sf.newSchema(xsdUrl); + Validator validator = schema.newValidator(); + + DocumentBuilder builder = factory.newDocumentBuilder(); + Document doc = builder.parse(new InputSource(in)); + validator.validate(new DOMSource(doc)); + return doc; + } catch (SAXException sxe) { + IllegalArgumentException e = new IllegalArgumentException("Error generated in parsing"); + e.initCause(sxe); + throw e; + } catch (ParserConfigurationException pce) { + // Parser with specific options can't be built + // should not reach here + InternalError x = new InternalError("Error in creating the new document"); + x.initCause(pce); + throw x; + } + } + + // initialize a new document for the registration data + private static Document initializeDocument() throws IOException { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + try { + DocumentBuilder builder = factory.newDocumentBuilder(); + Document doc = builder.newDocument(); + + // initialize the document with the registration_data root + Element root = doc.createElement(ST_NODE_REGISTRATION_DATA); + doc.appendChild(root); + root.setAttribute(ST_ATTR_REGISTRATION_VERSION, REGISTRATION_DATA_VERSION); + + return doc; + } catch (ParserConfigurationException pce) { + // Parser with specified options can't be built + // should not reach here + InternalError x = new InternalError("Error in creating the new document"); + x.initCause(pce); + throw x; + } + } + + // Transform the current DOM tree with the given output stream. + private static void transform(Document document, OutputStream os) { + try { + // Use a Transformer for output + TransformerFactory tFactory = TransformerFactory.newInstance(); + tFactory.setAttribute("indent-number", new Integer(3)); + + Transformer transformer = tFactory.newTransformer(); + + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + transformer.setOutputProperty(OutputKeys.STANDALONE, "yes"); + transformer.transform(new DOMSource(document), + new StreamResult(new BufferedWriter(new OutputStreamWriter(os, "UTF-8")))); + } catch (UnsupportedEncodingException ue) { + // Should not reach here + InternalError x = new InternalError("Error generated during transformation"); + x.initCause(ue); + throw x; + } catch (TransformerConfigurationException tce) { + // Error generated by the parser + // Should not reach here + InternalError x = new InternalError("Error in creating the new document"); + x.initCause(tce); + throw x; + } catch (TransformerException te) { + // Error generated by the transformer + InternalError x = new InternalError("Error generated during transformation"); + x.initCause(te); + throw x; + } + } + + private static void addServiceTagRegistry(Document document, + String registryURN, + Set<ServiceTag> svcTags) { + // add service tag registry node and its attributes + Element reg = document.createElement(ST_NODE_REGISTRY); + reg.setAttribute(ST_ATTR_REGISTRY_URN, registryURN); + reg.setAttribute(ST_ATTR_REGISTRY_VERSION, SERVICE_TAG_VERSION); + + Element root = getRegistrationDataRoot(document); + root.appendChild(reg); + + // adds the elements for the service tags + for (ServiceTag st : svcTags) { + addServiceTagElement(document, reg, st); + } + } + + private static void addServiceTagElement(Document document, + Element registryRoot, + ServiceTag st) { + Element svcTag = document.createElement(ST_NODE_SERVICE_TAG); + registryRoot.appendChild(svcTag); + addChildElement(document, svcTag, + ST_NODE_INSTANCE_URN, st.getInstanceURN()); + addChildElement(document, svcTag, + ST_NODE_PRODUCT_NAME, st.getProductName()); + addChildElement(document, svcTag, + ST_NODE_PRODUCT_VERSION, st.getProductVersion()); + addChildElement(document, svcTag, + ST_NODE_PRODUCT_URN, st.getProductURN()); + addChildElement(document, svcTag, + ST_NODE_PRODUCT_PARENT_URN, st.getProductParentURN()); + addChildElement(document, svcTag, + ST_NODE_PRODUCT_PARENT, st.getProductParent()); + addChildElement(document, svcTag, + ST_NODE_PRODUCT_DEFINED_INST_ID, + st.getProductDefinedInstanceID()); + addChildElement(document, svcTag, + ST_NODE_PRODUCT_VENDOR, st.getProductVendor()); + addChildElement(document, svcTag, + ST_NODE_PLATFORM_ARCH, st.getPlatformArch()); + addChildElement(document, svcTag, + ST_NODE_TIMESTAMP, Util.formatTimestamp(st.getTimestamp())); + addChildElement(document, svcTag, + ST_NODE_CONTAINER, st.getContainer()); + addChildElement(document, svcTag, + ST_NODE_SOURCE, st.getSource()); + addChildElement(document, svcTag, + ST_NODE_INSTALLER_UID, + String.valueOf(st.getInstallerUID())); + } + + private static void addChildElement(Document document, Element root, + String element, String text) { + Element node = document.createElement(element); + node.appendChild(document.createTextNode(text)); + root.appendChild(node); + } + + // Constructs service tags from the document + private static void addServiceTags(Element registryRoot, + RegistrationData registration) { + NodeList children = registryRoot.getElementsByTagName(ST_NODE_SERVICE_TAG); + int length = (children == null ? 0 : children.getLength()); + for (int i = 0; i < length; i++) { + Element svcTagElement = (Element) children.item(i); + ServiceTag st = getServiceTag(svcTagElement); + registration.addServiceTag(st); + } + } + + // build environment map from the document + private static void buildEnvironmentMap(Element envRoot, + RegistrationData registration) { + registration.setEnvironment(ST_NODE_HOSTNAME, getTextValue(envRoot, ST_NODE_HOSTNAME)); + registration.setEnvironment(ST_NODE_HOST_ID, getTextValue(envRoot, ST_NODE_HOST_ID)); + registration.setEnvironment(ST_NODE_OS_NAME, getTextValue(envRoot, ST_NODE_OS_NAME)); + registration.setEnvironment(ST_NODE_OS_VERSION, getTextValue(envRoot, ST_NODE_OS_VERSION)); + registration.setEnvironment(ST_NODE_OS_ARCH, getTextValue(envRoot, ST_NODE_OS_ARCH)); + registration.setEnvironment(ST_NODE_SYSTEM_MODEL, getTextValue(envRoot, ST_NODE_SYSTEM_MODEL)); + registration.setEnvironment(ST_NODE_SYSTEM_MANUFACTURER, getTextValue(envRoot, ST_NODE_SYSTEM_MANUFACTURER)); + registration.setEnvironment(ST_NODE_CPU_MANUFACTURER, getTextValue(envRoot, ST_NODE_CPU_MANUFACTURER)); + registration.setEnvironment(ST_NODE_SERIAL_NUMBER, getTextValue(envRoot, ST_NODE_SERIAL_NUMBER)); + } + + // add the nodes representing the environment map in the document + private static void addEnvironmentNodes(Document document, + Map<String, String> envMap) { + Element root = getRegistrationDataRoot(document); + Element env = document.createElement(ST_NODE_ENVIRONMENT); + root.appendChild(env); + Set<Map.Entry<String, String>> keys = envMap.entrySet(); + for (Map.Entry<String, String> entry : keys) { + addChildElement(document, env, entry.getKey(), entry.getValue()); + } + } + + private static Element getRegistrationDataRoot(Document doc) { + Element root = doc.getDocumentElement(); + if (!root.getNodeName().equals(ST_NODE_REGISTRATION_DATA)) { + throw new IllegalArgumentException("Not a " + + ST_NODE_REGISTRATION_DATA + + " node \"" + root.getNodeName() + "\""); + } + return root; + } + + private static Element getSingletonElementFromRoot(Element root, String name) { + NodeList children = root.getElementsByTagName(name); + int length = (children == null ? 0 : children.getLength()); + if (length != 1) { + throw new IllegalArgumentException("Invalid number of " + name + + " nodes = " + length); + } + Element e = (Element) children.item(0); + if (!e.getNodeName().equals(name)) { + throw new IllegalArgumentException("Not a " + name + + " node \"" + e.getNodeName() + "\""); + } + return e; + } + + // Constructs one ServiceTag instance from a service tag element root + private static ServiceTag getServiceTag(Element svcTagElement) { + return new ServiceTag( + getTextValue(svcTagElement, ST_NODE_INSTANCE_URN), + getTextValue(svcTagElement, ST_NODE_PRODUCT_NAME), + getTextValue(svcTagElement, ST_NODE_PRODUCT_VERSION), + getTextValue(svcTagElement, ST_NODE_PRODUCT_URN), + getTextValue(svcTagElement, ST_NODE_PRODUCT_PARENT), + getTextValue(svcTagElement, ST_NODE_PRODUCT_PARENT_URN), + getTextValue(svcTagElement, ST_NODE_PRODUCT_DEFINED_INST_ID), + getTextValue(svcTagElement, ST_NODE_PRODUCT_VENDOR), + getTextValue(svcTagElement, ST_NODE_PLATFORM_ARCH), + getTextValue(svcTagElement, ST_NODE_CONTAINER), + getTextValue(svcTagElement, ST_NODE_SOURCE), + Util.getIntValue(getTextValue(svcTagElement, ST_NODE_INSTALLER_UID)), + Util.parseTimestamp(getTextValue(svcTagElement, ST_NODE_TIMESTAMP)) + ); + } + + private static String getTextValue(Element e, String tagName) { + String value = ""; + NodeList nl = e.getElementsByTagName(tagName); + if (nl != null && nl.getLength() > 0) { + Element el = (Element) nl.item(0); + Node node = el.getFirstChild(); + if (node != null) { + value = node.getNodeValue(); + } + } + return value; + } +} diff --git a/desktop/source/registration/com/sun/star/servicetag/Registry.java b/desktop/source/registration/com/sun/star/servicetag/Registry.java new file mode 100644 index 000000000000..c118dc2e2575 --- /dev/null +++ b/desktop/source/registration/com/sun/star/servicetag/Registry.java @@ -0,0 +1,558 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: Registry.java,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.servicetag; + +import java.io.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Properties; +import java.util.Set; + +import static com.sun.star.servicetag.Util.*; +import static com.sun.star.servicetag.RegistrationDocument.*; + +/** + * A service tag registry is a XML-based registry containing + * the list of {@link ServiceTag service tags} installed in the system. + * The {@code Registry} class provides interfaces + * to add, remove, update, and get a service tag from a service tag + * registry. + * This {@code Registry} class may not be supported + * on all systems. The {@link #isSupported} method + * can be called to determine if it is supported. + * <p> + * A registry may implement restrictions to only allow certain users + * to {@link #updateServiceTag update} and + * to {@link #removeServiceTag remove} a service tag record. Typically, + * only the owner of the service tag, the owner of the registry + * and superuser are authorized to update or remove a service tag in + * the registry. + * + * @see <a href="https://sn-tools.central.sun.com/twiki/bin/view/ServiceTags/ServiceTagDevGuideHelper"> + * Service Tag User Guide</a> + */ +public class Registry { + + private static final String STCLIENT_SOLARIS = "/usr/bin/stclient"; + private static final String STCLIENT_LINUX = "/opt/sun/servicetag/bin/stclient"; + // stclient exit value (see sthelper.h) + private static final int ST_ERR_NOT_AUTH = 245; + private static final int ST_ERR_REC_NOT_FOUND = 225; + + // The stclient output has to be an exported interface + private static final String INSTANCE_URN_DESC = "Product instance URN="; + private static boolean initialized = false; + private static boolean supportsHelperClass = true; // default + private static File stclient = null; + private static String stclientPath = null; + private static Registry registry = new Registry(); + + // System properties for testing + private static String SVCTAG_STCLIENT_CMD = "servicetag.stclient.cmd"; + private static String SVCTAG_STHELPER_SUPPORTED = "servicetag.sthelper.supported"; + + private Registry() { + } + + private synchronized static String getSTclient() { + if (!initialized) { + // the system property always overrides the default setting + if (System.getProperty(SVCTAG_STHELPER_SUPPORTED) != null) { + supportsHelperClass = Boolean.getBoolean(SVCTAG_STHELPER_SUPPORTED); + } + + // This is only used for testing + stclientPath = System.getProperty(SVCTAG_STCLIENT_CMD); + if (stclientPath != null) { + return stclientPath; + } + + // Initialization to determine the platform's stclient pathname + String os = System.getProperty("os.name"); + if (os.equals("SunOS")) { + stclient = new File(STCLIENT_SOLARIS); + } else if (os.equals("Linux")) { + stclient = new File(STCLIENT_LINUX); + } else if (os.startsWith("Windows")) { + stclient = getWindowsStClientFile(); + } else { + if (isVerbose()) { + System.out.println("Running on non-Sun JDK"); + } + } + initialized = true; + } + + // com.sun.servicetag package has to be compiled with JDK 5 as well + // JDK 5 doesn't support the File.canExecute() method. + // Risk not checking isExecute() for the stclient command is very low. + + if (stclientPath == null && stclient != null && stclient.exists()) { + stclientPath = stclient.getAbsolutePath(); + } + return stclientPath; + } + + /** + * Returns the system service tag registry. The {@code Registry} class + * may not be supported on some platforms; use the {@link #isSupported} + * method to determine if it is supported. + * + * @return the {@code Registry} object for the system service tag registry. + * + * @throws UnsupportedOperationException if the {@code Registry} class is + * not supported. + */ + public static Registry getSystemRegistry() { + if (isSupported()) { + return registry; + } else { + throw new UnsupportedOperationException("Registry class is not supported"); + } + } + + /** + * Returns {@code true} if the {@code Registry} class is supported on this system. + * + * @return {@code true} if the {@code Registry} class is supported; + * otherwise, return {@code false}. + */ + public static boolean isSupported() { + return (getSTclient() != null && supportsHelperClass); + } + + private static List<String> getCommandList() { + // Set up the arguments to call stclient + List<String> command = new ArrayList<String>(); + if (System.getProperty(SVCTAG_STCLIENT_CMD) != null) { + // This is for jtreg testing use. This will be set to something + // like: + // $JAVA_HOME/bin/java -cp $TEST_DIR \ + // -Dstclient.registry.path=$TEST_DIR/registry.xml \ + // SvcTagClient + // + // On Windows, the JAVA_HOME and TEST_DIR path could contain + // space e.g. c:\Program Files\Java\jdk1.6.0_05\bin\java. + // The SVCTAG_STCLIENT_CMD must be set with a list of + // space-separated parameters. If a parameter contains spaces, + // it must be quoted with '"'. + + String cmd = getSTclient(); + int len = cmd.length(); + int i = 0; + while (i < len) { + char separator = ' '; + if (cmd.charAt(i) == '"') { + separator = '"'; + i++; + } + // look for the separator or matched the closing '"' + int j; + for (j = i+1; j < len; j++) { + if (cmd.charAt(j) == separator) { + break; + } + } + + if (i == j-1) { + // add an empty parameter + command.add("\"\""); + } else { + // double quotes and space are not included + command.add(cmd.substring(i,j)); + } + + // skip spaces + for (i = j+1; i < len; i++) { + if (!Character.isSpaceChar(cmd.charAt(i))) { + break; + } + } + } + if (isVerbose()) { + System.out.println("Command list:"); + for (String s : command) { + System.out.println(s); + } + } + } else { + command.add(getSTclient()); + } + return command; + } + + // Returns null if the service tag record not found; + // or throw UnauthorizedAccessException or IOException + // based on the exitValue. + private static ServiceTag checkReturnError(int exitValue, + String output, + ServiceTag st) throws IOException { + switch (exitValue) { + case ST_ERR_REC_NOT_FOUND: + return null; + case ST_ERR_NOT_AUTH: + if (st != null) { + throw new UnauthorizedAccessException( + "Not authorized to access " + st.getInstanceURN() + + " installer_uid=" + st.getInstallerUID()); + } else { + throw new UnauthorizedAccessException( + "Not authorized:" + output); + } + default: + throw new IOException("stclient exits with error" + + " (" + exitValue + ")\n" + output); + } + } + + /** + * Adds a service tag to this registry. + * If the given service tag has an empty <tt>instance_urn</tt>, + * this helper class will generate a URN and place it in the + * copy of the service tag in this registry. + * This method will return the {@code ServiceTag} representing + * the service tag entry to this registry. + * + * @param st {@code ServiceTag} object + * @return a {@code ServiceTag} object representing the service tag + * entry to this registry. + * + * @throws IllegalArgumentException if a service tag of the same + * <tt>instance_urn</tt> already exists in this registry. + * + * @throws java.io.IOException if an I/O error occurs in this operation. + */ + public ServiceTag addServiceTag(ServiceTag st) throws IOException { + List<String> command = getCommandList(); + command.add("-a"); + if (st.getInstanceURN().length() > 0) { + ServiceTag sysSvcTag = getServiceTag(st.getInstanceURN()); + if (sysSvcTag != null) { + throw new IllegalArgumentException("Instance_urn = " + + st.getInstanceURN() + " already exists"); + } + command.add("-i"); + command.add(st.getInstanceURN()); + } + command.add("-p"); + command.add(st.getProductName()); + command.add("-e"); + command.add(st.getProductVersion()); + command.add("-t"); + command.add(st.getProductURN()); + if (st.getProductParentURN().length() > 0) { + command.add("-F"); + command.add(st.getProductParentURN()); + } + command.add("-P"); + command.add(st.getProductParent()); + if (st.getProductDefinedInstanceID().length() > 0) { + command.add("-I"); + command.add(st.getProductDefinedInstanceID()); + } + command.add("-m"); + command.add(st.getProductVendor()); + command.add("-A"); + command.add(st.getPlatformArch()); + command.add("-z"); + command.add(st.getContainer()); + command.add("-S"); + command.add(st.getSource()); + + BufferedReader in = null; + try { + ProcessBuilder pb = new ProcessBuilder(command); + Process p = pb.start(); + String output = commandOutput(p); + if (isVerbose()) { + System.out.println("Output from stclient -a command:"); + System.out.println(output); + } + String urn = ""; + if (p.exitValue() == 0) { + // Obtain the instance urn from the stclient output + in = new BufferedReader(new StringReader(output)); + String line = null; + while ((line = in.readLine()) != null) { + line = line.trim(); + if (line.startsWith(INSTANCE_URN_DESC)) { + urn = line.substring(INSTANCE_URN_DESC.length()); + break; + } + } + if (urn.length() == 0) { + throw new IOException("Error in creating service tag:\n" + + output); + } + return getServiceTag(urn); + } else { + return checkReturnError(p.exitValue(), output, st); + } + } finally { + if (in != null) { + in.close(); + } + } + } + + /** + * Removes a service tag of the given <tt>instance_urn</tt> from this + * registry. + * + * @param instanceURN the <tt>instance_urn</tt> of the service tag + * to be removed. + * + * @return the {@code ServiceTag} object removed from this registry; + * or {@code null} if the service tag does not exist in this registry. + * + * @throws UnauthorizedAccessException if the user is not authorized to + * remove the service tag of the given <tt>instance_urn</tt> + * from this registry. + * + * @throws java.io.IOException if an I/O error occurs in this operation. + */ + public ServiceTag removeServiceTag(String instanceURN) throws IOException { + ServiceTag st = getServiceTag(instanceURN); + if (st == null) { + return null; + } + + List<String> command = getCommandList(); + command.add("-d"); + command.add("-i"); + command.add(instanceURN); + + ProcessBuilder pb = new ProcessBuilder(command); + Process p = pb.start(); + String output = commandOutput(p); + if (isVerbose()) { + System.out.println("Output from stclient -d command:"); + System.out.println(output); + } + if (p.exitValue() == 0) { + return st; + } else { + return checkReturnError(p.exitValue(), output, st); + } + } + + /** + * Updates the <tt>product_defined_instance_id</tt> in the service tag + * of the specified <tt>instance_urn</tt> in this registry. + * + * @param instanceURN the <tt>instance_urn</tt> of the service tag to be updated. + * @param productDefinedInstanceID the value of the + * <tt>product_defined_instance_id</tt> to be set. + * + * @return the updated {@code ServiceTag} object; + * or {@code null} if the service tag does not exist in this + * registry. + * + * @throws UnauthorizedAccessException if the user is not authorized to + * update the service tag from this registry. + * + * @throws IOException if an I/O error occurs in this operation. + */ + public ServiceTag updateServiceTag(String instanceURN, + String productDefinedInstanceID) + throws IOException { + ServiceTag svcTag = getServiceTag(instanceURN); + if (svcTag == null) { + return null; + } + + List<String> command = getCommandList(); + command.add("-u"); + command.add("-i"); + command.add(instanceURN); + command.add("-I"); + if (productDefinedInstanceID.length() > 0) { + command.add(productDefinedInstanceID); + } else { + command.add("\"\""); + } + + ProcessBuilder pb = new ProcessBuilder(command); + Process p = pb.start(); + String output = commandOutput(p); + if (isVerbose()) { + System.out.println("Output from stclient -u command:"); + System.out.println(output); + } + + if (p.exitValue() == 0) { + return getServiceTag(instanceURN); + } else { + return checkReturnError(p.exitValue(), output, svcTag); + } + } + + /** + * Returns a {@code ServiceTag} object of the given <tt>instance_urn</tt> + * in this registry. + * + * @param instanceURN the <tt>instance_urn</tt> of the service tag + * @return a {@code ServiceTag} object of the given <tt>instance_urn</tt> + * in this registry; or {@code null} if not found. + * + * @throws java.io.IOException if an I/O error occurs in this operation. + */ + public ServiceTag getServiceTag(String instanceURN) throws IOException { + if (instanceURN == null) { + throw new NullPointerException("instanceURN is null"); + } + + List<String> command = getCommandList(); + command.add("-g"); + command.add("-i"); + command.add(instanceURN); + + ProcessBuilder pb = new ProcessBuilder(command); + Process p = pb.start(); + String output = commandOutput(p); + if (isVerbose()) { + System.out.println("Output from stclient -g command:"); + System.out.println(output); + } + if (p.exitValue() == 0) { + return parseServiceTag(output); + } else { + return checkReturnError(p.exitValue(), output, null); + } + } + + private ServiceTag parseServiceTag(String output) throws IOException { + BufferedReader in = null; + try { + Properties props = new Properties(); + // parse the service tag output from stclient + in = new BufferedReader(new StringReader(output)); + String line = null; + while ((line = in.readLine()) != null) { + if ((line = line.trim()).length() > 0) { + String[] ss = line.trim().split("=", 2); + if (ss.length == 2) { + props.setProperty(ss[0].trim(), ss[1].trim()); + } else { + props.setProperty(ss[0].trim(), ""); + } + } + } + + String urn = props.getProperty(ST_NODE_INSTANCE_URN); + String productName = props.getProperty(ST_NODE_PRODUCT_NAME); + String productVersion = props.getProperty(ST_NODE_PRODUCT_VERSION); + String productURN = props.getProperty(ST_NODE_PRODUCT_URN); + String productParent = props.getProperty(ST_NODE_PRODUCT_PARENT); + String productParentURN = props.getProperty(ST_NODE_PRODUCT_PARENT_URN); + String productDefinedInstanceID = + props.getProperty(ST_NODE_PRODUCT_DEFINED_INST_ID); + String productVendor = props.getProperty(ST_NODE_PRODUCT_VENDOR); + String platformArch = props.getProperty(ST_NODE_PLATFORM_ARCH); + String container = props.getProperty(ST_NODE_CONTAINER); + String source = props.getProperty(ST_NODE_SOURCE); + int installerUID = + Util.getIntValue(props.getProperty(ST_NODE_INSTALLER_UID)); + Date timestamp = + Util.parseTimestamp(props.getProperty(ST_NODE_TIMESTAMP)); + + return new ServiceTag(urn, + productName, + productVersion, + productURN, + productParent, + productParentURN, + productDefinedInstanceID, + productVendor, + platformArch, + container, + source, + installerUID, + timestamp); + } finally { + if (in != null) { + in.close(); + } + } + + } + + /** + * Returns the service tags of the specified + * <tt>product_urn</tt> in this registry. + * + * @param productURN the <tt>product_urn</tt> to look up + * @return a {@code Set} of {@code ServiceTag} objects + * of the specified <tt>product_urn</tt> in this registry. + * + * @throws java.io.IOException if an I/O error occurs in this operation. + */ + public Set<ServiceTag> findServiceTags(String productURN) throws IOException { + if (productURN == null) { + throw new NullPointerException("productURN is null"); + } + + List<String> command = getCommandList(); + command.add("-f"); + command.add("-t"); + command.add(productURN); + + BufferedReader in = null; + try { + ProcessBuilder pb = new ProcessBuilder(command); + Process p = pb.start(); + String output = commandOutput(p); + + Set<ServiceTag> instances = new HashSet<ServiceTag>(); + if (p.exitValue() == 0) { + // parse the service tag output from stclient + in = new BufferedReader(new StringReader(output)); + String line = null; + while ((line = in.readLine()) != null) { + String s = line.trim(); + if (s.startsWith("urn:st:")) { + instances.add(getServiceTag(s)); + } + } + } else { + checkReturnError(p.exitValue(), output, null); + } + return instances; + } finally { + if (in != null) { + in.close(); + } + } + } +} diff --git a/desktop/source/registration/com/sun/star/servicetag/ServiceTag.java b/desktop/source/registration/com/sun/star/servicetag/ServiceTag.java new file mode 100644 index 000000000000..4b2be9ff8cc2 --- /dev/null +++ b/desktop/source/registration/com/sun/star/servicetag/ServiceTag.java @@ -0,0 +1,640 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ServiceTag.java,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.servicetag; + +import java.util.Date; +import java.io.IOException; +import static com.sun.star.servicetag.RegistrationDocument.*; + +/** + * A service tag is an XML-based data structure that identifies a product or + * a component on a system. The service tag schema is defined by the + * Service Tags Technology. The location of the DTD file is platform dependent. + * On Solaris, see <tt>/usr/share/lib/xml/dtd/servicetag.dtd</tt>. + * <p> + * A valid {@code ServiceTag} instance must comply to the service tag schema + * and contain the following fields: + * <ul> + * <li>{@link #getInstanceURN <tt>instance_urn</tt>}</li> + * <li>{@link #getProductName <tt>product_name</tt>}</li> + * <li>{@link #getProductVersion <tt>product_version</tt>}</li> + * <li>{@link #getProductURN <tt>product_urn</tt>}</li> + * <li>{@link #getProductParent <tt>product_parent</tt>}</li> + * <li>{@link #getProductParentURN <tt>product_parent_urn</tt>}</li> + * <li>{@link #getProductDefinedInstanceID <tt>product_defined_inst_id</tt>}</li> + * <li>{@link #getProductVendor <tt>product_vendor</tt>}</li> + * <li>{@link #getPlatformArch <tt>platform_arch</tt>}</li> + * <li>{@link #getContainer <tt>container</tt>}</li> + * <li>{@link #getSource <tt>source</tt>}</li> + * <li>{@link #getInstallerUID <tt>installer_uid</tt>}</li> + * <li>{@link #getTimestamp <tt>timestamp</tt>}</li> + * </ul> + * + * The <tt>instance_urn</tt> can be specified when a {@code ServiceTag} + * object is created, or it can be generated when it is added to + * a {@link RegistrationData} object, or {@link Registry + * system service tag registry}. The <tt>installer_uid</tt> and + * <tt>timestamp</tt> are set when a {@code ServiceTag} object + * is added to a {@link RegistrationData} object, or {@link Registry + * system service tag registry}. + * + * @see <a href="https://sunconnection.sun.com/FAQ/sc_faq.html">Service Tags FAQ</a> + */ +public class ServiceTag { + + private String instanceURN; + private String productName; + private String productVersion; + private String productURN; + private String productParent; + private String productParentURN; + private String productDefinedInstanceID; + private String productVendor; + private String platformArch; + private String container; + private String source; + private int installerUID; + private Date timestamp; + + // Service Tag Field Lengths (defined in sthelper.h) + // Since the constants defined in sthelper.h includes the null-terminated + // character, so minus 1 from the sthelper.h defined values. + private final int MAX_URN_LEN = 256 - 1; + private final int MAX_PRODUCT_NAME_LEN = 256 - 1; + private final int MAX_PRODUCT_VERSION_LEN = 64 - 1; + private final int MAX_PRODUCT_PARENT_LEN = 256 - 1; + private final int MAX_PRODUCT_VENDOR_LEN = 64 - 1; + private final int MAX_PLATFORM_ARCH_LEN = 64 - 1; + private final int MAX_CONTAINER_LEN = 64 - 1; + private final int MAX_SOURCE_LEN = 64 - 1; + + // private constructors + private ServiceTag() { + } + // package private + ServiceTag(String instanceURN, + String productName, + String productVersion, + String productURN, + String productParent, + String productParentURN, + String productDefinedInstanceID, + String productVendor, + String platformArch, + String container, + String source, + int installerUID, + Date timestamp) { + setInstanceURN(instanceURN); + setProductName(productName); + setProductVersion(productVersion); + setProductURN(productURN); + setProductParentURN(productParentURN); + setProductParent(productParent); + setProductDefinedInstanceID(productDefinedInstanceID); + setProductVendor(productVendor); + setPlatformArch(platformArch); + setContainer(container); + setSource(source); + setInstallerUID(installerUID); + setTimestamp(timestamp); + } + + /** + * Creates a service tag object with no <tt>instance_urn</tt>. + * + * @param productName the name of the product. + * @param productVersion the version of the product. + * @param productURN the uniform resource name of the product + * @param productParent the name of the product's parent. + * @param productParentURN the uniform resource name of the product's parent. + * @param productDefinedInstanceID the instance identifier. + * @param productVendor the vendor of the product. + * @param platformArch the operating system architecture. + * @param container the container of the product. + * @param source the source of the product. + * + * @throws IllegalArgumentException if any value of the input fields + * does not conform to the service tag XML schema. + */ + public static ServiceTag newInstance(String productName, + String productVersion, + String productURN, + String productParent, + String productParentURN, + String productDefinedInstanceID, + String productVendor, + String platformArch, + String container, + String source) { + return new ServiceTag("", /* empty instance_urn */ + productName, + productVersion, + productURN, + productParent, + productParentURN, + productDefinedInstanceID, + productVendor, + platformArch, + container, + source, + -1, + null); + } + + /** + * Creates a service tag object with a specified <tt>instance_urn</tt>. + * + * @param instanceURN the uniform resource name of this instance. + * @param productName the name of the product. + * @param productVersion the version of the product. + * @param productURN the uniform resource name of the product + * @param productParent the name of the product's parent. + * @param productParentURN the uniform resource name of the product's parent. + * @param productDefinedInstanceID the instance identifier. + * @param productVendor the vendor of the product. + * @param platformArch the operating system architecture. + * @param container the container of the product. + * @param source the source of the product. + * + * @throws IllegalArgumentException if any value of the input fields + * does not conform to the service tag XML schema. + */ + public static ServiceTag newInstance(String instanceURN, + String productName, + String productVersion, + String productURN, + String productParent, + String productParentURN, + String productDefinedInstanceID, + String productVendor, + String platformArch, + String container, + String source) { + return new ServiceTag(instanceURN, + productName, + productVersion, + productURN, + productParent, + productParentURN, + productDefinedInstanceID, + productVendor, + platformArch, + container, + source, + -1, + null); + } + + // Creates a copy of the ServiceTag instance + // with instance_urn and timestamp initialized + static ServiceTag newInstanceWithUrnTimestamp(ServiceTag st) { + String instanceURN = + (st.getInstanceURN().length() == 0 ? Util.generateURN() : + st.getInstanceURN()); + ServiceTag svcTag = new ServiceTag(instanceURN, + st.getProductName(), + st.getProductVersion(), + st.getProductURN(), + st.getProductParent(), + st.getProductParentURN(), + st.getProductDefinedInstanceID(), + st.getProductVendor(), + st.getPlatformArch(), + st.getContainer(), + st.getSource(), + st.getInstallerUID(), + new Date()); + return svcTag; + } + + /** + * Returns a uniform resource name (URN) in this format: + * <blockquote> + * "<tt>urn:st:<32-char {@link java.util.UUID uuid}></tt>" + * </blockquote> + * @return a URN. + */ + public static String generateInstanceURN() { + return Util.generateURN(); + } + + /** + * Returns the uniform resource name of this service tag instance. + * + * @return the <tt>instance_urn</tt> of this service tag. + */ + public String getInstanceURN() { + return instanceURN; + } + + /** + * Returns the name of the product. + * + * @return the product name. + */ + public String getProductName() { + return productName; + } + + /** + * Returns the version of the product. + * + * @return the product version. + */ + public String getProductVersion() { + return productVersion; + } + + /** + * Returns the uniform resource name of the product. + * + * @return the product URN. + */ + public String getProductURN() { + return productURN; + } + + /** + * Returns the uniform resource name of the product's parent. + * + * @return the product's parent URN. + */ + public String getProductParentURN() { + return productParentURN; + } + + /** + * Returns the name of the product's parent. + * + * @return the product's parent name. + */ + public String getProductParent() { + return productParent; + } + + /** + * Returns the identifier defined for this product instance. + * + * @return the identifier defined for this product instance. + */ + public String getProductDefinedInstanceID() { + return productDefinedInstanceID; + } + + /** + * Returns the vendor of the product. + * + * @return the product vendor. + */ + public String getProductVendor() { + return productVendor; + } + + /** + * Returns the platform architecture on which the product + * is running on. + * + * @return the platform architecture on which the product is running on. + */ + public String getPlatformArch() { + return platformArch; + } + + /** + * Returns the timestamp. This timestamp is set when this service tag + * is added to or updated in a {@code RegistrationData} object or + * the system service tag registry. + * This method may return {@code null}. + * + * @return timestamp when this service tag + * is added to or updated in a {@code RegistrationData} object or + * the system service tag registry, or {@code null}. + */ + public Date getTimestamp() { + if (timestamp != null) { + return (Date) timestamp.clone(); + } else { + return null; + } + } + + + /** + * Returns the container of the product. + * + * @return the container of the product. + */ + public String getContainer() { + return container; + } + + /** + * Returns the source of this service tag. + * + * @return source of this service tag. + */ + public String getSource() { + return source; + } + + /** + * Returns the UID. The UID is set when this service tag + * is added to or updated in the system service tag registry. + * This is platform dependent whose default value is {@code -1}. + * When this service tag is added to a {@code RegistrationData}, + * the UID is not set. + * + * @return the UID of whom this service tag + * is added to or updated in the system service tag registry, + * or {@code -1}. + */ + public int getInstallerUID() { + return installerUID; + } + + // The following setter methods are used to validate the + // input field when constructing a ServiceTag instance + + private void setInstanceURN(String instanceURN) { + if (instanceURN == null) { + throw new NullPointerException("Parameter instanceURN cannot be null"); + } + if (instanceURN.length() > MAX_URN_LEN) { + throw new IllegalArgumentException("instanceURN \"" + instanceURN + + "\" exceeds maximum length " + MAX_URN_LEN); + } + this.instanceURN = instanceURN; + } + + private void setProductName(String productName) { + if (productName == null) { + throw new NullPointerException("Parameter productName cannot be null"); + } + if (productName.length() == 0) { + throw new IllegalArgumentException("product name cannot be empty"); + } + if (productName.length() > MAX_PRODUCT_NAME_LEN) { + throw new IllegalArgumentException("productName \"" + productName + + "\" exceeds maximum length " + MAX_PRODUCT_NAME_LEN); + } + this.productName = productName; + } + + private void setProductVersion(String productVersion) { + if (productVersion == null) { + throw new NullPointerException("Parameter productVersion cannot be null"); + } + + if (productVersion.length() == 0) { + throw new IllegalArgumentException("product version cannot be empty"); + } + if (productVersion.length() > MAX_PRODUCT_VERSION_LEN) { + throw new IllegalArgumentException("productVersion \"" + + productVersion + "\" exceeds maximum length " + + MAX_PRODUCT_VERSION_LEN); + } + this.productVersion = productVersion; + } + + private void setProductURN(String productURN) { + if (productURN == null) { + throw new NullPointerException("Parameter productURN cannot be null"); + } + if (productURN.length() == 0) { + throw new IllegalArgumentException("product URN cannot be empty"); + } + if (productURN.length() > MAX_URN_LEN) { + throw new IllegalArgumentException("productURN \"" + productURN + + "\" exceeds maximum length " + MAX_URN_LEN); + } + this.productURN = productURN; + } + + private void setProductParentURN(String productParentURN) { + if (productParentURN == null) { + throw new NullPointerException("Parameter productParentURN cannot be null"); + } + // optional field - can be empty + if (productParentURN.length() > MAX_URN_LEN) { + throw new IllegalArgumentException("productParentURN \"" + + productParentURN + "\" exceeds maximum length " + + MAX_URN_LEN); + } + this.productParentURN = productParentURN; + } + + private void setProductParent(String productParent) { + if (productParent == null) { + throw new NullPointerException("Parameter productParent cannot be null"); + } + if (productParent.length() == 0) { + throw new IllegalArgumentException("product parent cannot be empty"); + } + if (productParent.length() > MAX_PRODUCT_PARENT_LEN) { + throw new IllegalArgumentException("productParent \"" + + productParent + "\" exceeds maximum length " + + MAX_PRODUCT_PARENT_LEN); + } + this.productParent = productParent; + } + + void setProductDefinedInstanceID(String productDefinedInstanceID) { + if (productDefinedInstanceID == null) { + throw new NullPointerException("Parameter productDefinedInstanceID cannot be null"); + } + if (productDefinedInstanceID.length() > MAX_URN_LEN) { + throw new IllegalArgumentException("productDefinedInstanceID \"" + + productDefinedInstanceID + "\" exceeds maximum length " + + MAX_URN_LEN); + } + // optional field - can be empty + this.productDefinedInstanceID = productDefinedInstanceID; + } + + private void setProductVendor(String productVendor) { + if (productVendor == null) { + throw new NullPointerException("Parameter productVendor cannot be null"); + } + if (productVendor.length() == 0) { + throw new IllegalArgumentException("product vendor cannot be empty"); + } + if (productVendor.length() > MAX_PRODUCT_VENDOR_LEN) { + throw new IllegalArgumentException("productVendor \"" + + productVendor + "\" exceeds maximum length " + + MAX_PRODUCT_VENDOR_LEN); + } + this.productVendor = productVendor; + } + + private void setPlatformArch(String platformArch) { + if (platformArch == null) { + throw new NullPointerException("Parameter platformArch cannot be null"); + } + if (platformArch.length() == 0) { + throw new IllegalArgumentException("platform architecture cannot be empty"); + } + if (platformArch.length() > MAX_PLATFORM_ARCH_LEN) { + throw new IllegalArgumentException("platformArch \"" + + platformArch + "\" exceeds maximum length " + + MAX_PLATFORM_ARCH_LEN); + } + this.platformArch = platformArch; + } + + private void setTimestamp(Date timestamp) { + // can be null + this.timestamp = timestamp; + } + + private void setContainer(String container) { + if (container == null) { + throw new NullPointerException("Parameter container cannot be null"); + } + if (container.length() == 0) { + throw new IllegalArgumentException("container cannot be empty"); + } + if (container.length() > MAX_CONTAINER_LEN) { + throw new IllegalArgumentException("container \"" + + container + "\" exceeds maximum length " + + MAX_CONTAINER_LEN); + } + this.container = container; + } + + private void setSource(String source) { + if (source == null) { + throw new NullPointerException("Parameter source cannot be null"); + } + if (source.length() == 0) { + throw new IllegalArgumentException("source cannot be empty"); + } + if (source.length() > MAX_SOURCE_LEN) { + throw new IllegalArgumentException("source \"" + source + + "\" exceeds maximum length " + MAX_SOURCE_LEN); + } + this.source = source; + } + + private void setInstallerUID(int installerUID) { + this.installerUID = installerUID; + } + + /** + * Compares this service tag to the specified object. + * The result is {@code true} if and only if the argument is + * not {@code null} and is a {@code ServiceTag} object whose + * <tt>instance_urn</tt> is the same as the + * <tt>instance_urn</tt> of this service tag. + * + * @return {@code true} if this service tag is the same as + * the specified object. + */ + @Override + public boolean equals(Object obj) { + if (obj == null || !(obj instanceof ServiceTag)) { + return false; + } + ServiceTag st = (ServiceTag) obj; + if (st == this) { + return true; + } + return st.getInstanceURN().equals(getInstanceURN()); + } + + /** + * Returns the hash code value for this service tag. + * @return the hash code value for this service tag. + */ + @Override + public int hashCode() { + int hash = 7; + hash = 19 * hash + (this.instanceURN != null ? this.instanceURN.hashCode() : 0); + return hash; + } + + /** + * Returns the string representation of this service tag. + * The format is implementation specific. + * + * @return the string representation of this service tag. + */ + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(ST_NODE_INSTANCE_URN).append("=").append(instanceURN).append("\n"); + sb.append(ST_NODE_PRODUCT_NAME).append("=").append(productName).append("\n"); + sb.append(ST_NODE_PRODUCT_VERSION).append("=").append(productVersion).append("\n"); + sb.append(ST_NODE_PRODUCT_URN).append("=").append(productURN).append("\n"); + sb.append(ST_NODE_PRODUCT_PARENT_URN).append("=").append(productParentURN).append("\n"); + sb.append(ST_NODE_PRODUCT_PARENT).append("=").append(productParent).append("\n"); + sb.append(ST_NODE_PRODUCT_DEFINED_INST_ID).append("=").append(productDefinedInstanceID).append("\n"); + sb.append(ST_NODE_PRODUCT_VENDOR).append("=").append(productVendor).append("\n"); + sb.append(ST_NODE_PLATFORM_ARCH).append("=").append(platformArch).append("\n"); + sb.append(ST_NODE_TIMESTAMP).append("=").append(Util.formatTimestamp(timestamp)).append("\n"); + sb.append(ST_NODE_CONTAINER).append("=").append(container).append("\n"); + sb.append(ST_NODE_SOURCE).append("=").append(source).append("\n"); + sb.append(ST_NODE_INSTALLER_UID).append("=").append(String.valueOf(installerUID)).append("\n"); + return sb.toString(); + } + + + /** + * Returns the {@link ServiceTag} instance for the running Java + * platform. The {@link ServiceTag#setSource source} field + * of the {@code ServiceTag} will be set to the given {@code source}. + * This method will return {@code null} if there is no service tag + * for the running Java platform. + * <p> + * This method is designed for Sun software that bundles the JDK + * or the JRE to use. It is recommended that the {@code source} + * string contains information about the bundling software + * such as the name and the version of the software bundle, + * for example, + * <blockquote> + * <tt>NetBeans IDE 6.0 with JDK 6 Update 5 Bundle</tt> + * </blockquote> + * in a NetBeans/JDK bundle. + * <p> + * At the first time to call this method the application + * is required to have the write permission to the installed + * directory of this running JDK or JRE instance. + * + * @param source the source that bundles the JDK or the JRE. + * @return a {@code ServiceTag} object for the Java platform, + * or {@code null} if not supported. + * @throws IOException if an error occurs in this operation. + */ + public static ServiceTag getJavaServiceTag(String source) throws IOException { + return Installer.getJavaServiceTag(source); + } + +} diff --git a/desktop/source/registration/com/sun/star/servicetag/SolarisServiceTag.java b/desktop/source/registration/com/sun/star/servicetag/SolarisServiceTag.java new file mode 100644 index 000000000000..245b993b086e --- /dev/null +++ b/desktop/source/registration/com/sun/star/servicetag/SolarisServiceTag.java @@ -0,0 +1,68 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SolarisServiceTag.java,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.servicetag; + +import java.io.IOException; +import java.util.Set; + +/** + * Utility class to obtain the service tag for the Solaris Operating System. + */ +class SolarisServiceTag { + private final static String[] SolarisProductURNs = new String[] { + "urn:uuid:a7a38948-2bd5-11d6-98ce-9d3ac1c0cfd7", /* Solaris 8 */ + "urn:uuid:4f82caac-36f3-11d6-866b-85f428ef944e", /* Solaris 9 */ + "urn:uuid:a19de03b-48bc-11d9-9607-080020a9ed93", /* Solaris 9 sparc */ + "urn:uuid:4c35c45b-4955-11d9-9607-080020a9ed93", /* Solaris 9 x86 */ + "urn:uuid:5005588c-36f3-11d6-9cec-fc96f718e113", /* Solaris 10 */ + "urn:uuid:6df19e63-7ef5-11db-a4bd-080020a9ed93" /* Solaris 11 */ + }; + + /** + * Returns null if not found. + * + * There is only one service tag for the operating system. + */ + static ServiceTag getServiceTag() throws IOException { + if (Registry.isSupported()) { + Registry streg = Registry.getSystemRegistry(); + for (String parentURN : SolarisProductURNs) { + Set<ServiceTag> instances = streg.findServiceTags(parentURN); + for (ServiceTag st : instances) { + // there should have only one service tag for the OS + return st; + } + } + } + return null; + } +} diff --git a/desktop/source/registration/com/sun/star/servicetag/SolarisSystemEnvironment.java b/desktop/source/registration/com/sun/star/servicetag/SolarisSystemEnvironment.java new file mode 100644 index 000000000000..1ce5f5697bcb --- /dev/null +++ b/desktop/source/registration/com/sun/star/servicetag/SolarisSystemEnvironment.java @@ -0,0 +1,159 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SolarisSystemEnvironment.java,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.servicetag; + +// The Service Tags team maintains the latest version of the implementation +// for system environment data collection. JDK will include a copy of +// the most recent released version for a JDK release. We rename +// the package to com.sun.servicetag so that the Sun Connection +// product always uses the latest version from the com.sun.scn.servicetags +// package. JDK and users of the com.sun.servicetag API +// (e.g. NetBeans and SunStudio) will use the version in JDK. + +import java.io.*; + +/** + * Solaris implementation of the SystemEnvironment class. + */ +class SolarisSystemEnvironment extends SystemEnvironment { + SolarisSystemEnvironment() { + setHostId(getCommandOutput("/usr/bin/hostid")); + setSystemModel(getCommandOutput("/usr/bin/uname", "-i")); + setSystemManufacturer(getSolarisSystemManufacturer()); + setCpuManufacturer(getSolarisCpuManufacturer()); + setSerialNumber(getSolarisSN()); + } + + /** + * Tries to obtain the cpu manufacturer. + * @return The cpu manufacturer (an empty string if not found or an error occurred) + */ + private String getSolarisCpuManufacturer() { + // not fully accurate, this could be another manufacturer (fujitsu for example) + if ("sparc".equalsIgnoreCase(System.getProperty("os.arch"))) { + return "Sun Microsystems, Inc"; + } + + // if we're here, then we'll try smbios (type 3) + return getSmbiosData("3", "Manufacturer: "); + } + + /** + * Tries to obtain the system manufacturer. + * @return The system manufacturer (an empty string if not found or an error occurred) + */ + private String getSolarisSystemManufacturer() { + // not fully accurate, this could be another manufacturer (fujitsu for example) + if ("sparc".equalsIgnoreCase(System.getProperty("os.arch"))) { + return "Sun Microsystems, Inc"; + } + + // if we're here, then we'll try smbios (type 1) + return getSmbiosData("1", "Manufacturer: "); + } + + /** + * Tries to obtain the serial number. + * @return The serial number (empty string if not found or an error occurred) + */ + private String getSolarisSN() { + // try to read from the psn file if it exists + String tmp = getFileContent("/var/run/psn"); + if (tmp.length() > 0) { + return tmp.trim(); + } + + // if we're here, then we'll try sneep + String tmpSN = getSneepSN(); + if (tmpSN.length() > 0) { + return tmpSN; + } + + // if we're here, then we'll try smbios (type 1) + tmpSN = getSmbiosData("1", "Serial Number: "); + if (tmpSN.length() > 0) { + return tmpSN; + } + + // if we're here, then we'll try smbios (type 3) + tmpSN = getSmbiosData("3", "Serial Number: "); + if (tmpSN.length() > 0) { + return tmpSN; + } + + // give up and return + return ""; + } + + // Sample smbios output segment: + // ID SIZE TYPE + // 1 150 SMB_TYPE_SYSTEM (system information) + // + // Manufacturer: Sun Microsystems + // Product: Sun Fire X4600 + // Version: To Be Filled By O.E.M. + // Serial Number: 00:14:4F:45:0C:2A + private String getSmbiosData(String type, String target) { + String output = getCommandOutput("/usr/sbin/smbios", "-t", type); + for (String s : output.split("\n")) { + if (s.contains(target)) { + int indx = s.indexOf(target) + target.length(); + if (indx < s.length()) { + String tmp = s.substring(indx).trim(); + String lowerCaseStr = tmp.toLowerCase(); + if (!lowerCaseStr.startsWith("not available") + && !lowerCaseStr.startsWith("to be filled by o.e.m")) { + return tmp; + } + } + } + } + + return ""; + } + + private String getSneepSN() { + String basedir = getCommandOutput("pkgparam","SUNWsneep","BASEDIR"); + File f = new File(basedir + "/bin/sneep"); + if (f.exists()) { + String sneepSN = getCommandOutput(basedir + "/bin/sneep"); + if (sneepSN.equalsIgnoreCase("unknown")) { + return ""; + } else { + return sneepSN; + } + } else { + return ""; + } + } + +} diff --git a/desktop/source/registration/com/sun/star/servicetag/SunConnection.java b/desktop/source/registration/com/sun/star/servicetag/SunConnection.java new file mode 100644 index 000000000000..4a3d2ee9722f --- /dev/null +++ b/desktop/source/registration/com/sun/star/servicetag/SunConnection.java @@ -0,0 +1,296 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SunConnection.java,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.servicetag; + +import java.io.*; +import java.net.URISyntaxException; +import java.net.URL; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.io.OutputStreamWriter; +import java.util.Locale; +import javax.net.ssl.HttpsURLConnection; + +/** + * Sun Connection Class for Product Registration. + * + * Registration Web Application Interface + * 1) POST the product registry to the output stream of the registration + * relay service. + * 2) Open the webapp URL from a browser with the following parameters: + * registry-urn + * product=jdk + * locale=<locale-lang> + * + * @see https://sn-tools.central.sun.com/twiki/pub/ServiceTags/RegistrationRelayService/ + * + */ +class SunConnection { + + private static String JDK_REGISTRATION_URL = + "https://inventory.sun.com/RegistrationWeb/register"; + private static String SANDBOX_TESTING_URL = + "https://connection-tst.sun.com/RegistrationWeb/register"; + + // System properties for testing + private static String SVCTAG_REGISTER_TESTING = "servicetag.register.testing"; + private static String SVCTAG_REGISTRATION_URL = "servicetag.registration.url"; + private static String SVCTAG_CONNECTION_TIMEOUT = "servicetag.connection.timeout"; + + private SunConnection() { + } + + /** + * Returns a URL for JDK registration interfacing with the Sun Connection + * registration relay service in this form: + * <registration-url>/<registry_urn>?product=jdk&locale=<locale-lang> + * + * The <registration-url> can be overridden by an environment + * variable or a system property. + * + * 1) "servicetag.register.testing" system property to switch to the + * Sun Connection registration sandbox testing. + * 2) "servicetag.registration.url" system property to override + * the URL + * 3) Default production URL + * + */ + static URL getRegistrationURL(String registrationURN) { + String url = System.getProperty(SVCTAG_REGISTRATION_URL); + if (url == null) { + if (System.getProperty(SVCTAG_REGISTER_TESTING) != null) { + url = SANDBOX_TESTING_URL; + } else { + url = JDK_REGISTRATION_URL; + } + } + + // trim whitespaces + url = url.trim(); + if (url.length() == 0) { + throw new InternalError("Empty registration url set"); + } + + // Add the registry_urn in the URL's query + String registerURL = rewriteURL(url, registrationURN); + try { + return new URL(registerURL); + } catch (MalformedURLException ex) { + // should never reach here + InternalError x = + new InternalError(ex.getMessage()); + x.initCause(ex); + throw x; + } + } + + private static String rewriteURL(String url, String registryURN) { + StringBuilder sb = new StringBuilder(url.trim()); + int len = sb.length(); + if (sb.charAt(len-1) != '/') { + sb.append('/'); + } + sb.append(registryURN); + sb.append("?"); + sb.append("product=jdk"); + sb.append("&"); + sb.append("locale=").append(Locale.getDefault().getLanguage()); + return sb.toString(); + } + + /** + * Registers all products in the given product registry. If it fails + * to post the service tag registry, open the browser with the offline + * registration page. + * + * @param regData registration data to be posted to the Sun Connection + * for registration. + * + * @throws IOException if I/O error occurs in this operation + */ + public static void register(RegistrationData regData) throws IOException { + // Gets the URL for SunConnection registration relay service + URL url = getRegistrationURL(regData.getRegistrationURN()); + + // Post the Product Registry to Sun Connection + boolean succeed = postRegistrationData(url, regData); + if (succeed) { + // service tags posted successfully + // now prompt for registration + openBrowser(url); + } else { + // open browser with the offline registration page + openOfflineRegisterPage(); + } + } + + /** + * Opens a browser for JDK product registration. + * @param url Registration Webapp URL + */ + private static void openBrowser(URL url) throws IOException { + if (!BrowserSupport.isSupported()) { + if (Util.isVerbose()) { + System.out.println("Browser is not supported"); + } + return; + } + + try { + BrowserSupport.browse(url.toURI()); + } catch (URISyntaxException ex) { + InternalError x = new InternalError("Error in registering: " + ex.getMessage()); + x.initCause(ex); + throw x; + } catch (IllegalArgumentException ex) { + if (Util.isVerbose()) { + ex.printStackTrace(); + } + } catch (UnsupportedOperationException ex) { + // ignore if not supported + if (Util.isVerbose()) { + ex.printStackTrace(); + } + } + } + + /** + * POST service tag registry to Sun Connection + * @param loc the URL of the webapp to handle the POST request + * @param streg the Service Tag registry + * @return true if posting succeeds; otherwise, false. + */ + private static boolean postRegistrationData(URL url, + RegistrationData registration) { + try { + HttpsURLConnection con = (HttpsURLConnection) url.openConnection(); + con.setDoInput(true); + con.setDoOutput(true); + con.setUseCaches(false); + con.setAllowUserInteraction(false); + + // default 10 seconds timeout + String timeout = System.getProperty(SVCTAG_CONNECTION_TIMEOUT, "10"); + con.setConnectTimeout(Util.getIntValue(timeout) * 1000); + + if (Util.isVerbose()) { + System.out.println("Connecting to post registration data at " + url); + } + + con.setRequestMethod("POST"); + con.setRequestProperty("Content-Type", "text/xml;charset=\"utf-8\""); + con.connect(); + + OutputStream out = con.getOutputStream(); + registration.storeToXML(out); + out.flush(); + out.close(); + + int returnCode = con.getResponseCode(); + if (Util.isVerbose()) { + System.out.println("POST return status = " + returnCode); + printReturnData(con, returnCode); + } + return (returnCode == HttpURLConnection.HTTP_OK); + } catch (MalformedURLException me) { + // should never reach here + InternalError x = new InternalError("Error in registering: " + me.getMessage()); + x.initCause(me); + throw x; + } catch (Exception ioe) { + // SocketTimeoutException, IOException or UnknownHostException + if (Util.isVerbose()) { + ioe.printStackTrace(); + } + return false; + } + } + + /** + * Opens the offline registratioin page in the browser. + * + */ + private static void openOfflineRegisterPage() + throws IOException { + if (!BrowserSupport.isSupported()) { + if (Util.isVerbose()) { + System.out.println("Browser is not supported"); + } + return; + } + + File registerPage = Installer.getRegistrationHtmlPage(); + try { + BrowserSupport.browse(registerPage.toURI()); + } catch (FileNotFoundException ex) { + // should never reach here + InternalError x = + new InternalError("Error in launching " + registerPage + ": " + ex.getMessage()); + x.initCause(ex); + throw x; + } catch (IllegalArgumentException ex) { + if (Util.isVerbose()) { + ex.printStackTrace(); + } + } catch (UnsupportedOperationException ex) { + // ignore if not supported + if (Util.isVerbose()) { + ex.printStackTrace(); + } + } + } + + private static void printReturnData(HttpURLConnection con, int returnCode) + throws IOException { + BufferedReader reader = null; + try { + if (returnCode < 400) { + reader = new BufferedReader( + new InputStreamReader(con.getInputStream())); + } else { + reader = new BufferedReader( + new InputStreamReader(con.getErrorStream())); + } + StringBuilder sb = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + sb.append(line).append("\n"); + } + System.out.println("Response is : "); + System.out.println(sb.toString()); + } finally { + if (reader != null) { + reader.close(); + } + } + } +} diff --git a/desktop/source/registration/com/sun/star/servicetag/SysnetRegistryHelper.java b/desktop/source/registration/com/sun/star/servicetag/SysnetRegistryHelper.java new file mode 100644 index 000000000000..d50104e827ed --- /dev/null +++ b/desktop/source/registration/com/sun/star/servicetag/SysnetRegistryHelper.java @@ -0,0 +1,380 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SysnetRegistryHelper.java,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.servicetag; + +import java.io.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Properties; +import java.util.Set; + +import static com.sun.star.servicetag.Util.*; +import static com.sun.star.servicetag.RegistrationDocument.*; + +/** + * Class containing additional methods that are not yet + * in the JDK Registry class. Note that all methods in this class + * will be superceeded by the JDK classes. + */ +public class SysnetRegistryHelper { + + private static final String STCLIENT_SOLARIS = "/usr/bin/stclient"; + private static final String STCLIENT_LINUX = "/opt/sun/servicetag/bin/stclient"; + // stclient exit value (see sthelper.h) + private static final int ST_ERR_NOT_AUTH = 245; + private static final int ST_ERR_REC_NOT_FOUND = 225; + + // The stclient output has to be an exported interface + private static final String INSTANCE_URN_OPEN_ELEMENT = "<instance_urn>"; + private static final String INSTANCE_URN_CLOSE_ELEMENT = "</instance_urn>"; + private static final String REGISTRY_URN = "<registry urn=\""; + private static final String INSTANCE_URN_DESC = "Product instance URN="; + private static boolean initialized = false; + private static boolean supportsHelperClass = true; // default + private static File stclient = null; + private static String stclientPath = null; + + // System properties for testing + private static String SVCTAG_STCLIENT_CMD = "servicetag.stclient.cmd"; + private static String SVCTAG_STHELPER_SUPPORTED = "servicetag.sthelper.supported"; + + private synchronized static String getSTclient() { + if (!initialized) { + // the system property always overrides the default setting + if (System.getProperty(SVCTAG_STHELPER_SUPPORTED) != null) { + supportsHelperClass = Boolean.getBoolean(SVCTAG_STHELPER_SUPPORTED); + } + + // This is only used for testing + stclientPath = System.getProperty(SVCTAG_STCLIENT_CMD); + if (stclientPath != null) { + return stclientPath; + } + + // Initialization to determine the platform's stclient pathname + String os = System.getProperty("os.name"); + if (os.equals("SunOS")) { + stclient = new File(STCLIENT_SOLARIS); + } else if (os.equals("Linux")) { + stclient = new File(STCLIENT_LINUX); + } else if (os.startsWith("Windows")) { + stclient = getWindowsStClientFile(); + } else { + if (isVerbose()) { + System.out.println("Running on non-Sun JDK"); + } + } + initialized = true; + } + + // com.sun.servicetag package has to be compiled with JDK 5 as well + // JDK 5 doesn't support the File.canExecute() method. + // Risk not checking isExecute() for the stclient command is very low. + + if (stclientPath == null && stclient != null && stclient.exists()) { + stclientPath = stclient.getAbsolutePath(); + } + return stclientPath; + } + + private static List<String> getCommandList() { + // Set up the arguments to call stclient + List<String> command = new ArrayList<String>(); + if (System.getProperty(SVCTAG_STCLIENT_CMD) != null) { + // This is for jtreg testing use. This will be set to something + // like: + // $JAVA_HOME/bin/java -cp $TEST_DIR \ + // -Dstclient.registry.path=$TEST_DIR/registry.xml \ + // SvcTagClient + // + // On Windows, the JAVA_HOME and TEST_DIR path could contain + // space e.g. c:\Program Files\Java\jdk1.6.0_05\bin\java. + // The SVCTAG_STCLIENT_CMD must be set with a list of + // space-separated parameters. If a parameter contains spaces, + // it must be quoted with '"'. + + String cmd = getSTclient(); + int len = cmd.length(); + int i = 0; + while (i < len) { + char separator = ' '; + if (cmd.charAt(i) == '"') { + separator = '"'; + i++; + } + // look for the separator or matched the closing '"' + int j; + for (j = i+1; j < len; j++) { + if (cmd.charAt(j) == separator) { + break; + } + } + + if (i == j-1) { + // add an empty parameter + command.add("\"\""); + } else { + // double quotes and space are not included + command.add(cmd.substring(i,j)); + } + + // skip spaces + for (i = j+1; i < len; i++) { + if (!Character.isSpaceChar(cmd.charAt(i))) { + break; + } + } + } + if (isVerbose()) { + System.out.println("Command list:"); + for (String s : command) { + System.out.println(s); + } + } + } else { + command.add(getSTclient()); + } + return command; + } + + // Returns null if the service tag record not found; + // or throw UnauthorizedAccessException or IOException + // based on the exitValue. + private static ServiceTag checkReturnError(int exitValue, + String output, + ServiceTag st) throws IOException { + switch (exitValue) { + case ST_ERR_REC_NOT_FOUND: + return null; + case ST_ERR_NOT_AUTH: + if (st != null) { + throw new UnauthorizedAccessException( + "Not authorized to access " + st.getInstanceURN() + + " installer_uid=" + st.getInstallerUID()); + } else { + throw new UnauthorizedAccessException( + "Not authorized:" + output); + } + default: + throw new IOException("stclient exits with error" + + " (" + exitValue + ")\n" + output); + } + } + + /** + * Returns a {@code ServiceTag} object of the given <tt>instance_urn</tt> + * in this registry. + * + * @param instanceURN the <tt>instance_urn</tt> of the service tag + * @return a {@code ServiceTag} object of the given <tt>instance_urn</tt> + * in this registry; or {@code null} if not found. + * + * @throws java.io.IOException if an I/O error occurs in this operation. + */ + private static ServiceTag getServiceTag(String instanceURN) throws IOException { + if (instanceURN == null) { + throw new NullPointerException("instanceURN is null"); + } + + List<String> command = getCommandList(); + command.add("-g"); + command.add("-i"); + command.add(instanceURN); + + ProcessBuilder pb = new ProcessBuilder(command); + Process p = pb.start(); + String output = commandOutput(p); + if (isVerbose()) { + System.out.println("Output from stclient -g command:"); + System.out.println(output); + } + if (p.exitValue() == 0) { + return parseServiceTag(output); + } else { + return checkReturnError(p.exitValue(), output, null); + } + } + + private static ServiceTag parseServiceTag(String output) throws IOException { + BufferedReader in = null; + try { + Properties props = new Properties(); + // parse the service tag output from stclient + in = new BufferedReader(new StringReader(output)); + String line = null; + while ((line = in.readLine()) != null) { + if ((line = line.trim()).length() > 0) { + String[] ss = line.trim().split("=", 2); + if (ss.length == 2) { + props.setProperty(ss[0].trim(), ss[1].trim()); + } else { + props.setProperty(ss[0].trim(), ""); + } + } + } + + String urn = props.getProperty(ST_NODE_INSTANCE_URN); + String productName = props.getProperty(ST_NODE_PRODUCT_NAME); + String productVersion = props.getProperty(ST_NODE_PRODUCT_VERSION); + String productURN = props.getProperty(ST_NODE_PRODUCT_URN); + String productParent = props.getProperty(ST_NODE_PRODUCT_PARENT); + String productParentURN = props.getProperty(ST_NODE_PRODUCT_PARENT_URN); + String productDefinedInstanceID = + props.getProperty(ST_NODE_PRODUCT_DEFINED_INST_ID); + String productVendor = props.getProperty(ST_NODE_PRODUCT_VENDOR); + String platformArch = props.getProperty(ST_NODE_PLATFORM_ARCH); + String container = props.getProperty(ST_NODE_CONTAINER); + String source = props.getProperty(ST_NODE_SOURCE); + int installerUID = + Util.getIntValue(props.getProperty(ST_NODE_INSTALLER_UID)); + Date timestamp = + Util.parseTimestamp(props.getProperty(ST_NODE_TIMESTAMP)); + + return new ServiceTag(urn, + productName, + productVersion, + productURN, + productParent, + productParentURN, + productDefinedInstanceID, + productVendor, + platformArch, + container, + source, + installerUID, + timestamp); + } finally { + if (in != null) { + in.close(); + } + } + + } + + /** + * Returns the urn of this registry. + * + * @return a {@code String} for the urn of this registry. + * + * @throws java.io.IOException if an I/O error occurs in this operation. + */ + // Once JDK makes this method available, we'll deprecate this method + // @deprecated Use the JDK version when available. + public static String getRegistryURN() throws IOException { + List<String> command = getCommandList(); + command.add("-x"); + + BufferedReader in = null; + try { + ProcessBuilder pb = new ProcessBuilder(command); + Process p = pb.start(); + String output = commandOutput(p); + + String registryURN = null; + if (p.exitValue() == 0) { + // parse the service tag output from stclient + in = new BufferedReader(new StringReader(output)); + String line = null; + while ((line = in.readLine()) != null) { + String s = line.trim(); + if (s.indexOf(REGISTRY_URN) != -1) { + s = s.substring(s.indexOf(REGISTRY_URN) + + REGISTRY_URN.length()); + if (s.indexOf("\"") != -1) { + s = s.substring(0, s.indexOf("\"")); + registryURN = s; + break; + } + } + } + } else { + checkReturnError(p.exitValue(), output, null); + } + return registryURN; + } finally { + if (in != null) { + in.close(); + } + } + } + + /** + * Returns all the service tags in this registry. + * + * @return a {@code Set} of {@code ServiceTag} objects + * in this registry. + * + * @throws java.io.IOException if an I/O error occurs in this operation. + */ + // Once JDK makes this method available, we'll deprecate this method + // @deprecated Use the JDK version when available. + public static Set<ServiceTag> getServiceTags() throws IOException { + List<String> command = getCommandList(); + command.add("-x"); + + BufferedReader in = null; + try { + ProcessBuilder pb = new ProcessBuilder(command); + Process p = pb.start(); + String output = commandOutput(p); + + Set<ServiceTag> instances = new HashSet<ServiceTag>(); + if (p.exitValue() == 0) { + // parse the service tag output from stclient + in = new BufferedReader(new StringReader(output)); + String line = null; + while ((line = in.readLine()) != null) { + String s = line.trim(); + if (s.indexOf(INSTANCE_URN_OPEN_ELEMENT) != -1 + && s.indexOf(INSTANCE_URN_CLOSE_ELEMENT) != -1) { + s = s.substring(s.indexOf(INSTANCE_URN_OPEN_ELEMENT) + + INSTANCE_URN_OPEN_ELEMENT.length(), + s.indexOf(INSTANCE_URN_CLOSE_ELEMENT)); + try { + instances.add(getServiceTag(s)); + } catch (Exception e) { + } + } + } + } else { + checkReturnError(p.exitValue(), output, null); + } + return instances; + } finally { + if (in != null) { + in.close(); + } + } + } +} diff --git a/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java b/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java new file mode 100644 index 000000000000..e5b9e0e3b4fe --- /dev/null +++ b/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java @@ -0,0 +1,341 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SystemEnvironment.java,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.servicetag; + +// The Service Tags team maintains the latest version of the implementation +// for system environment data collection. JDK will include a copy of +// the most recent released version for a JDK release. We rename +// the package to com.sun.servicetag so that the Sun Connection +// product always uses the latest version from the com.sun.scn.servicetags +// package. JDK and users of the com.sun.servicetag API +// (e.g. NetBeans and SunStudio) will use the version in JDK. + +import java.io.*; +import java.net.InetAddress; +import java.net.UnknownHostException; + +/** + * SystemEnvironment class collects the environment data with the + * best effort from the underlying platform. + */ +public class SystemEnvironment { + private String hostname; + private String hostId; + private String osName; + private String osVersion; + private String osArchitecture; + private String systemModel; + private String systemManufacturer; + private String cpuManufacturer; + private String serialNumber; + private static SystemEnvironment sysEnv = null; + + public static synchronized SystemEnvironment getSystemEnvironment() { + if (sysEnv == null) { + String os = System.getProperty("os.name"); + if (os.equals("SunOS")) { + sysEnv = new SolarisSystemEnvironment(); + } else if (os.equals("Linux")) { + sysEnv = new LinuxSystemEnvironment(); + } else if (os.startsWith("Windows")) { + sysEnv = new WindowsSystemEnvironment(); + } else { + sysEnv = new SystemEnvironment(); + } + } + return sysEnv; + } + + // package-private + SystemEnvironment() { + try { + this.hostname = InetAddress.getLocalHost().getHostName(); + } catch (UnknownHostException ex) { + this.hostname = "Unknown host"; + } + this.hostId = ""; + this.osName = System.getProperty("os.name"); + this.osVersion = System.getProperty("os.version"); + this.osArchitecture = System.getProperty("os.arch"); + this.systemModel = ""; + this.systemManufacturer = ""; + this.cpuManufacturer = ""; + this.serialNumber = ""; + } + + + /** + * Sets the hostname. + * @param hostname The hostname to set. + */ + public void setHostname(String hostname) { + this.hostname = hostname; + } + + /** + * Sets the OS name. + * @param osName The osName to set. + */ + public void setOsName(String osName) { + this.osName = osName; + } + + /** + * Sets the OS version. + * @param osVersion The osVersion to set. + */ + public void setOsVersion(String osVersion) { + this.osVersion = osVersion; + } + + /** + * Sets the OS architecture. + * @param osArchitecture The osArchitecture to set. + */ + public void setOsArchitecture(String osArchitecture) { + this.osArchitecture = osArchitecture; + } + + /** + * Sets the system model. + * @param systemModel The systemModel to set. + */ + public void setSystemModel(String systemModel) { + this.systemModel = systemModel; + } + + /** + * Sets the system manufacturer. + * @param systemManufacturer The systemManufacturer to set. + */ + public void setSystemManufacturer(String systemManufacturer) { + this.systemManufacturer = systemManufacturer; + } + + /** + * Sets the cpu manufacturer. + * @param cpuManufacturer The cpuManufacturer to set. + */ + public void setCpuManufacturer(String cpuManufacturer) { + this.cpuManufacturer = cpuManufacturer; + } + + /** + * Sets the serial number. + * @param serialNumber The serialNumber to set. + */ + public void setSerialNumber(String serialNumber) { + this.serialNumber = serialNumber; + } + + /** + * Sets the hostid. Truncates to a max length of 16 chars. + * @param hostId The hostid to set. + */ + public void setHostId(String hostId) { + if (hostId == null || hostId.equals("null")) { + hostId = ""; + } + if (hostId.length() > 16) { + hostId = hostId.substring(0,16); + } + this.hostId = hostId; + } + + /** + * Returns the hostname. + * @return The hostname. + */ + public String getHostname() { + return hostname; + } + + /** + * Returns the osName. + * @return The osName. + */ + public String getOsName() { + return osName; + } + + /** + * Returns the osVersion. + * @return The osVersion. + */ + public String getOsVersion() { + return osVersion; + } + + /** + * Returns the osArchitecture. + * @return The osArchitecture. + */ + public String getOsArchitecture() { + return osArchitecture; + } + + /** + * Returns the systemModel. + * @return The systemModel. + */ + public String getSystemModel() { + return systemModel; + } + + /** + * Returns the systemManufacturer. + * @return The systemManufacturer. + */ + public String getSystemManufacturer() { + return systemManufacturer; + } + + /** + * Returns the serialNumber. + * @return The serialNumber. + */ + public String getSerialNumber() { + return serialNumber; + } + + /** + * Returns the hostId. + * @return The hostId. + */ + public String getHostId() { + return hostId; + } + + /** + * Returns the cpuManufacturer. + * @return The cpuManufacturer. + */ + public String getCpuManufacturer() { + return cpuManufacturer; + } + + protected String getCommandOutput(String... command) { + StringBuilder sb = new StringBuilder(); + BufferedReader br = null; + Process p = null; + try { + ProcessBuilder pb = new ProcessBuilder(command); + p = pb.start(); + p.waitFor(); + + if (p.exitValue() == 0) { + br = new BufferedReader(new InputStreamReader(p.getInputStream())); + String line = null; + while ((line = br.readLine()) != null) { + line = line.trim(); + if (line.length() > 0) { + if (sb.length() > 0) { + sb.append("\n"); + } + sb.append(line); + } + } + } + return sb.toString(); + } catch (InterruptedException ie) { + // in case the command hangs + if (p != null) { + p.destroy(); + } + return ""; + } catch (Exception e) { + // ignore exception + return ""; + } finally { + if (p != null) { + try { + p.getErrorStream().close(); + } catch (IOException e) { + // ignore + } + try { + p.getInputStream().close(); + } catch (IOException e) { + // ignore + } + try { + p.getOutputStream().close(); + } catch (IOException e) { + // ignore + } + p = null; + } + if (br != null) { + try { + br.close(); + } catch (IOException e) { + // ignore + } + } + } + } + + protected String getFileContent(String filename) { + File f = new File(filename); + if (!f.exists()) { + return ""; + } + + StringBuilder sb = new StringBuilder(); + BufferedReader br = null; + try { + br = new BufferedReader(new FileReader(f)); + String line = null; + while ((line = br.readLine()) != null) { + line = line.trim(); + if (line.length() > 0) { + if (sb.length() > 0) { + sb.append("\n"); + } + sb.append(line); + } + } + return sb.toString(); + } catch (Exception e) { + // ignore exception + return ""; + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException e) { + // ignore + } + } + } + } +} diff --git a/sj2/stardiv/applet/LiveConnectable.java b/desktop/source/registration/com/sun/star/servicetag/UnauthorizedAccessException.java index 36604358c19f..785cb35777ae 100644 --- a/sj2/stardiv/applet/LiveConnectable.java +++ b/desktop/source/registration/com/sun/star/servicetag/UnauthorizedAccessException.java @@ -6,8 +6,9 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: LiveConnectable.java,v $ - * $Revision: 1.3 $ + * $RCSfile: UnauthorizedAccessException.java,v $ + * + * $Revision: 1.2 $ * * This file is part of OpenOffice.org. * @@ -28,18 +29,31 @@ * ************************************************************************/ -package stardiv.applet; +package com.sun.star.servicetag; /** - * LiveConnectable interface . - * - * @version 1.0, 21/04/98 - * @author Markus Meyer + * Thrown if the user is not authorized to + * {@link Registry#updateServiceTag update} or + * {@link Registry#removeServiceTag remove} + * a service tag from a {@link Registry}. */ +public class UnauthorizedAccessException extends RuntimeException { -public interface LiveConnectable -{ - public Object getJavaScriptJSObjectWindow(); -} + /** + * Constructs an <code>UnauthorizedAccessException</code> object + * without detail message. + */ + public UnauthorizedAccessException() { + } + /** + * Constructs an <code>UnauthorizedAccessException</code> object + * with the specified detail message. + * + * @param msg the detail message. + */ + public UnauthorizedAccessException(String msg) { + super(msg); + } +} diff --git a/desktop/source/registration/com/sun/star/servicetag/Util.java b/desktop/source/registration/com/sun/star/servicetag/Util.java new file mode 100644 index 000000000000..55fa097297e6 --- /dev/null +++ b/desktop/source/registration/com/sun/star/servicetag/Util.java @@ -0,0 +1,297 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: Util.java,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.servicetag; + +import java.io.*; +import java.util.Date; +import java.text.SimpleDateFormat; +import java.text.ParseException; +import java.util.TimeZone; +import java.util.UUID; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +// Utility class for com.sun.star.servicetag package +class Util { + private static boolean verbose = (System.getProperty("servicetag.verbose") != null); + private static String jrepath = null; + + // for debugging and tracing + static boolean isVerbose() { + return verbose; + } + + /** + * Gets the pathname of JRE in the running platform + * This can be a JDK or JRE. + */ + static synchronized String getJrePath() { + if (jrepath == null) { + // Determine the JRE path by checking the existence of + // <HOME>/jre/lib and <HOME>/lib. + String javaHome = System.getProperty("java.home"); + jrepath = javaHome + File.separator + "jre"; + File f = new File(jrepath, "lib"); + if (!f.exists()) { + // java.home usually points to the JRE path + jrepath = javaHome; + } + } + return jrepath; + } + + /** + * Tests if the running platform is a JDK. + */ + static boolean isJdk() { + // <HOME>/jre exists which implies it's a JDK + return getJrePath().endsWith(File.separator + "jre"); + } + + /** + * Generates the URN string of "urn:st" namespace + */ + static String generateURN() { + return "urn:st:" + UUID.randomUUID().toString(); + } + + static int getIntValue(String value) { + try { + return Integer.parseInt(value); + } catch (NumberFormatException e) { + throw new IllegalArgumentException("\"" + value + "\"" + + " expected to be an integer"); + } + } + + /** + * Formats the Date into a timestamp string in YYYY-MM-dd HH:mm:ss GMT. + * @param timestamp Date + * @return a string representation of the timestamp + * in the YYYY-MM-dd HH:mm:ss GMT format. + */ + static String formatTimestamp(Date timestamp) { + if (timestamp == null) { + return "[No timestamp]"; + } + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); + df.setTimeZone(TimeZone.getTimeZone("GMT")); + return df.format(timestamp); + } + + /** + * Parses a timestamp string in YYYY-MM-dd HH:mm:ss GMT format. + * @param timestamp Timestamp in the YYYY-MM-dd HH:mm:ss GMT format. + * @return Date + */ + static Date parseTimestamp(String timestamp) { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); + df.setTimeZone(TimeZone.getTimeZone("GMT")); + try { + return df.parse(timestamp); + } catch (ParseException e) { + // should not reach here + e.printStackTrace(); + return new Date(); + } + } + + static String commandOutput(Process p) throws IOException { + Reader r = null; + Reader err = null; + try { + r = new InputStreamReader(p.getInputStream()); + err = new InputStreamReader(p.getErrorStream()); + String output = commandOutput(r); + String errorMsg = commandOutput(err); + p.waitFor(); + return output + errorMsg.trim(); + } catch (InterruptedException e) { + if (isVerbose()) { + e.printStackTrace(); + } + return e.getMessage(); + } finally { + if (r != null) { + r.close(); + } + if (err != null) { + err.close(); + } + } + } + + static String commandOutput(Reader r) throws IOException { + StringBuilder sb = new StringBuilder(); + int c; + while ((c = r.read()) > 0) { + if (c != '\r') { + sb.append((char) c); + } + } + return sb.toString(); + } + + static int getJdkVersion() { + parseVersion(); + return jdkVersion; + } + + static int getUpdateVersion() { + parseVersion(); + return jdkUpdate; + } + + private static int jdkVersion = 0; + private static int jdkUpdate = 0; + private static synchronized void parseVersion() { + if (jdkVersion > 0) { + return; + } + + // parse java.runtime.version + // valid format of the version string is: + // n.n.n[_uu[c]][-<identifer>]-bxx + String cs = System.getProperty("java.runtime.version"); + if (cs.length() >= 5 && + Character.isDigit(cs.charAt(0)) && cs.charAt(1) == '.' && + Character.isDigit(cs.charAt(2)) && cs.charAt(3) == '.' && + Character.isDigit(cs.charAt(4))) { + jdkVersion = Character.digit(cs.charAt(2), 10); + cs = cs.substring(5, cs.length()); + if (cs.charAt(0) == '_' && cs.length() >= 3 && + Character.isDigit(cs.charAt(1)) && + Character.isDigit(cs.charAt(2))) { + int nextChar = 3; + try { + String uu = cs.substring(1, 3); + jdkUpdate = Integer.valueOf(uu).intValue(); + } catch (NumberFormatException e) { + // not conforming to the naming convention + return; + } + } + } else { + throw new InternalError("Invalid java.runtime.version" + cs); + } + } + + /** + * Returns this java string as a null-terminated byte array + */ + private static byte[] stringToByteArray(String str) { + return (str + "\u0000").getBytes(); + } + + /** + * Converts a null-terminated byte array to java string + */ + private static String byteArrayToString(byte[] array) { + return new String(array, 0, array.length -1); + } + + /** + * Gets the stclient path using a well known location from + * the Windows platform Registry, otherwise it will return null. + */ + static File getWindowsStClientFile() { + File out = null; + String regKey = "software\\microsoft\\windows\\currentversion\\app paths\\stclient.exe"; + String keyName = "" ; // use the default key + String path = getRegistryKey(regKey, keyName); + + if (path != null && (new File(path)).exists()) { + out = new File(path); + } + if (isVerbose()) { + System.out.println("stclient=" + out); + } + return out; + } + + /** + * This uses reflection to access a private java windows registry + * interface, any changes to that Class must be appropriately adjusted. + * Returns a null if unsuccessful. + */ + private static String getRegistryKey(String regKey, String keyName) { + String out = null; + try { + Class<?> clazz = Class.forName("java.util.prefs.WindowsPreferences"); + + // Get the registry methods + Method winRegOpenKeyM = clazz.getDeclaredMethod("WindowsRegOpenKey", + int.class, byte[].class, int.class); + winRegOpenKeyM.setAccessible(true); + + Method winRegCloseKeyM = clazz.getDeclaredMethod("WindowsRegCloseKey", + int.class); + winRegCloseKeyM.setAccessible(true); + + Method winRegQueryValueM = clazz.getDeclaredMethod("WindowsRegQueryValueEx", + int.class, byte[].class); + winRegQueryValueM.setAccessible(true); + + // Get all the constants we need + int HKLM = getValueFromStaticField("HKEY_LOCAL_MACHINE", clazz); + int KEY_READ = getValueFromStaticField("KEY_READ", clazz); + int ERROR_CODE = getValueFromStaticField("ERROR_CODE", clazz); + int NATIVE_HANDLE = getValueFromStaticField("NATIVE_HANDLE", clazz); + int ERROR_SUCCESS = getValueFromStaticField("ERROR_SUCCESS", clazz); + + // Convert keys + byte[] reg = stringToByteArray(regKey); + byte[] key = stringToByteArray(keyName); + + // Open the registry + int[] result = (int[]) winRegOpenKeyM.invoke(null, HKLM, reg, KEY_READ); + + if (result[ERROR_CODE] == ERROR_SUCCESS) { + byte[] stvalue = (byte[]) winRegQueryValueM.invoke(null, + result[NATIVE_HANDLE], key); + out = byteArrayToString(stvalue); + winRegCloseKeyM.invoke(null, result[NATIVE_HANDLE]); + } + } catch (Exception ex) { + if (isVerbose()) { + ex.printStackTrace(); + } + } + return out; + } + + private static int getValueFromStaticField(String fldName, Class<?> klass) throws Exception { + Field f = klass.getDeclaredField(fldName); + f.setAccessible(true); + return f.getInt(null); + } +} diff --git a/desktop/source/registration/com/sun/star/servicetag/WindowsSystemEnvironment.java b/desktop/source/registration/com/sun/star/servicetag/WindowsSystemEnvironment.java new file mode 100644 index 000000000000..cdc374f4a993 --- /dev/null +++ b/desktop/source/registration/com/sun/star/servicetag/WindowsSystemEnvironment.java @@ -0,0 +1,145 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WindowsSystemEnvironment.java,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.servicetag; + +// The Service Tags team maintains the latest version of the implementation +// for system environment data collection. JDK will include a copy of +// the most recent released version for a JDK release. We rename +// the package to com.sun.servicetag so that the Sun Connection +// product always uses the latest version from the com.sun.scn.servicetags +// package. JDK and users of the com.sun.servicetag API +// (e.g. NetBeans and SunStudio) will use the version in JDK. + +import java.io.*; +import java.util.ArrayList; +import java.util.List; + +/** + * Windows implementation of the SystemEnvironment class. + */ +class WindowsSystemEnvironment extends SystemEnvironment { + WindowsSystemEnvironment() { + super(); + + // run a call to make sure things are initialized + // ignore the first call result as the system may + // give inconsistent data on the first invocation ever + getWmicResult("computersystem", "get", "model"); + + setSystemModel(getWmicResult("computersystem", "get", "model")); + setSystemManufacturer(getWmicResult("computersystem", "get", "manufacturer")); + setSerialNumber(getWmicResult("bios", "get", "serialnumber")); + + String cpuMfr = getWmicResult("cpu", "get", "manufacturer"); + // this isn't as good an option, but if we couldn't get anything + // from wmic, try the processor_identifier + if (cpuMfr.length() == 0) { + String procId = System.getenv("processor_identifer"); + if (procId != null) { + String[] s = procId.split(","); + cpuMfr = s[s.length - 1].trim(); + } + } + setCpuManufacturer(cpuMfr); + + // try to remove the temp file that gets created from running wmic cmds + try { + // look in the current working directory + File f = new File("TempWmicBatchFile.bat"); + if (f.exists()) { + f.delete(); + } + } catch (Exception e) { + // ignore the exception + } + } + + + /** + * This method invokes wmic outside of the normal environment + * collection routines. + * + * An initial call to wmic can be costly in terms of time. + * + * <code> + * Details of why the first call is costly can be found at: + * + * http://support.microsoft.com/kb/290216/en-us + * + * "When you run the Wmic.exe utility for the first time, the utility + * compiles its .mof files into the repository. To save time during + * Windows installation, this operation takes place as necessary." + * </code> + */ + private String getWmicResult(String alias, String verb, String property) { + String res = ""; + BufferedReader in = null; + try { + ProcessBuilder pb = new ProcessBuilder("cmd", "/C", "WMIC", alias, verb, property); + Process p = pb.start(); + // need this for executing windows commands (at least + // needed for executing wmic command) + BufferedWriter bw = new BufferedWriter( + new OutputStreamWriter(p.getOutputStream())); + bw.write(13); + bw.flush(); + bw.close(); + + p.waitFor(); + if (p.exitValue() == 0) { + in = new BufferedReader(new InputStreamReader(p.getInputStream())); + String line = null; + while ((line = in.readLine()) != null) { + line = line.trim(); + if (line.length() == 0) { + continue; + } + res = line; + } + // return the *last* line read + return res; + } + + } catch (Exception e) { + // ignore the exception + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + // ignore + } + } + } + return res.trim(); + } +} diff --git a/sj2/util/makefile.mk b/desktop/source/registration/com/sun/star/servicetag/makefile.mk index 9a74eb31b012..d4ebbed2f0c4 100644 --- a/sj2/util/makefile.mk +++ b/desktop/source/registration/com/sun/star/servicetag/makefile.mk @@ -8,7 +8,7 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.16 $ +# $Revision: 1.2 $ # # This file is part of OpenOffice.org. # @@ -29,69 +29,55 @@ # #************************************************************************* -PRJ=.. - -PRJNAME=sj2 -TARGET=sj -TARGETTYPE=GUI +PRJNAME = setup_native +PRJ = ..$/..$/..$/..$/..$/.. +TARGET = servicetag +PACKAGE = com$/sun$/star$/servicetag # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk -# ------------------------------------------------------------------ - -LIB1TARGET= $(SLB)$/$(TARGET).lib -LIB1FILES= \ - $(SLB)$/jscpp.lib +.IF "$(ENABLE_SVCTAGS)" == "YES" -SHL1DEPN= $(LIB1TARGET) +JARFILES = jurt.jar unoil.jar ridl.jar +JAVAFILES = \ + BrowserSupport.java \ + Installer.java \ + LinuxSystemEnvironment.java \ + RegistrationData.java \ + RegistrationDocument.java \ + Registry.java \ + ServiceTag.java \ + SolarisServiceTag.java \ + SolarisSystemEnvironment.java \ + SunConnection.java \ + SysnetRegistryHelper.java \ + SystemEnvironment.java \ + UnauthorizedAccessException.java \ + Util.java \ + WindowsSystemEnvironment.java -SHL1TARGET= j$(DLLPOSTFIX)_g -SHL1IMPLIB= $(TARGET) +JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) -SHL1STDLIBS= \ - $(VCLLIB) \ - $(TOOLSLIB) \ - $(CPPULIB) \ - $(SALLIB) +JARTARGET = $(TARGET).jar +JARCOMPRESS = TRUE +JARCLASSDIRS = $(PACKAGE) -.IF "$(GUI)$(COMID)"=="WNTMSC" -SHL1STDLIBS+= \ - $(SVTOOLLIB) -.ENDIF # "$(GUI)$(COMID)"=="WNTMSC" +JAVARES= $(CLASSDIR)$/$(PACKAGE)$/resources$/product_registration.xsd -.IF "$(SOLAR_JAVA)"!="" - SHL1STDLIBS+=$(JVMACCESSLIB) -.ENDIF +.ENDIF # "$(ENABLE_SVCTAGS)" == "YES" -SHL1LIBS= $(SLB)$/$(TARGET).lib -SHL1DEF= $(MISC)$/$(SHL1TARGET).def +# --- Targets ------------------------------------------------------ -DEF1NAME =$(SHL1TARGET) -DEF1DEPN =$(MISC)$/$(SHL1TARGET).flt -DEFLIB1NAME =$(TARGET) -DEF1DES =JavaCPP -DEF1CEXP =Java -JARTARGET=classes.jar -JARCLASSDIRS=stardiv -JARCLASSPATH = sandbox.jar +.INCLUDE : target.mk -# --- Targets ------------------------------------------------------ +.IF "$(ENABLE_SVCTAGS)" == "YES" +ALLTAR: $(JAVARES) -.INCLUDE : target.mk -.INCLUDE : target.pmk +$(JAVARES) : $$(@:d:d:f)$/$$(@:f) + $(MKDIRHIER) $(@:d) + $(COPY) $< $@ -$(MISC)$/$(SHL1TARGET).flt: makefile.mk - @echo ------------------------------ - @echo Making: $@ - @echo WEP>$@ - @echo LIBMAIN>>$@ - @echo LibMain>>$@ - @echo bad_alloc::bad_alloc>>$@ - @echo exception::exception>>$@ -.IF "$(COM)"=="MSC" - @echo __CT>>$@ - @echo _C@>>$@ -.ENDIF +.ENDIF # "$(ENABLE_SVCTAGS)" == "YES" diff --git a/desktop/source/registration/com/sun/star/servicetag/resources/product_registration.xsd b/desktop/source/registration/com/sun/star/servicetag/resources/product_registration.xsd new file mode 100644 index 000000000000..e9b34417d9ae --- /dev/null +++ b/desktop/source/registration/com/sun/star/servicetag/resources/product_registration.xsd @@ -0,0 +1,301 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + +<xs:element name="registration_data"> + <xs:complexType> + <xs:sequence> + <xs:element name="environment" + minOccurs="1" + maxOccurs="1"> + <xs:complexType> + <xs:sequence> + <xs:element ref="hostname" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="hostId" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="osName" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="osVersion" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="osArchitecture" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="systemModel" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="systemManufacturer" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="cpuManufacturer" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="serialNumber" + minOccurs='1' + maxOccurs='1'/> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="registry" + minOccurs="1" + maxOccurs="1"> + <xs:complexType> + <xs:sequence> + <xs:element name="service_tag" + minOccurs="0" + maxOccurs="1024"> + <xs:complexType> + <xs:sequence> + <xs:element ref="instance_urn" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="product_name" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="product_version" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="product_urn" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="product_parent_urn" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="product_parent" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="product_defined_inst_id" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="product_vendor" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="platform_arch" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="timestamp" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="container" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="source" + minOccurs='1' + maxOccurs='1'/> + <xs:element ref="installer_uid" + minOccurs='1' + maxOccurs='1'/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + <xs:attribute name="urn" + type="xs:string" + use="required"/> + <xs:attribute name="version" + type="xs:string" + use="required"/> + </xs:complexType> + </xs:element> + </xs:sequence> + <xs:attribute name="version" + type="xs:string" + use="required"/> + </xs:complexType> +</xs:element> + + <!-- definition of simple elements --> + <xs:element name="hostname"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="255"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="hostId"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="0"/> + <xs:maxLength value="16"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="osName"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="256"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="osVersion"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="0"/> + <xs:maxLength value="50"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="osArchitecture"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="0"/> + <xs:maxLength value="256"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="systemModel"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="0"/> + <xs:maxLength value="50"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="systemManufacturer"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="0"/> + <xs:maxLength value="50"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="cpuManufacturer"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="0"/> + <xs:maxLength value="50"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="serialNumber"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="0"/> + <xs:maxLength value="256"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="instance_urn"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="255"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="product_name"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:maxLength value="255"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="product_version"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:maxLength value="63"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="product_urn"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="255"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="product_parent_urn"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="0"/> + <xs:maxLength value="255"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="product_parent"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="255"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="product_defined_inst_id"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="0"/> + <xs:maxLength value="255"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="product_vendor"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="63"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="platform_arch"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="63"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="timestamp"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:maxLength value="24"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="container"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:maxLength value="63"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="source"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:maxLength value="63"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + + <xs:element name="installer_uid"> + <xs:simpleType> + <xs:restriction base="xs:integer"> + </xs:restriction> + </xs:simpleType> + </xs:element> + +</xs:schema> diff --git a/desktop/util/makefile.mk b/desktop/util/makefile.mk index b04162cf0ad1..05f129b3c5fc 100644 --- a/desktop/util/makefile.mk +++ b/desktop/util/makefile.mk @@ -78,6 +78,7 @@ RESLIB1IMAGES= $(PRJ)$/res RESLIB1SRSFILES= $(SRS)$/desktop.srs \ $(SRS)$/wizard.srs +.IF "$(L10N_framework)"=="" .IF "$(GUI)" != "OS2" APP1TARGET=so$/$(TARGET) APP1NOSAL=TRUE @@ -107,7 +108,6 @@ APP1STDLIBS = \ $(SAXLIB) \ $(FWILIB) \ $(ICUUCLIB) \ - $(SJLIB) \ $(I18NUTILLIB) \ $(ICULIB) \ $(JVMFWKLIB) \ @@ -121,7 +121,7 @@ APP1STDLIBS = \ .IF "$(GUI)" == "UNX" .IF "$(OS)" == "LINUX" || "$(OS)" == "FREEBSD" -APP1STDLIBS+= -lXext -lSM -lICE +APP1STDLIBS+= -lXext .ENDIF .ENDIF @@ -171,7 +171,6 @@ APP5STDLIBS = \ $(SAXLIB) \ $(FWILIB) \ $(ICUUCLIB) \ - $(SJLIB) \ $(I18NUTILLIB) \ $(ICULIB) \ $(JVMFWKLIB) \ @@ -183,7 +182,8 @@ APP5STDLIBS = \ $(VOSLIB) .IF "$(OS)" == "LINUX" -APP5STDLIBS+= -lXext -lSM -lICE +APP5STDLIBS+= -lXext +#APP5STDLIBS+= -lXext -lSM -lICE .ENDIF # LINUX APP5DEPN= $(APP1TARGETN) $(APP5RES) ooverinfo.rc @@ -241,10 +241,14 @@ APP5DEPN= $(APP1TARGETN) $(APP5RES) ooverinfo.rc APP5DEF= $(MISCX)$/$(TARGET).def .ENDIF # WNT +.ENDIF + # --- Targets ------------------------------------------------------------- .INCLUDE : target.mk +.IF "$(L10N_framework)"=="" + .IF "$(APP1TARGETN)"!="" $(APP1TARGETN) : $(MISC)$/binso_created.flg .ENDIF # "$(APP1TARGETN)"!="" @@ -333,3 +337,5 @@ $(BIN)$/$(TARGET).bin: $(BIN)$/$(TARGET)$(EXECPOST) $(MISC)$/binso_created.flg : @@-$(MKDIRHIER) $(BIN)$/so && $(TOUCH) $@ + +.ENDIF diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx index b9639aeacc50..df09718a7582 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx @@ -76,8 +76,11 @@ namespace drawinglayer ~TextLayouterDevice(); void setFont(const Font& rFont); - void setFontAttributes(const FontAttributes& rFontAttributes, const basegfx::B2DHomMatrix& rTransform, const ::com::sun::star::lang::Locale & rLocale); - void setFontAttributes(const FontAttributes& rFontAttributes, double fFontScaleX, double fFontScaleY, const ::com::sun::star::lang::Locale & rLocale); + void setFontAttributes( + const FontAttributes& rFontAttributes, + double fFontScaleX, + double fFontScaleY, + const ::com::sun::star::lang::Locale & rLocale); double getTextHeight() const; double getOverlineHeight() const; @@ -85,9 +88,6 @@ namespace drawinglayer double getUnderlineHeight() const; double getUnderlineOffset() const; double getStrikeoutOffset() const; -#ifdef WIN32 - double getCurrentFontRelation() const; -#endif double getTextWidth( const String& rText, @@ -99,9 +99,7 @@ namespace drawinglayer const String& rText, xub_StrLen nIndex, xub_StrLen nLength, - // #i89784# added suppirt for DXArray for justified text - const ::std::vector< double >& rDXArray, - double fFontScaleWidth); + const ::std::vector< double >& rDXArray); basegfx::B2DRange getTextBoundRect( const String& rText, @@ -112,27 +110,33 @@ namespace drawinglayer } // end of namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// +// helper methods for vcl font handling namespace drawinglayer { namespace primitive2d { - // helper methods for vcl font handling + // Create a VCL-Font based on the definitions in FontAttributes + // and the given FontScaling. The FontScaling defines the FontHeight + // (fFontScaleY) and the FontWidth (fFontScaleX). The combination of + // both defines FontStretching, where no stretching happens at + // fFontScaleY == fFontScaleX Font getVclFontFromFontAttributes( const FontAttributes& rFontAttributes, double fFontScaleX, double fFontScaleY, double fFontRotation, - const ::com::sun::star::lang::Locale & rLocale, - const OutputDevice& rOutDev); - - Font getVclFontFromFontAttributes( - const FontAttributes& rFontAttributes, - const basegfx::B2DHomMatrix& rTransform, - const ::com::sun::star::lang::Locale & rLocale, - const OutputDevice& rOutDev); - - FontAttributes getFontAttributesFromVclFont(basegfx::B2DVector& rSize, const Font& rFont, bool bRTL, bool bBiDiStrong); + const ::com::sun::star::lang::Locale & rLocale); + + // Generate FontAttributes DataSet derived from the given VCL-Font. + // The FontScaling with fFontScaleY, fFontScaleX relationship (see + // above) will be set in return parameter o_rSize to allow further + // processing + FontAttributes getFontAttributesFromVclFont( + basegfx::B2DVector& o_rSize, + const Font& rFont, + bool bRTL, + bool bBiDiStrong); } // end of namespace primitive2d } // end of namespace drawinglayer diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textprimitive2d.hxx index 9515fcc22ee8..d7f9bdb1e89a 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/textprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/textprimitive2d.hxx @@ -158,14 +158,6 @@ namespace drawinglayer // the necessary VCL outline extractins, scaling adaptions and other stuff. void getTextOutlinesAndTransformation(basegfx::B2DPolyPolygonVector& rTarget, basegfx::B2DHomMatrix& rTransformation) const; - // adapts fontScale for usage with TextLayouter. Input is rScale which is the extracted - // scale from a text transformation. A copy goes to rFontScale and is modified so that - // it contains only positive scalings and XY-equal scalings to allow to get a non-X-scaled - // Vcl-Font for TextLayouter. rScale is adapted accordingly to contain the corrected scale - // which would need to be applied to e.g. outlines received from TextLayouter under - // usage of fontScale. This includes Y-Scale, X-Scale-correction and mirrorings. - void getCorrectedScaleAndFontScale(basegfx::B2DVector& rScale, basegfx::B2DVector& rFontScale) const; - // get data const basegfx::B2DHomMatrix& getTextTransform() const { return maTextTransform; } const String& getText() const { return maText; } diff --git a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx index ffceaf8ce04a..1ed826dab562 100644 --- a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx @@ -266,7 +266,38 @@ namespace drawinglayer case GRAPHIC_GDIMETAFILE : { - xPrimitive = Primitive2DReference(new MetafilePrimitive2D(getTransform(), aTransformedGraphic.GetGDIMetaFile())); + // create MetafilePrimitive2D + const GDIMetaFile& rMetafile = aTransformedGraphic.GetGDIMetaFile(); + + xPrimitive = Primitive2DReference( + new MetafilePrimitive2D( + getTransform(), + rMetafile)); + + // #i100357# find out if clipping is needed for this primitive. Unfortunately, + // there exist Metafiles who's content is bigger than the proposed PrefSize set + // at them. This is an error, but we need to work around this + const Size aMetaFilePrefSize(rMetafile.GetPrefSize()); + const Size aMetaFileRealSize( + const_cast< GDIMetaFile& >(rMetafile).GetBoundRect( + *Application::GetDefaultDevice()).GetSize()); + + if(aMetaFileRealSize.getWidth() > aMetaFilePrefSize.getWidth() + || aMetaFileRealSize.getHeight() > aMetaFilePrefSize.getHeight()) + { + // clipping needed. Embed to MaskPrimitive2D. Create childs and mask polygon + const primitive2d::Primitive2DSequence aChildContent(&xPrimitive, 1); + basegfx::B2DPolygon aMaskPolygon( + basegfx::tools::createPolygonFromRect( + basegfx::B2DRange(0.0, 0.0, 1.0, 1.0))); + aMaskPolygon.transform(getTransform()); + + xPrimitive = Primitive2DReference( + new MaskPrimitive2D( + basegfx::B2DPolyPolygon(aMaskPolygon), + aChildContent)); + } + break; } diff --git a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx index 94e92a149e50..d337950c6c6b 100644 --- a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx @@ -277,15 +277,16 @@ namespace drawinglayer const FontAttributes& rFontAttributes) const { // create the SimpleTextPrimitive needed in any case - rTarget.push_back(Primitive2DReference(new TextSimplePortionPrimitive2D( - rDecTrans.getB2DHomMatrix(), - rText, - aTextPosition, - aTextLength, - rDXArray, - rFontAttributes, - getLocale(), - getFontColor()))); + rTarget.push_back(Primitive2DReference( + new TextSimplePortionPrimitive2D( + rDecTrans.getB2DHomMatrix(), + rText, + aTextPosition, + aTextLength, + rDXArray, + rFontAttributes, + getLocale(), + getFontColor()))); // see if something else needs to be done const bool bOverlineUsed(FONT_UNDERLINE_NONE != getFontOverline()); @@ -305,7 +306,11 @@ namespace drawinglayer // TextLayouterDevice is needed to get metrics for text decorations like // underline/strikeout/emphasis marks from it. For setup, the font size is needed - aTextLayouter.setFontAttributes(getFontAttributes(), rDecTrans.getScale().getX(), rDecTrans.getScale().getY(), getLocale()); + aTextLayouter.setFontAttributes( + getFontAttributes(), + rDecTrans.getScale().getX(), + rDecTrans.getScale().getY(), + getLocale()); // get text width double fTextWidth(0.0); @@ -317,6 +322,14 @@ namespace drawinglayer else { fTextWidth = rDXArray.back() * rDecTrans.getScale().getX(); + const double fFontScaleX(rDecTrans.getScale().getX()); + + if(!basegfx::fTools::equal(fFontScaleX, 1.0) + && !basegfx::fTools::equalZero(fFontScaleX)) + { + // need to take FontScaling out of the DXArray + fTextWidth /= fFontScaleX; + } } if(bOverlineUsed) @@ -343,28 +356,26 @@ namespace drawinglayer const String aSingleCharString(aStrikeoutChar); const double fStrikeCharWidth(aTextLayouter.getTextWidth(aSingleCharString, 0, 1)); const double fStrikeCharCount(fabs(fTextWidth/fStrikeCharWidth)); - const sal_uInt32 nStrikeCharCount(static_cast< sal_uInt32 >(fStrikeCharCount + 0.9)); - const double fScaleX(rDecTrans.getScale().getX()); - const double fStrikeCharWidthUnscaled(basegfx::fTools::equalZero(fScaleX) ? fStrikeCharWidth : fStrikeCharWidth/fScaleX); - + const sal_uInt32 nStrikeCharCount(static_cast< sal_uInt32 >(fStrikeCharCount + 0.5)); std::vector<double> aDXArray(nStrikeCharCount); String aStrikeoutString; for(sal_uInt32 a(0); a < nStrikeCharCount; a++) { aStrikeoutString += aSingleCharString; - aDXArray[a] = (a + 1) * fStrikeCharWidthUnscaled; + aDXArray[a] = (a + 1) * fStrikeCharWidth; } - rTarget.push_back(Primitive2DReference(new TextSimplePortionPrimitive2D( - rDecTrans.getB2DHomMatrix(), - aStrikeoutString, - 0, - aStrikeoutString.Len(), - aDXArray, - rFontAttributes, - getLocale(), - getFontColor()))); + rTarget.push_back(Primitive2DReference( + new TextSimplePortionPrimitive2D( + rDecTrans.getB2DHomMatrix(), + aStrikeoutString, + 0, + aStrikeoutString.Len(), + aDXArray, + rFontAttributes, + getLocale(), + getFontColor()))); } else { @@ -483,17 +494,15 @@ namespace drawinglayer xLocalBreakIterator.set(xMSF->createInstance(rtl::OUString::createFromAscii("com.sun.star.i18n.BreakIterator")), ::com::sun::star::uno::UNO_QUERY); } - if(xLocalBreakIterator.is()) + if(xLocalBreakIterator.is() && getTextLength()) { // init word iterator, get first word and truncate to possibilities ::com::sun::star::i18n::Boundary aNextWordBoundary(xLocalBreakIterator->getWordBoundary( getText(), getTextPosition(), getLocale(), ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES, sal_True)); - if(aNextWordBoundary.endPos == getTextPosition() && getTextLength() > 0) + if(aNextWordBoundary.endPos == getTextPosition()) { - // #i96474# - // a word before was found (this can happen when search starts on a whitespace and a word - // in front of it exists), force to look one position further + // backward hit, force next word aNextWordBoundary = xLocalBreakIterator->getWordBoundary( getText(), getTextPosition() + 1, getLocale(), ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES, sal_True); } @@ -526,7 +535,11 @@ namespace drawinglayer if(bNoDXArray) { // ..but only completely when no DXArray - aTextLayouter.setFontAttributes(getFontAttributes(), rDecTrans.getScale().getX(), rDecTrans.getScale().getY(),getLocale()); + aTextLayouter.setFontAttributes( + getFontAttributes(), + rDecTrans.getScale().getX(), + rDecTrans.getScale().getY(), + getLocale()); } // do iterate over single words @@ -566,12 +579,25 @@ namespace drawinglayer fOffset = getDXArray()[nIndex - 1]; } + // need offset without FontScale for building the new transformation. The + // new transformation will be multiplied with the current text transformation + // so FontScale would be double + double fOffsetNoScale(fOffset); + const double fFontScaleX(rDecTrans.getScale().getX()); + + if(!basegfx::fTools::equal(fFontScaleX, 1.0) + && !basegfx::fTools::equalZero(fFontScaleX)) + { + fOffsetNoScale /= fFontScaleX; + } + // apply needed offset to transformation - aNewTransform.translate(fOffset, 0.0); + aNewTransform.translate(fOffsetNoScale, 0.0); if(!bNoDXArray) { - // DXArray values need to be corrected with the offset, too + // DXArray values need to be corrected with the offset, too. Here, + // take the scaled offset since the DXArray is scaled const sal_uInt32 nArraySize(aNewDXArray.size()); for(sal_uInt32 a(0); a < nArraySize; a++) @@ -591,12 +617,30 @@ namespace drawinglayer impCreateGeometryContent(rTarget, aDecTrans, getText(), nNewTextStart, nNewTextEnd - nNewTextStart, aNewDXArray, aNewFontAttributes); - // prepare next word and truncate to possibilities - aNextWordBoundary = xLocalBreakIterator->nextWord( - getText(), aNextWordBoundary.endPos, getLocale(), - ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES); + if(aNextWordBoundary.endPos >= getTextPosition() + getTextLength()) + { + // end reached + aNextWordBoundary.startPos = aNextWordBoundary.endPos; + } + else + { + // get new word portion + const sal_Int32 nLastEndPos(aNextWordBoundary.endPos); + + aNextWordBoundary = xLocalBreakIterator->getWordBoundary( + getText(), aNextWordBoundary.endPos, getLocale(), + ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES, sal_True); - impCorrectTextBoundary(aNextWordBoundary); + if(nLastEndPos == aNextWordBoundary.endPos) + { + // backward hit, force next word + aNextWordBoundary = xLocalBreakIterator->getWordBoundary( + getText(), nLastEndPos + 1, getLocale(), + ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES, sal_True); + } + + impCorrectTextBoundary(aNextWordBoundary); + } } } } diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx index 0055af3ea4bd..e321783c8406 100644 --- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx +++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx @@ -43,6 +43,7 @@ #include <vcl/metric.hxx> #include <i18npool/mslangid.hxx> #include <drawinglayer/primitive2d/textprimitive2d.hxx> +#include <vcl/svapp.hxx> ////////////////////////////////////////////////////////////////////////////// // VDev RevDevice provider @@ -166,14 +167,18 @@ namespace drawinglayer mrDevice.SetFont( rFont ); } - void TextLayouterDevice::setFontAttributes(const FontAttributes& rFontAttributes, const basegfx::B2DHomMatrix& rTransform, const ::com::sun::star::lang::Locale & rLocale) - { - setFont(getVclFontFromFontAttributes(rFontAttributes, rTransform, rLocale, mrDevice)); - } - - void TextLayouterDevice::setFontAttributes(const FontAttributes& rFontAttributes, double fFontScaleX, double fFontScaleY, const ::com::sun::star::lang::Locale & rLocale) + void TextLayouterDevice::setFontAttributes( + const FontAttributes& rFontAttributes, + double fFontScaleX, + double fFontScaleY, + const ::com::sun::star::lang::Locale& rLocale) { - setFont(getVclFontFromFontAttributes(rFontAttributes, fFontScaleX, fFontScaleY, 0.0, rLocale, mrDevice)); + setFont(getVclFontFromFontAttributes( + rFontAttributes, + fFontScaleX, + fFontScaleY, + 0.0, + rLocale)); } double TextLayouterDevice::getOverlineOffset() const @@ -197,18 +202,6 @@ namespace drawinglayer return fRet; } -#ifdef WIN32 - double TextLayouterDevice::getCurrentFontRelation() const - { - const Font aFont(mrDevice.GetFont()); - const FontMetric aFontMetric(mrDevice.GetFontMetric(aFont)); - const double fWidth(aFontMetric.GetWidth()); - const double fHeight(aFont.GetHeight()); - - return basegfx::fTools::equalZero(fWidth) ? 1.0 : fHeight / fWidth; - } -#endif - double TextLayouterDevice::getOverlineHeight() const { const ::FontMetric& rMetric = mrDevice.GetFontMetric(); @@ -241,33 +234,42 @@ namespace drawinglayer const String& rText, xub_StrLen nIndex, xub_StrLen nLength, - // #i89784# added suppirt for DXArray for justified text - const ::std::vector< double >& rDXArray, - double fFontScaleWidth) + const ::std::vector< double >& rDXArray) { - std::vector< sal_Int32 > aTransformedDXArray; - const sal_uInt32 nDXArraySize(rDXArray.size()); + const sal_uInt32 nDXArrayCount(rDXArray.size()); - if(nDXArraySize && basegfx::fTools::more(fFontScaleWidth, 0.0)) + if(nDXArrayCount) { - OSL_ENSURE(nDXArraySize == nLength, "DXArray size does not correspond to text portion size (!)"); - aTransformedDXArray.reserve(nDXArraySize); + OSL_ENSURE(nDXArrayCount == nLength, "DXArray size does not correspond to text portion size (!)"); + std::vector< sal_Int32 > aIntegerDXArray(nDXArrayCount); - for(std::vector< double >::const_iterator aStart(rDXArray.begin()); aStart != rDXArray.end(); aStart++) + for(sal_uInt32 a(0); a < nDXArrayCount; a++) { - aTransformedDXArray.push_back(basegfx::fround((*aStart) * fFontScaleWidth)); + aIntegerDXArray[a] = basegfx::fround(rDXArray[a]); } - } - return mrDevice.GetTextOutlines( - rB2DPolyPolyVector, - rText, - nIndex, - nIndex, - nLength, - true, - 0, - nDXArraySize ? &(aTransformedDXArray[0]) : 0); + return mrDevice.GetTextOutlines( + rB2DPolyPolyVector, + rText, + nIndex, + nIndex, + nLength, + true, + 0, + &(aIntegerDXArray[0])); + } + else + { + return mrDevice.GetTextOutlines( + rB2DPolyPolyVector, + rText, + nIndex, + nIndex, + nLength, + true, + 0, + 0); + } } basegfx::B2DRange TextLayouterDevice::getTextBoundRect( @@ -286,7 +288,7 @@ namespace drawinglayer nIndex, nLength); - // #i102556# take empty results into account + // #i104432#, #i102556# take empty results into account if(!aRect.IsEmpty()) { return basegfx::B2DRange(aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom()); @@ -307,38 +309,36 @@ namespace drawinglayer { Font getVclFontFromFontAttributes( const FontAttributes& rFontAttributes, - const basegfx::B2DHomMatrix& rTransform, - const ::com::sun::star::lang::Locale & rLocale, - const OutputDevice& rOutDev) - { - // decompose matrix to have position and size of text - basegfx::B2DVector aScale, aTranslate; - double fRotate, fShearX; - - rTransform.decompose(aScale, aTranslate, fRotate, fShearX); - - return getVclFontFromFontAttributes(rFontAttributes, aScale.getX(), aScale.getY(), fRotate, rLocale, rOutDev); - } - - Font getVclFontFromFontAttributes( - const FontAttributes& rFontAttributes, double fFontScaleX, double fFontScaleY, double fFontRotation, - const ::com::sun::star::lang::Locale & rLocale, - const OutputDevice& /*rOutDev*/) + const ::com::sun::star::lang::Locale& rLocale) { - sal_uInt32 nWidth(basegfx::fround(fabs(fFontScaleX))); - sal_uInt32 nHeight(basegfx::fround(fabs(fFontScaleY))); + // detect FontScaling + const sal_uInt32 nHeight(basegfx::fround(fabs(fFontScaleY))); + const sal_uInt32 nWidth(basegfx::fround(fabs(fFontScaleX))); + const bool bFontIsScaled(nHeight != nWidth); + +#ifdef WIN32 + // for WIN32 systems, start with creating an unscaled font. If FontScaling + // is wanted, that width needs to be adapted using FontMetric again to get a + // width of the unscaled font Font aRetval( rFontAttributes.getFamilyName(), rFontAttributes.getStyleName(), -#ifdef WIN32 Size(0, nHeight)); #else - Size(nWidth, nHeight)); + // for non-WIN32 systems things are easier since these accept a Font creation + // with initially nWidth != nHeight for FontScaling. Despite that, use zero for + // FontWidth when no scaling is used to explicitely have that zero when e.g. the + // Font would be recorded in a MetaFile (The MetaFile FontAction WILL record a + // set FontWidth; import that in a WIN32 system, and trouble is there) + Font aRetval( + rFontAttributes.getFamilyName(), + rFontAttributes.getStyleName(), + Size(bFontIsScaled ? nWidth : 0, nHeight)); #endif - + // define various other FontAttributes aRetval.SetAlign(ALIGN_BASELINE); aRetval.SetCharSet(rFontAttributes.getSymbol() ? RTL_TEXTENCODING_SYMBOL : RTL_TEXTENCODING_UNICODE); aRetval.SetVertical(rFontAttributes.getVertical() ? TRUE : FALSE); @@ -348,32 +348,20 @@ namespace drawinglayer aRetval.SetLanguage(MsLangId::convertLocaleToLanguage(rLocale)); #ifdef WIN32 - // #100424# use higher precision - if(!basegfx::fTools::equal(fFontScaleX, fFontScaleY)) + // for WIN32 systems, correct the FontWidth if FontScaling is used + if(bFontIsScaled && nHeight > 0) { - // #i92757# - // Removed the relative calculation with GetFontMetric() usage again. On - // the one hand it was wrong (integer division always created zero), OTOH - // calculating a scale factor from current to target width and then using - // it to actually scale the current width does nothing but set the target - // value directly. Maybe more is needed here with WIN version of font - // width/height handling, but currently, this works the simple way. - // - // As can be seen, when this can stay the simple way, the OutputDevice - // can be removed from the whole getVclFontFromFontAttributes implementations - // again and make it more VCL-independent. - // - // Adapted nWidth usage to nWidth-1 to be completely compatible with - // non-primitive version. - // - // previous stuff: - // const FontMetric aFontMetric(rOutDev.GetFontMetric(aRetval)); - // const double fCurrentWidth(aFontMetric.GetWidth()); - // aRetval.SetWidth(basegfx::fround(fCurrentWidth * ((double)nWidth/(double)nHeight))); - aRetval.SetWidth(nWidth ? nWidth - 1 : 0); + const FontMetric aUnscaledFontMetric(Application::GetDefaultDevice()->GetFontMetric(aRetval)); + + if(aUnscaledFontMetric.GetWidth() > 0) + { + const double fScaleFactor((double)nWidth / (double)nHeight); + const sal_uInt32 nScaledWidth(basegfx::fround((double)aUnscaledFontMetric.GetWidth() * fScaleFactor)); + aRetval.SetWidth(nScaledWidth); + } } #endif - + // handle FontRotation (if defined) if(!basegfx::fTools::equalZero(fFontRotation)) { sal_Int16 aRotate10th((sal_Int16)(fFontRotation * (-1800.0/F_PI))); @@ -383,9 +371,13 @@ namespace drawinglayer return aRetval; } - FontAttributes getFontAttributesFromVclFont(basegfx::B2DVector& rSize, const Font& rFont, bool bRTL, bool bBiDiStrong) + FontAttributes getFontAttributesFromVclFont( + basegfx::B2DVector& o_rSize, + const Font& rFont, + bool bRTL, + bool bBiDiStrong) { - FontAttributes aRetval( + const FontAttributes aRetval( rFont.GetName(), rFont.GetStyleName(), static_cast<sal_uInt16>(rFont.GetWeight()), @@ -397,12 +389,38 @@ namespace drawinglayer bBiDiStrong); // TODO: eKerning - const sal_Int32 nWidth(rFont.GetSize().getWidth()); - const sal_Int32 nHeight(rFont.GetSize().getHeight()); + // set FontHeight and init to no FontScaling + o_rSize.setY(rFont.GetSize().getHeight() > 0 ? rFont.GetSize().getHeight() : 0); + o_rSize.setX(o_rSize.getY()); - rSize.setX(nWidth ? nWidth : nHeight); - rSize.setY(nHeight); +#ifdef WIN32 + // for WIN32 systems, the FontScaling at the Font is detected by + // checking that FontWidth != 0. When FontScaling is used, WIN32 + // needs to do extra stuff to detect the correct width (since it's + // zero and not equal the font height) and it's relationship to + // the height + if(rFont.GetSize().getWidth() > 0) + { + Font aUnscaledFont(rFont); + aUnscaledFont.SetWidth(0); + const FontMetric aUnscaledFontMetric(Application::GetDefaultDevice()->GetFontMetric(aUnscaledFont)); + if(aUnscaledFontMetric.GetWidth() > 0) + { + const double fScaleFactor((double)rFont.GetSize().getWidth() / (double)aUnscaledFontMetric.GetWidth()); + o_rSize.setX(fScaleFactor * o_rSize.getY()); + } + } +#else + // For non-WIN32 systems the detection is the same, but the value + // is easier achieved since width == height is interpreted as no + // scaling. Ergo, Width == 0 means width == height, and width != 0 + // means the scaling is in the direct relation of width to height + if(rFont.GetSize().getWidth() > 0) + { + o_rSize.setX((double)rFont.GetSize().getWidth()); + } +#endif return aRetval; } } // end of namespace primitive2d diff --git a/drawinglayer/source/primitive2d/textprimitive2d.cxx b/drawinglayer/source/primitive2d/textprimitive2d.cxx index 7c62c235c21d..f8e413da0e8c 100644 --- a/drawinglayer/source/primitive2d/textprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/textprimitive2d.cxx @@ -70,49 +70,63 @@ namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// -namespace drawinglayer +namespace { - namespace primitive2d + // adapts fontScale for usage with TextLayouter. Input is rScale which is the extracted + // scale from a text transformation. A copy is modified so that it contains only positive + // scalings and XY-equal scalings to allow to get a non-X-scaled Vcl-Font for TextLayouter. + // rScale is adapted accordingly to contain the corrected scale which would need to be + // applied to e.g. outlines received from TextLayouter under usage of fontScale. This + // includes Y-Scale, X-Scale-correction and mirrorings. + basegfx::B2DVector getCorrectedScaleAndFontScale(basegfx::B2DVector& rScale) { - void TextSimplePortionPrimitive2D::getCorrectedScaleAndFontScale(basegfx::B2DVector& rScale, basegfx::B2DVector& rFontScale) const - { - // copy input value - rFontScale = rScale; + // copy input value + basegfx::B2DVector aFontScale(rScale); - if(basegfx::fTools::equalZero(rFontScale.getY())) - { - // no font height; choose one and adapt scale to get back to original scaling - static double fDefaultFontScale(100.0); - rScale.setY(1.0 / fDefaultFontScale); - rFontScale.setY(fDefaultFontScale); - } - else if(basegfx::fTools::less(rFontScale.getY(), 0.0)) - { - // negative font height; invert and adapt scale to get back to original scaling - rFontScale.setY(-rFontScale.getY()); - rScale.setY(-1.0); - } - else - { - // positive font height; adapt scale; scaling will be part of the polygons - rScale.setY(1.0); - } + // correct FontHeight settings + if(basegfx::fTools::equalZero(aFontScale.getY())) + { + // no font height; choose one and adapt scale to get back to original scaling + static double fDefaultFontScale(100.0); + rScale.setY(1.0 / fDefaultFontScale); + aFontScale.setY(fDefaultFontScale); + } + else if(basegfx::fTools::less(aFontScale.getY(), 0.0)) + { + // negative font height; invert and adapt scale to get back to original scaling + aFontScale.setY(-aFontScale.getY()); + rScale.setY(-1.0); + } + else + { + // positive font height; adapt scale; scaling will be part of the polygons + rScale.setY(1.0); + } - if(basegfx::fTools::equal(rFontScale.getX(), rFontScale.getY())) - { - // adapt scale in X - rScale.setX(1.0); - } - else - { - // If font scale is different in X and Y, force font scale to equal - // in X and Y to get a non-scaled VCL font. - // Adapt scaling in X accordingly. FontScaleY cannot be zero here. - rScale.setX(rFontScale.getX()/rFontScale.getY()); - rFontScale.setX(rFontScale.getY()); - } + // correct FontWidth settings + if(basegfx::fTools::equal(aFontScale.getX(), aFontScale.getY())) + { + // no FontScale, adapt scale + rScale.setX(1.0); } + else + { + // If FontScale is used, force to no FontScale to get a non-scaled VCL font. + // Adapt scaling in X accordingly. + rScale.setX(aFontScale.getX() / aFontScale.getY()); + aFontScale.setX(aFontScale.getY()); + } + + return aFontScale; + } +} // end of anonymous namespace +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { void TextSimplePortionPrimitive2D::getTextOutlinesAndTransformation(basegfx::B2DPolyPolygonVector& rTarget, basegfx::B2DHomMatrix& rTransformation) const { if(getTextLength()) @@ -137,33 +151,47 @@ namespace drawinglayer // the font size. Since we want to extract polygons here, it is okay to // work just with scaling and to ignore shear, rotation and translation, // all that can be applied to the polygons later -#ifdef WIN32 - const bool bCorrectScale(!basegfx::fTools::equal(fabs(aScale.getX()), fabs(aScale.getY()))); -#endif - basegfx::B2DVector aFontScale; - getCorrectedScaleAndFontScale(aScale, aFontScale); + const basegfx::B2DVector aFontScale(getCorrectedScaleAndFontScale(aScale)); // prepare textlayoutdevice TextLayouterDevice aTextLayouter; - aTextLayouter.setFontAttributes(getFontAttributes(), aFontScale.getX(), aFontScale.getY(), getLocale()); -#ifdef WIN32 - // when under Windows and the font is unequally scaled, need to correct font X-Scaling factor - if(bCorrectScale) + aTextLayouter.setFontAttributes( + getFontAttributes(), + aFontScale.getX(), + aFontScale.getY(), + getLocale()); + + // When getting outlines from stretched text (aScale.getX() != 1.0) it + // is necessary to inverse-scale the DXArray (if used) to not get the + // outlines already aligned to given, but wrong DXArray + if(getDXArray().size() && !basegfx::fTools::equal(aScale.getX(), 1.0)) + { + ::std::vector< double > aScaledDXArray = getDXArray(); + const double fDXArrayScale(1.0 / aScale.getX()); + + for(sal_uInt32 a(0); a < aScaledDXArray.size(); a++) + { + aScaledDXArray[a] *= fDXArrayScale; + } + + // get the text outlines + aTextLayouter.getTextOutlines( + rTarget, + getText(), + getTextPosition(), + getTextLength(), + aScaledDXArray); + } + else { - const double fFontRelation(aTextLayouter.getCurrentFontRelation()); - aScale.setX(aScale.getX() * fFontRelation); - aFontScale.setX(aFontScale.getX() / fFontRelation); + // get the text outlines + aTextLayouter.getTextOutlines( + rTarget, + getText(), + getTextPosition(), + getTextLength(), + getDXArray()); } -#endif - // get the text outlines. No DXArray is given (would contain integers equal to unit vector - // transformed by object's transformation), let VCL do the job - aTextLayouter.getTextOutlines( - rTarget, getText(), - getTextPosition(), - getTextLength(), - // #i89784# added support for DXArray for justified text - getDXArray(), - aFontScale.getX()); // create primitives for the outlines const sal_uInt32 nCount(rTarget.size()); @@ -300,29 +328,22 @@ namespace drawinglayer // the font size. Since we want to extract polygons here, it is okay to // work just with scaling and to ignore shear, rotation and translation, // all that can be applied to the polygons later -#ifdef WIN32 - const bool bCorrectScale(!basegfx::fTools::equal(fabs(aScale.getX()), fabs(aScale.getY()))); -#endif - basegfx::B2DVector aFontScale; - getCorrectedScaleAndFontScale(aScale, aFontScale); + const basegfx::B2DVector aFontScale(getCorrectedScaleAndFontScale(aScale)); // prepare textlayoutdevice TextLayouterDevice aTextLayouter; - aTextLayouter.setFontAttributes(getFontAttributes(), aFontScale.getX(), aFontScale.getY(), getLocale()); + aTextLayouter.setFontAttributes( + getFontAttributes(), + aFontScale.getX(), + aFontScale.getY(), + getLocale()); // get basic text range basegfx::B2DRange aNewRange(aTextLayouter.getTextBoundRect(getText(), getTextPosition(), getTextLength())); - // #i102556# take empty results into account + // #i104432#, #i102556# take empty results into account if(!aNewRange.isEmpty()) { -#ifdef WIN32 - // when under Windows and the font is unequally scaled, need to correct font X-Scaling factor - if(bCorrectScale) - { - aScale.setX(aScale.getX() * aTextLayouter.getCurrentFontRelation()); - } -#endif // prepare object transformation for range basegfx::B2DHomMatrix aRangeTransformation; diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index daf8ce5d525f..e5a88812dd10 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -138,79 +138,31 @@ namespace drawinglayer { // decompose matrix to have position and size of text basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rTextCandidate.getTextTransform()); - basegfx::B2DVector aScale, aTranslate; + basegfx::B2DVector aFontScaling, aTranslate; double fRotate, fShearX; - aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX); + aLocalTransform.decompose(aFontScaling, aTranslate, fRotate, fShearX); bool bPrimitiveAccepted(false); if(basegfx::fTools::equalZero(fShearX)) { - if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0)) + if(basegfx::fTools::less(aFontScaling.getX(), 0.0) && basegfx::fTools::less(aFontScaling.getY(), 0.0)) { // handle special case: If scale is negative in (x,y) (3rd quadrant), it can - // be expressed as rotation by PI - aScale = basegfx::absolute(aScale); + // be expressed as rotation by PI. Use this since the Font rendering will not + // apply the negative scales in any form + aFontScaling = basegfx::absolute(aFontScaling); fRotate += F_PI; } - if(basegfx::fTools::more(aScale.getX(), 0.0) && basegfx::fTools::more(aScale.getY(), 0.0)) + if(basegfx::fTools::more(aFontScaling.getX(), 0.0) && basegfx::fTools::more(aFontScaling.getY(), 0.0)) { - // #i96581# Get the font forced without FontStretching (use FontHeight as FontWidth) + // Get the VCL font (use FontHeight as FontWidth) Font aFont(primitive2d::getVclFontFromFontAttributes( rTextCandidate.getFontAttributes(), - - // #i100373# FontScaling - // - // There are two different definitions for unscaled fonts, (1) 0==width and - // (2) height==width where (2) is the more modern one supported on all non-WIN32 - // systems and (1) is the old one coming from WIN16-VCL definitions where - // that ominous FontWidth (available over FontMetric) is involved. While - // WIN32 only supports (1), all other systems support (2). When on WIN32, the - // support for (1) is ensured inside getVclFontFromFontAttributes. - // - // The former usage of (2) leads to problems when it is used on non-WIN32 systems - // and exported to MetaFile FontActions where the scale is taken over unseen. When - // such a MetaFile is imported on a WIN32-System supporting (1), all fonts are - // seen as scaled an look wrong. - // - // The simplest and fastest solution is to fallback to (1) independent from the - // system we are running on. - // - // The best solution would be a system-independent Y-value just expressing the - // font scaling, e.g. when (2) is used and width == height, use 1.0 as Y-Value, - // which would also solve the involved ominous FontWidth value for WIN32-systems. - // This is a region which needs redesign urgently. - // - 0, // aScale.getY(), - - aScale.getY(), + aFontScaling.getX(), + aFontScaling.getY(), fRotate, - rTextCandidate.getLocale(), - *mpOutputDevice)); - - if(!basegfx::fTools::equal(aScale.getX(), aScale.getY())) - { - // #100424# We have a hint on FontScaling here. To decide a look - // at the pure font's scale is needed, since e.g. SC uses unequally scaled - // MapModes (was: #i96581#, but use available full precision from primitive - // now). aTranslate and fShearX can be reused since no longer needed. - basegfx::B2DVector aFontScale; - double fFontRotate; - rTextCandidate.getTextTransform().decompose(aFontScale, aTranslate, fFontRotate, fShearX); - - if(!basegfx::fTools::equal(aFontScale.getX(), aFontScale.getY())) - { - // indeed a FontScaling. Set at Font. Use the combined scale - // and rotate here - aFont = primitive2d::getVclFontFromFontAttributes( - rTextCandidate.getFontAttributes(), - aScale.getX(), - aScale.getY(), - fRotate, - rTextCandidate.getLocale(), - *mpOutputDevice); - } - } + rTextCandidate.getLocale())); // handle additional font attributes const primitive2d::TextDecoratedPortionPrimitive2D* pTCPP = @@ -314,10 +266,11 @@ namespace drawinglayer if(rTextCandidate.getDXArray().size()) { aTransformedDXArray.reserve(rTextCandidate.getDXArray().size()); - const basegfx::B2DVector aPixelVector(aLocalTransform * basegfx::B2DVector(1.0, 0.0)); + const basegfx::B2DVector aPixelVector(maCurrentTransformation * basegfx::B2DVector(1.0, 0.0)); const double fPixelVectorFactor(aPixelVector.getLength()); - for(::std::vector< double >::const_iterator aStart(rTextCandidate.getDXArray().begin()); aStart != rTextCandidate.getDXArray().end(); aStart++) + for(::std::vector< double >::const_iterator aStart(rTextCandidate.getDXArray().begin()); + aStart != rTextCandidate.getDXArray().end(); aStart++) { aTransformedDXArray.push_back(basegfx::fround((*aStart) * fPixelVectorFactor)); } diff --git a/eventattacher/source/eventattacher.cxx b/eventattacher/source/eventattacher.cxx index 04ed033862c1..b61548c0fa3c 100644 --- a/eventattacher/source/eventattacher.cxx +++ b/eventattacher/source/eventattacher.cxx @@ -882,7 +882,7 @@ void * SAL_CALL component_getFactory( { Reference< XSingleServiceFactory > xFactory( createOneInstanceFactory( reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), - OUString( RTL_CONSTASCII_USTRINGPARAM( pImplName ) ), + OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLNAME ) ), ::comp_EventAttacher::EventAttacherImpl_CreateInstance, ::comp_EventAttacher::EventAttacherImpl::getSupportedServiceNames_Static() ) ); diff --git a/eventattacher/source/makefile.mk b/eventattacher/source/makefile.mk index 1a1cbe3f751a..f642559b8000 100644 --- a/eventattacher/source/makefile.mk +++ b/eventattacher/source/makefile.mk @@ -40,6 +40,7 @@ ENABLE_EXCEPTIONS=TRUE .INCLUDE : settings.mk # ------------------------------------------------------------------ +.IF "$(L10N_framework)"=="" SLOFILES= \ $(SLO)$/eventattacher.obj @@ -59,6 +60,8 @@ SHL1STDLIBS= \ SHL1DEPN= SHL1LIBS= $(SLB)$/$(TARGET).lib +.ENDIF # L10N_framework + # --- Targets ------------------------------------------------------ .INCLUDE : target.mk diff --git a/fileaccess/source/makefile.mk b/fileaccess/source/makefile.mk index 36906af4e103..ff9eaab41f40 100644 --- a/fileaccess/source/makefile.mk +++ b/fileaccess/source/makefile.mk @@ -40,6 +40,7 @@ COMPRDB=$(SOLARBINDIR)$/types.rdb # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" # ------------------------------------------------------------------ SLOFILES= \ @@ -65,6 +66,7 @@ SHL1DEPN= SHL1LIBS=$(SLB)$/$(TARGET).lib # --- Targets ------------------------------------------------------ +.ENDIF # L10N_framework .INCLUDE : target.mk diff --git a/fpicker/source/aqua/makefile.mk b/fpicker/source/aqua/makefile.mk index cd52ddfb6c9f..e6a8247480c9 100644 --- a/fpicker/source/aqua/makefile.mk +++ b/fpicker/source/aqua/makefile.mk @@ -40,7 +40,6 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk -.INCLUDE : $(PRJ)$/util$/makefile.pmk DLLPRE= @@ -52,7 +51,7 @@ dummy: @echo "Nothing to build. GUIBASE == $(GUIBASE)" .ELSE # we build for aqua - +CFLAGSCXX+=$(OBJCXXFLAGS) # --- Files -------------------------------------------------------- diff --git a/fpicker/source/unx/kde4/KDE4FilePicker.cxx b/fpicker/source/unx/kde4/KDE4FilePicker.cxx index d6d852c71d93..09e33a225977 100644 --- a/fpicker/source/unx/kde4/KDE4FilePicker.cxx +++ b/fpicker/source/unx/kde4/KDE4FilePicker.cxx @@ -1,11 +1,4 @@ /************************************************************************* - * - * - * - * - * - * - * * The Contents of this file are made available subject to the terms of * either of the following licenses * @@ -136,7 +129,8 @@ namespace rtl::OUString toOUString(const QString& s) { - return rtl::OUString(s.toUtf8().data(), s.length(), RTL_TEXTENCODING_UTF8); + // QString stores UTF16, just like OUString + return rtl::OUString(reinterpret_cast<const sal_Unicode*>(s.data()), s.length()); } QString toQString(const rtl::OUString& s) diff --git a/fpicker/util/makefile.pmk b/fpicker/util/makefile.pmk deleted file mode 100644 index 15e00b88eda4..000000000000 --- a/fpicker/util/makefile.pmk +++ /dev/null @@ -1,35 +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: makefile.pmk,v $ -# -# $Revision: 1.3 $ -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -.IF "$(GUIBASE)"=="aqua" -OBJCXXFLAGS=-x objective-c++ -fobjc-exceptions -CFLAGSCXX+=$(OBJCXXFLAGS) -.ENDIF # "$(GUIBASE)"=="aqua" diff --git a/framework/inc/classes/fwktabwindow.hxx b/framework/inc/classes/fwktabwindow.hxx index ba6a2522c2c7..80e4b8144bb0 100644 --- a/framework/inc/classes/fwktabwindow.hxx +++ b/framework/inc/classes/fwktabwindow.hxx @@ -84,9 +84,6 @@ public: virtual void ActivatePage(); virtual void DeactivatePage(); virtual void Resize(); - - void Reset(); - void Save(); }; struct TabEntry @@ -131,7 +128,6 @@ public: FwkTabPage* AddTabPage( sal_Int32 nIndex, const css::uno::Sequence< css::beans::NamedValue >& rProperties ); void ActivatePage( sal_Int32 nIndex ); void RemovePage( sal_Int32 nIndex ); - sal_Int32 GetActivePageId() const;
virtual void Resize(); }; diff --git a/framework/inc/dispatch/menudispatcher.hxx b/framework/inc/dispatch/menudispatcher.hxx index 3f52e952c825..0c76dbf96983 100644 --- a/framework/inc/dispatch/menudispatcher.hxx +++ b/framework/inc/dispatch/menudispatcher.hxx @@ -312,8 +312,6 @@ class MenuDispatcher : // interfaces static sal_Bool impldbg_checkParameter_MenuDispatcher ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , const css::uno::Reference< css::frame::XFrame >& xOwner ); - static sal_Bool impldbg_checkParameter_dispatch ( const css::util::URL& aURL , - const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ); static sal_Bool impldbg_checkParameter_addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xControl , const css::util::URL& aURL ); static sal_Bool impldbg_checkParameter_removeStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xControl , diff --git a/framework/inc/helper/opluginframedispatcher.hxx b/framework/inc/helper/opluginframedispatcher.hxx deleted file mode 100644 index 4f738825d2ee..000000000000 --- a/framework/inc/helper/opluginframedispatcher.hxx +++ /dev/null @@ -1,353 +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: opluginframedispatcher.hxx,v $ - * $Revision: 1.8 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef __FRAMEWORK_HELPER_OPLUGINFRAMEDISPATCHER_HXX_ -#define __FRAMEWORK_HELPER_OPLUGINFRAMEDISPATCHER_HXX_ - -//_________________________________________________________________________________________________________________ -// my own includes -//_________________________________________________________________________________________________________________ - -#include <threadhelp/threadhelpbase.hxx> -#include <macros/generic.hxx> -#include <macros/xinterface.hxx> -#include <macros/debug.hxx> -#include <general.h> - -//_________________________________________________________________________________________________________________ -// interface includes -//_________________________________________________________________________________________________________________ -#include <com/sun/star/frame/XFrame.hpp> -#include <com/sun/star/frame/XDispatch.hpp> -#include <com/sun/star/frame/XDispatchProvider.hpp> -#include <com/sun/star/mozilla/XPluginInstance.hpp> -#include <com/sun/star/mozilla/XPluginInstancePeer.hpp> -#include <com/sun/star/mozilla/XPluginInstanceNotifySink.hpp> -#include <com/sun/star/util/URL.hpp> -#include <com/sun/star/frame/DispatchDescriptor.hpp> -#include <com/sun/star/io/XInputStream.hpp> -#include <com/sun/star/beans/PROPERTYVALUE.hpp> - -//_________________________________________________________________________________________________________________ -// other includes -//_________________________________________________________________________________________________________________ -#include <cppuhelper/implbase3.hxx> -#include <cppuhelper/weakref.hxx> -#include <cppuhelper/interfacecontainer.hxx> - -//_________________________________________________________________________________________________________________ -// namespace -//_________________________________________________________________________________________________________________ - -namespace framework{ - -//_________________________________________________________________________________________________________________ -// exported const -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// exported definitions -//_________________________________________________________________________________________________________________ - -/*-************************************************************************************************************//** - Use OMultiTypeInterfaceContainerHelperVar-template to create new class to get a container - to combine string values with listeners. -*//*-*************************************************************************************************************/ - -struct IMPL_hashCode -{ - size_t operator()(const ::rtl::OUString& sString) const - { - return sString.hashCode(); - } -}; - -typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< ::rtl::OUString , - IMPL_hashCode , - ::std::equal_to< ::rtl::OUString > > IMPL_ListenerContainerHelper ; - -/*-************************************************************************************************************//** - @short - - @descr - - - @implements XInterface - XDispatchProvider - XDispatch - XPluginInstanceNotifySink - @base OWeakObject - - @devstatus ready to use -*//*-*************************************************************************************************************/ - -class OPlugInFrameDispatcher : private ThreadHelpBase , - public ::cppu::WeakImplHelper3< ::com::sun::star::frame::XDispatchProvider, ::com::sun::star::frame::XDispatch, ::com::sun::star::mozilla::XPluginInstanceNotifySink > -{ - //------------------------------------------------------------------------------------------------------------- - // public methods - //------------------------------------------------------------------------------------------------------------- - - public: - - static void AddArguments ( const css::uno::Sequence< css::beans::PropertyValue > & rArgs , - const ::rtl::OUString& rURL ); - static const css::uno::Sequence < css::beans::PropertyValue >* GetArguments ( const ::rtl::OUString& rURL ); - static void RemoveArguments ( const ::rtl::OUString& rURL ); - - //--------------------------------------------------------------------------------------------------------- - // constructor / destructor - //--------------------------------------------------------------------------------------------------------- - - /*-****************************************************************************************************//** - @short standard ctor - @descr These initialize a new instance of ths class with needed informations for work. - - @seealso using at owner - - @param - - @return - - - @onerror - - *//*-*****************************************************************************************************/ - - OPlugInFrameDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , - const css::uno::Reference< css::mozilla::XPluginInstance >& xOwner , - const css::uno::Reference< css::mozilla::XPluginInstancePeer >& xPlugInDLL ); - - //--------------------------------------------------------------------------------------------------------- - // XDispatchProvider - //--------------------------------------------------------------------------------------------------------- - - /*-****************************************************************************************************//** - @short search a dispatcher for given URL - @descr If no interceptor is set on owner, we search for right frame and dispatch URL to it. - If no frame was found, we do nothing. - - @seealso - - - @param "aURL" , URL to dispatch. - @param "sTargetFrameName" , name of searched frame. - @param "nSearchFlags" , flags for searching. - @return A reference a dispatcher for these URL (if someone was found!). - - @onerror We return a NULL-reference. - *//*-*****************************************************************************************************/ - - virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( const css::util::URL& aURL , - const ::rtl::OUString& sTargetFrameName , - sal_Int32 nSearchFlags ) throw( css::uno::RuntimeException ); - - /*-****************************************************************************************************//** - @short search dispatcher for more the one URL - @descr Call this method, if you search dispatcher for more then one URL at the same time. - ( But these mode is not supported yet! ) - - @seealso - - - @param "seqDescripts", descriptor to search more then one dispatcher. - @return A list of founded dispatcher. (if somewhere exist!) - - @onerror An empty list is returned. - *//*-*****************************************************************************************************/ - - virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& seqDescripts ) throw( css::uno::RuntimeException ); - - //--------------------------------------------------------------------------------------------------------- - // XDispatch - //--------------------------------------------------------------------------------------------------------- - - /*-****************************************************************************************************//** - @short dispatch URL with arguments - @descr This class implement XDispatch interface to. We use the implementation of ouer owner - directly to do this. He must support a function impl_loadComponent(). - - @seealso methode <owner>::impl_loadComponent() - - @param "aURL" , URL to dispatch. - @param "seqArguments" , list of optional arguments. - @return - - - @onerror - - *//*-*****************************************************************************************************/ - - virtual void SAL_CALL dispatch( const css::util::URL& aURL , - const css::uno::Sequence< css::beans::PropertyValue >& seqArguments) throw( css::uno::RuntimeException ); - - /*-****************************************************************************************************//** - @short add listener for state events - @descr - - - @seealso - - - @param "xControl" , reference to a valid listener for state events. - @param "aURL" , URL about listener will be informed, if something occured. - @return - - - @onerror - - *//*-*****************************************************************************************************/ - - virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, - const css::util::URL& aURL ) throw( css::uno::RuntimeException ); - - /*-****************************************************************************************************//** - @short remove listener - @descr - - - @seealso - - - @param "xControl" , reference to a valid listener. - @param "aURL" , URL on which listener has registered. - @return - - - @onerror - - *//*-*****************************************************************************************************/ - - virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, - const css::util::URL& aURL ) throw( css::uno::RuntimeException ); - - //--------------------------------------------------------------------------------------------------------- - // XPluginInstanceNotifySink - //--------------------------------------------------------------------------------------------------------- - - /*-****************************************************************************************************//** - @short - - @descr - - - @seealso - - - @param - - @param - - @return - - - @onerror - - *//*-*****************************************************************************************************/ - - void SAL_CALL notifyURL( const ::rtl::OUString& sURL ) throw( css::uno::RuntimeException ); - - //------------------------------------------------------------------------------------------------------------- - // protected methods - //------------------------------------------------------------------------------------------------------------- - - protected: - - /*-****************************************************************************************************//** - @short standard destructor - @descr This method destruct an instance of this class and clear some member. - This method is protected, because its not allowed to use an instance of this class as a member! - You MUST use a pointer. - - @seealso - - - @param - - @return - - - @onerror - - *//*-*****************************************************************************************************/ - - virtual ~OPlugInFrameDispatcher(); - - //------------------------------------------------------------------------------------------------------------- - // private methods - //------------------------------------------------------------------------------------------------------------- - - private: - - /*-****************************************************************************************************//** - @short - - @descr - - - @seealso - - - @param - - @return - - - @onerror - - *//*-*****************************************************************************************************/ - - void impl_sendStatusEvent( const ::rtl::OUString& sURL , - sal_Bool bLoadingSuccessful ); - - //------------------------------------------------------------------------------------------------------------- - // debug methods - // (should be private everyway!) - //------------------------------------------------------------------------------------------------------------- - - /*-****************************************************************************************************//** - @short debug-method to check incoming parameter of some other mehods of this class - @descr The following methods are used to check parameters for other methods - of this class. The return value is used directly for an ASSERT(...). - - @seealso ASSERTs in implementation! - - @param references to checking variables - @return sal_False on invalid parameter<BR> - sal_True otherway - - @onerror - - *//*-*****************************************************************************************************/ - - #ifdef ENABLE_ASSERTIONS - - private: - - static sal_Bool impldbg_checkParameter_OPlugInFrameDispatcherCtor ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , - const css::uno::Reference< css::mozilla::XPluginInstance >& xOwner , - const css::uno::Reference< css::mozilla::XPluginInstancePeer >& xPlugInDLL ); - static sal_Bool impldbg_checkParameter_queryDispatch ( const css::util::URL& aURL , - const ::rtl::OUString& sTargetFrameName , - sal_Int32 nSearchFlags ); - static sal_Bool impldbg_checkParameter_queryDispatches ( const css::uno::Sequence< css::frame::DispatchDescriptor >& seqDescriptor ); - static sal_Bool impldbg_checkParameter_dispatch ( const css::util::URL& aURL , - const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ); - static sal_Bool impldbg_checkParameter_addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xControl , - const css::util::URL& aURL ); - static sal_Bool impldbg_checkParameter_removeStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xControl , - const css::util::URL& aURL ); - static sal_Bool impldbg_checkParameter_notifyURL ( const ::rtl::OUString& sURL ); - - #endif // #ifdef ENABLE_ASSERTIONS - - //------------------------------------------------------------------------------------------------------------- - // variables - // (should be private everyway!) - //------------------------------------------------------------------------------------------------------------- - - private: - - css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// servicemanager to create uno services - css::uno::WeakReference< css::mozilla::XPluginInstance > m_xOwnerWeak ; /// weakreference to owner (Don't use a hard reference. Owner can't delete us then!) - css::uno::Reference< css::mozilla::XPluginInstancePeer > m_xPlugInDLL ; /// Interface for communication with browser. - ::rtl::OUString m_sTargetFrameName ; /// We need it as target for get/postURL. - IMPL_ListenerContainerHelper m_aListenerContainer ; /// Container to combine listeners and URLs. - -}; // class OPlugInFrameDispatcher - -} // namespace framework - -#endif // #ifndef __FRAMEWORK_HELPER_OPLUGINFRAMEDISPATCHER_HXX_ diff --git a/framework/inc/interaction/stillinteraction.hxx b/framework/inc/interaction/quietinteraction.hxx index d77ebe462043..d45d1b97580e 100644 --- a/framework/inc/interaction/stillinteraction.hxx +++ b/framework/inc/interaction/quietinteraction.hxx @@ -28,8 +28,8 @@ * ************************************************************************/ -#ifndef __FRAMEWORK_INTERACTION_STILLINTERACTION_HXX_ -#define __FRAMEWORK_INTERACTION_STILLINTERACTION_HXX_ +#ifndef __FRAMEWORK_INTERACTION_QUIETINTERACTION_HXX_ +#define __FRAMEWORK_INTERACTION_QUIETINTERACTION_HXX_ //_________________________________________________________________________________________________________________ // my own includes @@ -80,7 +80,7 @@ namespace framework{ @modified 12.07.2002 14:06 @by Andreas Schlns */ -class StillInteraction : public css::lang::XTypeProvider +class QuietInteraction : public css::lang::XTypeProvider , public css::task::XInteractionHandler , private ThreadHelpBase , public ::cppu::OWeakObject @@ -130,7 +130,7 @@ class StillInteraction : public css::lang::XTypeProvider @threadsafe not neccessary */ - StillInteraction(); + QuietInteraction(); //_________________________________ /** diff --git a/framework/inc/services/desktop.hxx b/framework/inc/services/desktop.hxx index 04623d369f82..92c575c7b5b5 100644 --- a/framework/inc/services/desktop.hxx +++ b/framework/inc/services/desktop.hxx @@ -440,13 +440,8 @@ class Desktop : // interfaces private: static sal_Bool implcp_ctor ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); - static sal_Bool implcp_addTerminateListener ( const css::uno::Reference< css::frame::XTerminateListener >& xListener ); - static sal_Bool implcp_removeTerminateListener ( const css::uno::Reference< css::frame::XTerminateListener >& xListener ); - static sal_Bool implcp_findFrame ( const ::rtl::OUString& sTargetFrameName , - sal_Int32 nSearchFlags ); static sal_Bool implcp_addEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener ); static sal_Bool implcp_removeEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener ); - static sal_Bool implcp_statusChanged ( const css::frame::FeatureStateEvent& aEvent ); sal_Bool m_bIsTerminated ; /// check flag to protect us against dispose before terminate! /// see dispose() for further informations! diff --git a/framework/inc/services/frame.hxx b/framework/inc/services/frame.hxx index 7c48e44693eb..32e83aed1974 100644 --- a/framework/inc/services/frame.hxx +++ b/framework/inc/services/frame.hxx @@ -400,13 +400,6 @@ class Frame : // interfaces static sal_Bool implcp_ctor ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); static sal_Bool implcp_setActiveFrame ( const css::uno::Reference< css::frame::XFrame >& xFrame ); - static sal_Bool implcp_initialize ( const css::uno::Reference< css::awt::XWindow >& xWindow ); - static sal_Bool implcp_setCreator ( const css::uno::Reference< css::frame::XFramesSupplier >& xCreator ); - static sal_Bool implcp_setName ( const ::rtl::OUString& sName ); - static sal_Bool implcp_findFrame ( const ::rtl::OUString& sTargetFrameName , - sal_Int32 nSearchFlags ); - static sal_Bool implcp_setComponent ( const css::uno::Reference< css::awt::XWindow >& xComponentWindow , - const css::uno::Reference< css::frame::XController >& xController ); static sal_Bool implcp_addFrameActionListener ( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ); static sal_Bool implcp_removeFrameActionListener ( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ); static sal_Bool implcp_addEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener ); diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx index 8b518f1bda07..86dec1a938bf 100644 --- a/framework/inc/services/layoutmanager.hxx +++ b/framework/inc/services/layoutmanager.hxx @@ -397,7 +397,6 @@ namespace framework SingleRowColumnWindowData& rRowColumnWindowData ); ::Point implts_findNextCascadeFloatingPos(); void implts_findNextDockingPos( ::com::sun::star::ui::DockingArea DockingArea, const ::Size& aUIElementSize, ::Point& rVirtualPos, ::Point& rPixelPos ); - void implts_sortActiveElement( const UIElement& aElementData ); ::com::sun::star::awt::Rectangle implts_calcDockingAreaSizes(); void implts_setDockingAreaWindowSizes( const com::sun::star::awt::Rectangle& rBorderSpace ); sal_Bool implts_doLayout( sal_Bool bForceRequestBorderSpace ); @@ -428,8 +427,9 @@ namespace framework sal_Bool impl_parseResourceURL( const rtl::OUString aResourceURL, rtl::OUString& aElementType, rtl::OUString& aElementName ); void implts_notifyListeners( short nEvent, ::com::sun::star::uno::Any aInfoParam ); - +#ifdef DBG_UTIL void implts_checkElementContainer(); +#endif DECL_LINK( OptionsChanged, void* ); DECL_LINK( SettingsChanged, void* ); diff --git a/framework/inc/services/license.hxx b/framework/inc/services/license.hxx index 9e4cb9197275..66810193f1b3 100644 --- a/framework/inc/services/license.hxx +++ b/framework/inc/services/license.hxx @@ -91,7 +91,9 @@ namespace framework FWK_DECLARE_XTYPEPROVIDER DECLARE_XSERVICEINFO +#if 0 DECL_STATIC_LINK( License, Terminate, void* ); +#endif /* XJob... diff --git a/framework/source/accelerators/presethandler.cxx b/framework/source/accelerators/presethandler.cxx index 1c5984184f0f..5ae8a7280b2a 100644 --- a/framework/source/accelerators/presethandler.cxx +++ b/framework/source/accelerators/presethandler.cxx @@ -613,15 +613,6 @@ void PresetHandler::connectToResource( PresetHandler::EConfigType } //----------------------------------------------- -sal_Bool PresetHandler::existsTarget(const ::rtl::OUString& sTarget) const -{ - // SAFE -> ---------------------------------- - ReadGuard aReadLock(m_aLock); - return (m_lTargets.findConst(sTarget) != m_lTargets.end()); - // <- SAFE ---------------------------------- -} - -//----------------------------------------------- void PresetHandler::copyPresetToTarget(const ::rtl::OUString& sPreset, const ::rtl::OUString& sTarget) { diff --git a/framework/source/classes/fwktabwindow.cxx b/framework/source/classes/fwktabwindow.cxx index b9615fdc7a20..d737a2d77308 100644 --- a/framework/source/classes/fwktabwindow.cxx +++ b/framework/source/classes/fwktabwindow.cxx @@ -205,21 +205,6 @@ void FwkTabPage::Resize() } } -// ----------------------------------------------------------------------- - -void FwkTabPage::Reset() -{ - CallMethod( BACK_METHOD ); - ActivatePage(); -} - -// ----------------------------------------------------------------------- - -void FwkTabPage::Save() -{ - CallMethod( OK_METHOD ); -} - // class FwkTabWindow --------------------------------------------- FwkTabWindow::FwkTabWindow( Window* pParent ) : @@ -416,13 +401,6 @@ void FwkTabWindow::RemovePage( sal_Int32 nIndex ) } // ----------------------------------------------------------------------- - -sal_Int32 FwkTabWindow::GetActivePageId() const -{ - return m_aTabCtrl.GetCurPageId(); -} - -// ----------------------------------------------------------------------- void FwkTabWindow::Resize() { Size aPageSize = GetSizePixel(); diff --git a/framework/source/dispatch/closedispatcher.cxx b/framework/source/dispatch/closedispatcher.cxx index 44eaa2062497..25b80650e81a 100644 --- a/framework/source/dispatch/closedispatcher.cxx +++ b/framework/source/dispatch/closedispatcher.cxx @@ -48,6 +48,7 @@ #include <com/sun/star/frame/CommandGroup.hpp> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/awt/XTopWindow.hpp> +#include <com/sun/star/document/XActionLockable.hpp> #include "com/sun/star/beans/XFastPropertySet.hpp" #include <toolkit/helper/vclunohelper.hxx> @@ -171,7 +172,7 @@ void SAL_CALL CloseDispatcher::removeStatusListener(const css::uno::Reference< c //----------------------------------------------- void SAL_CALL CloseDispatcher::dispatchWithNotification(const css::util::URL& aURL , - const css::uno::Sequence< css::beans::PropertyValue >& /*lArguments*/, + const css::uno::Sequence< css::beans::PropertyValue >& lArguments, const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw(css::uno::RuntimeException) { @@ -236,7 +237,20 @@ void SAL_CALL CloseDispatcher::dispatchWithNotification(const css::util::URL& aWriteLock.unlock(); // <- SAFE ---------------------------------- - m_aAsyncCallback.Post(0); + sal_Bool bIsSynchron = sal_False; + for (sal_Int32 nArgs=0; nArgs<lArguments.getLength(); nArgs++ ) + { + if ( lArguments[nArgs].Name.equalsAscii("SynchronMode") ) + { + lArguments[nArgs].Value >>= bIsSynchron; + break; + } + } + + if ( bIsSynchron ) + impl_asyncCallback(0); + else + m_aAsyncCallback.Post(0); } //----------------------------------------------- @@ -540,6 +554,10 @@ sal_Bool CloseDispatcher::implts_establishBackingMode() if (!xFrame.is()) return sal_False; + css::uno::Reference < css::document::XActionLockable > xLock( xFrame, css::uno::UNO_QUERY ); + if ( xLock.is() && xLock->isActionLocked() ) + return sal_False; + css::uno::Reference< css::awt::XWindow > xContainerWindow = xFrame->getContainerWindow(); css::uno::Sequence< css::uno::Any > lArgs(1); lArgs[0] <<= xContainerWindow; diff --git a/framework/source/dispatch/dispatchprovider.cxx b/framework/source/dispatch/dispatchprovider.cxx index 392e5574d82d..a4b330bab2b3 100644 --- a/framework/source/dispatch/dispatchprovider.cxx +++ b/framework/source/dispatch/dispatchprovider.cxx @@ -47,7 +47,7 @@ #include <pattern/window.hxx> #include <threadhelp/transactionguard.hxx> #include <threadhelp/readguard.hxx> -#include <threadhelp/writeguard.hxx>
+#include <threadhelp/writeguard.hxx> #include <dispatchcommands.h> #include <protocols.h> #include <services.h> @@ -224,24 +224,13 @@ css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL Disp return lDispatcher; } -//_________________________________________________________________________________________________________________
-
-::sal_Bool lcl_isCloseDispatch (const css::util::URL& aURL)
-{
- return (
- (aURL.Complete.equals(CMD_UNO_CLOSEDOC )) || - (aURL.Complete.equals(CMD_UNO_CLOSEWIN )) || - (aURL.Complete.equals(CMD_UNO_CLOSEFRAME))
- ); -}
- -//_________________________________________________________________________________________________________________
-
-::sal_Bool lcl_isStartModuleDispatch (const css::util::URL& aURL)
-{
- return (aURL.Complete.equals(CMD_UNO_SHOWSTARTMODULE));
-}
-
+//_________________________________________________________________________________________________________________ + +::sal_Bool lcl_isStartModuleDispatch (const css::util::URL& aURL) +{ + return (aURL.Complete.equals(CMD_UNO_SHOWSTARTMODULE)); +} + //_________________________________________________________________________________________________________________ /** @@ -296,10 +285,10 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_queryDeskt if (sTargetFrameName==SPECIALTARGET_DEFAULT) { if (implts_isLoadableContent(aURL)) - xDispatcher = implts_getOrCreateDispatchHelper( E_DEFAULTDISPATCHER, xDesktop );
-
- if (lcl_isStartModuleDispatch(aURL))
- xDispatcher = implts_getOrCreateDispatchHelper( E_STARTMODULEDISPATCHER, xDesktop );
+ xDispatcher = implts_getOrCreateDispatchHelper( E_DEFAULTDISPATCHER, xDesktop ); + + if (lcl_isStartModuleDispatch(aURL)) + xDispatcher = implts_getOrCreateDispatchHelper( E_STARTMODULEDISPATCHER, xDesktop ); } //----------------------------------------------------------------------------------------------------- @@ -772,7 +761,7 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_getOrCreat CloseDispatcher* pDispatcher = new CloseDispatcher( xFactory, xOwner, sTarget ); xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); } - break;
+ break; case E_STARTMODULEDISPATCHER : { diff --git a/framework/source/dispatch/menudispatcher.cxx b/framework/source/dispatch/menudispatcher.cxx index a17f830a1b7e..1e715f58fddc 100644 --- a/framework/source/dispatch/menudispatcher.cxx +++ b/framework/source/dispatch/menudispatcher.cxx @@ -445,26 +445,6 @@ sal_Bool MenuDispatcher::impldbg_checkParameter_MenuDispatcher( const uno::R } //***************************************************************************************************************** -// We don't know anything about right values of aURL and seqArguments! -// Check valid references only. -sal_Bool MenuDispatcher::impldbg_checkParameter_dispatch( const URL& aURL , - const Sequence< PropertyValue >& seqArguments) -{ - // Set default return value. - sal_Bool bOK = sal_True; - // Check parameter. - if ( - ( &aURL == NULL ) || - ( &seqArguments == NULL ) - ) - { - bOK = sal_False ; - } - // Return result of check. - return bOK ; -} - -//***************************************************************************************************************** // We need a valid URL. What is meaning with "register for nothing"?! // xControl must correct to - nobody can advised otherwise! sal_Bool MenuDispatcher::impldbg_checkParameter_addStatusListener( const uno::Reference< XStatusListener >& xControl, diff --git a/framework/source/inc/accelerators/presethandler.hxx b/framework/source/inc/accelerators/presethandler.hxx index a7c266db52b6..211316758f4c 100644 --- a/framework/source/inc/accelerators/presethandler.hxx +++ b/framework/source/inc/accelerators/presethandler.hxx @@ -356,8 +356,6 @@ class PresetHandler : private ThreadHelpBase // attention! Must be the first bas const css::uno::Reference< css::embed::XStorage >& xDocumentRoot , const ::comphelper::Locale& aLocale = ::comphelper::Locale(::comphelper::Locale::X_NOTRANSLATE())); - sal_Bool existsTarget(const ::rtl::OUString& sTarget) const; - //--------------------------------------- /** @short try to copy the specified preset from the share layer to the user layer and establish it as the diff --git a/framework/source/inc/loadenv/loadenv.hxx b/framework/source/inc/loadenv/loadenv.hxx index 4a49f72df985..40ded72db9f6 100644 --- a/framework/source/inc/loadenv/loadenv.hxx +++ b/framework/source/inc/loadenv/loadenv.hxx @@ -67,7 +67,7 @@ namespace framework{ namespace css = ::com::sun::star; - +class QuietInteraction; //_______________________________________________ // definitions @@ -232,6 +232,8 @@ class LoadEnv : private ThreadHelpBase /** TODO document me ... */ void* m_pCheck; + QuietInteraction* m_pQuietInteraction; + //___________________________________________ // native interface diff --git a/framework/source/interaction/makefile.mk b/framework/source/interaction/makefile.mk index 1399335b6ca8..4ae3564c21f7 100644 --- a/framework/source/interaction/makefile.mk +++ b/framework/source/interaction/makefile.mk @@ -45,7 +45,7 @@ CDEFS+=-DCOMPMOD_NAMESPACE=framework # --- Generate ----------------------------------------------------- -SLOFILES= $(SLO)$/stillinteraction.obj \ +SLOFILES= $(SLO)$/quietinteraction.obj \ $(SLO)$/preventduplicateinteraction.obj # --- Targets ------------------------------------------------------ diff --git a/framework/source/interaction/stillinteraction.cxx b/framework/source/interaction/quietinteraction.cxx index 278053d6f6bb..30130bf37360 100644 --- a/framework/source/interaction/stillinteraction.cxx +++ b/framework/source/interaction/quietinteraction.cxx @@ -6,7 +6,7 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: stillinteraction.cxx,v $ + * $RCSfile: QuietInteraction.cxx,v $ * $Revision: 1.7 $ * * This file is part of OpenOffice.org. @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_framework.hxx" -#include "interaction/stillinteraction.hxx" +#include "interaction/quietinteraction.hxx" //_________________________________________________________________________________________________________________ // my own includes @@ -77,18 +77,18 @@ namespace framework{ // exported definitions //_________________________________________________________________________________________________________________ -DEFINE_XINTERFACE_2( StillInteraction , +DEFINE_XINTERFACE_2( QuietInteraction , OWeakObject , DIRECT_INTERFACE(css::lang::XTypeProvider ) , DIRECT_INTERFACE(css::task::XInteractionHandler) ) -DEFINE_XTYPEPROVIDER_2( StillInteraction , +DEFINE_XTYPEPROVIDER_2( QuietInteraction , css::lang::XTypeProvider , css::task::XInteractionHandler ) //_________________________________________________________________________________________________________________ -StillInteraction::StillInteraction() +QuietInteraction::QuietInteraction() : ThreadHelpBase ( &Application::GetSolarMutex() ) , ::cppu::OWeakObject( ) , m_aRequest ( ) @@ -97,7 +97,7 @@ StillInteraction::StillInteraction() //_________________________________________________________________________________________________________________ -void SAL_CALL StillInteraction::handle( const css::uno::Reference< css::task::XInteractionRequest >& xRequest ) throw( css::uno::RuntimeException ) +void SAL_CALL QuietInteraction::handle( const css::uno::Reference< css::task::XInteractionRequest >& xRequest ) throw( css::uno::RuntimeException ) { // safe the request for outside analyzing everytime! css::uno::Any aRequest = xRequest->getRequest(); @@ -172,7 +172,7 @@ void SAL_CALL StillInteraction::handle( const css::uno::Reference< css::task::XI //_________________________________________________________________________________________________________________ -css::uno::Any StillInteraction::getRequest() const +css::uno::Any QuietInteraction::getRequest() const { /* SAFE { */ ReadGuard aReadLock(m_aLock); @@ -182,7 +182,7 @@ css::uno::Any StillInteraction::getRequest() const //_________________________________________________________________________________________________________________ -sal_Bool StillInteraction::wasUsed() const +sal_Bool QuietInteraction::wasUsed() const { /* SAFE { */ ReadGuard aReadLock(m_aLock); diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index daf0701fff2d..fb10e4fae24c 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -3068,11 +3068,6 @@ void LayoutManager::implts_renumberRowColumnData( return aSize; } -void LayoutManager::implts_sortActiveElement( const UIElement& ) -{ - implts_sortUIElements(); -} - Reference< XUIElement > LayoutManager::implts_createElement( const rtl::OUString& aName ) { Reference< ::com::sun::star::ui::XUIElement > xUIElement; @@ -7038,6 +7033,7 @@ IMPL_LINK( LayoutManager, AsyncLayoutHdl, Timer *, EMPTYARG ) return 0; } +#ifdef DBG_UTIL void LayoutManager::implts_checkElementContainer() { #ifdef DBG_UTIL @@ -7062,6 +7058,7 @@ void LayoutManager::implts_checkElementContainer() } // for ( ; pCheckIter != aUIElementHash.end(); pCheckIter++ ) #endif } +#endif //--------------------------------------------------------------------------------------------------------- // XFrameActionListener diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index d0110e667906..0af8ea0e6587 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -55,7 +55,7 @@ #ifndef __FRAMEWORK_CONSTANT_CONTAINERQUERY_HXX_ #include <constant/containerquery.hxx> #endif -#include <interaction/stillinteraction.hxx> +#include <interaction/quietinteraction.hxx> #include <threadhelp/writeguard.hxx> #include <threadhelp/readguard.hxx> #include <threadhelp/resetableguard.hxx> @@ -172,6 +172,7 @@ LoadEnv::LoadEnv(const css::uno::Reference< css::lang::XMultiServiceFactory >& x : ThreadHelpBase( ) , m_xSMGR (xSMGR) , m_pCheck (this ) + , m_pQuietInteraction( 0 ) { } @@ -348,8 +349,9 @@ void LoadEnv::initializeLoading(const ::rtl::OUString& { nMacroMode = css::document::MacroExecMode::NEVER_EXECUTE; nUpdateMode = css::document::UpdateDocMode::NO_UPDATE; - StillInteraction* pInteraction = new StillInteraction(); - xInteractionHandler = css::uno::Reference< css::task::XInteractionHandler >(static_cast< css::task::XInteractionHandler* >(pInteraction), css::uno::UNO_QUERY); + m_pQuietInteraction = new QuietInteraction(); + m_pQuietInteraction->acquire(); + xInteractionHandler = css::uno::Reference< css::task::XInteractionHandler >(static_cast< css::task::XInteractionHandler* >(m_pQuietInteraction), css::uno::UNO_QUERY); } if ( @@ -1660,8 +1662,7 @@ void LoadEnv::impl_reactForLoadingState() m_xTargetFrame->setName(sFrameName); } } - else - if (m_bReactivateControllerOnError) + else if (m_bReactivateControllerOnError) { // Try to reactivate the old document (if any exists!) css::uno::Reference< css::frame::XController > xOldDoc = m_xTargetFrame->getController(); @@ -1677,8 +1678,7 @@ void LoadEnv::impl_reactForLoadingState() m_bReactivateControllerOnError = sal_False; } } - else - if (m_bCloseFrameOnError) + else if (m_bCloseFrameOnError) { // close empty frames css::uno::Reference< css::util::XCloseable > xCloseable (m_xTargetFrame, css::uno::UNO_QUERY); @@ -1712,7 +1712,25 @@ void LoadEnv::impl_reactForLoadingState() // Otherwhise it hold a might existing stream open! m_lMediaDescriptor.clear(); + css::uno::Any aRequest; + bool bThrow = false; + if ( !m_bLoaded && m_pQuietInteraction && m_pQuietInteraction->wasUsed() ) + { + aRequest = m_pQuietInteraction->getRequest(); + m_pQuietInteraction->release(); + m_pQuietInteraction = 0; + bThrow = true; + } + aReadLock.unlock(); + + if (bThrow) + { + css::uno::Exception aEx; + if ( aRequest >>= aEx ) + throw LoadEnvException( LoadEnvException::ID_GENERAL_ERROR, aEx ); + } + // <- SAFE ---------------------------------- } diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx index a734d0bd1931..62361d619df3 100644 --- a/framework/source/services/desktop.cxx +++ b/framework/source/services/desktop.cxx @@ -2016,47 +2016,6 @@ sal_Bool Desktop::implcp_ctor( const css::uno::Reference< css::lang::XMultiServi //***************************************************************************************************************** // We work with valid listener only. -sal_Bool Desktop::implcp_addTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener ) -{ - return( - ( &xListener == NULL ) || - ( xListener.is() == sal_False ) - ); -} - -//***************************************************************************************************************** -// We work with valid listener only. -sal_Bool Desktop::implcp_removeTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener ) -{ - return( - ( &xListener == NULL ) || - ( xListener.is() == sal_False ) - ); -} - -//***************************************************************************************************************** -// The target frame could be ""(!), but flags must be in range of right enum. -sal_Bool Desktop::implcp_findFrame( const ::rtl::OUString& sTargetFrameName, - sal_Int32 nSearchFlags ) -{ - return( - ( &sTargetFrameName == NULL ) || - ( - ( nSearchFlags != css::frame::FrameSearchFlag::AUTO ) && - ( !( nSearchFlags & css::frame::FrameSearchFlag::PARENT ) ) && - ( !( nSearchFlags & css::frame::FrameSearchFlag::SELF ) ) && - ( !( nSearchFlags & css::frame::FrameSearchFlag::CHILDREN ) ) && - ( !( nSearchFlags & css::frame::FrameSearchFlag::CREATE ) ) && - ( !( nSearchFlags & css::frame::FrameSearchFlag::SIBLINGS ) ) && - ( !( nSearchFlags & css::frame::FrameSearchFlag::TASKS ) ) && - ( !( nSearchFlags & css::frame::FrameSearchFlag::ALL ) ) && - ( !( nSearchFlags & css::frame::FrameSearchFlag::GLOBAL ) ) - ) - ); -} - -//***************************************************************************************************************** -// We work with valid listener only. sal_Bool Desktop::implcp_addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) { return( @@ -2075,15 +2034,6 @@ sal_Bool Desktop::implcp_removeEventListener( const css::uno::Reference< css::la ); } -//***************************************************************************************************************** -sal_Bool Desktop::implcp_statusChanged( const css::frame::FeatureStateEvent& aEvent ) -{ - return( - ( &aEvent == NULL ) || - ( aEvent.FeatureDescriptor.getLength() < 1 ) - ); -} - #endif // #ifdef ENABLE_ASSERTIONS } // namespace framework diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx index a83a7120c40e..0e14404de381 100644 --- a/framework/source/services/frame.cxx +++ b/framework/source/services/frame.cxx @@ -3243,50 +3243,6 @@ sal_Bool Frame::implcp_setActiveFrame( const css::uno::Reference< css::frame::XF } //***************************************************************************************************************** -// We don't accept null pointer ... but NULL-References are allowed! -sal_Bool Frame::implcp_initialize( const css::uno::Reference< css::awt::XWindow >& xWindow ) -{ - return( &xWindow == NULL ); -} - -//***************************************************************************************************************** -// We don't accept null pointer or references! -sal_Bool Frame::implcp_setCreator( const css::uno::Reference< css::frame::XFramesSupplier >& xCreator ) -{ - return ( - ( &xCreator == NULL ) || - ( xCreator.is() == sal_False ) - ); -} - -//***************************************************************************************************************** -// We don't accept null pointer or references! -sal_Bool Frame::implcp_setName( const ::rtl::OUString& sName ) -{ - return( &sName == NULL ); -} - -//***************************************************************************************************************** -// We don't accept null pointer or references! -// An empty target name is allowed => is the same like "_self" -sal_Bool Frame::implcp_findFrame( const ::rtl::OUString& sTargetFrameName, - sal_Int32 /*nSearchFlags*/ ) -{ - return( &sTargetFrameName == NULL ); -} - -//***************************************************************************************************************** -// We don't accept null pointer! -sal_Bool Frame::implcp_setComponent( const css::uno::Reference< css::awt::XWindow >& xComponentWindow , - const css::uno::Reference< css::frame::XController >& xController ) -{ - return ( - ( &xComponentWindow == NULL ) || - ( &xController == NULL ) - ); -} - -//***************************************************************************************************************** sal_Bool Frame::implcp_addFrameActionListener( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ) { return ( diff --git a/framework/source/services/license.cxx b/framework/source/services/license.cxx index 25d117ca50e2..c2a63843d45b 100644 --- a/framework/source/services/license.cxx +++ b/framework/source/services/license.cxx @@ -167,7 +167,7 @@ DEFINE_INIT_SERVICE ( License, ) - +#if 0 IMPL_STATIC_LINK_NOINSTANCE( License, Terminate, void*, EMPTYARG ) { /* @@ -182,6 +182,7 @@ IMPL_STATIC_LINK_NOINSTANCE( License, Terminate, void*, EMPTYARG ) */ return 0; } +#endif static DateTime _oslDateTimeToDateTime(const oslDateTime& aDateTime) { diff --git a/framework/util/makefile.mk b/framework/util/makefile.mk index 61d0da2a4c86..60a44dba706f 100644 --- a/framework/util/makefile.mk +++ b/framework/util/makefile.mk @@ -316,7 +316,7 @@ SHL4OBJS= \ $(SLO)$/statusindicatorfactory.obj \ $(SLO)$/statusindicatorinterfacewrapper.obj \ $(SLO)$/statusindicator.obj \ - $(SLO)$/stillinteraction.obj \ + $(SLO)$/quietinteraction.obj \ $(SLO)$/storageholder.obj \ $(SLO)$/substitutepathvars.obj \ $(SLO)$/tagwindowasmodified.obj \ diff --git a/idl/source/objects/bastype.cxx b/idl/source/objects/bastype.cxx index 9fc48737e34c..4c9d9bb08926 100644 --- a/idl/source/objects/bastype.cxx +++ b/idl/source/objects/bastype.cxx @@ -44,50 +44,31 @@ #ifdef IDL_COMPILER /************************************************************************/ static BOOL ReadRangeSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm, - long nMin, ULONG nMax, long * pValue ) + ULONG nMin, ULONG nMax, ULONG* pValue ) { UINT32 nTokPos = rInStm.Tell(); SvToken * pTok = rInStm.GetToken_Next(); - if( pTok->Is( pName ) ) { - BOOL bOk = TRUE; - BOOL bBraket = rInStm.Read( '(' ); - if( bBraket || rInStm.Read( '=' ) ) + BOOL bOk = FALSE; + if( rInStm.Read( '=' ) ) { - short nSign = 1; pTok = rInStm.GetToken_Next(); - if( pTok->IsChar() && pTok->GetChar() == '-' ) - { - nSign = -1; - pTok = rInStm.GetToken_Next(); - } - else if( pTok->IsChar() && pTok->GetChar() == '+' ) - pTok = rInStm.GetToken_Next(); - if( pTok->IsInteger() ) { ULONG n = pTok->GetNumber(); - if( nSign == -1 || n <= nMax ) - { // nicht ueber dem Maximum - if( (nSign == -1 && n < 0x8000000 - && -(long)n >= nMin) - || ( (nSign == 1 && n >= 0x8000000) || (long)n > nMin) ) - { - *pValue = (long)n; - } - else - bOk = FALSE; + if ( n >= nMin && n <= nMax ) + { + *pValue = n; + bOk = TRUE; } - if( bOk && bBraket ) - bOk = rInStm.Read( ')' ); } - else - bOk = pTok->IsChar() && pTok->GetChar() == ')'; } + if( bOk ) return TRUE; } + rInStm.Seek( nTokPos ); return FALSE; } @@ -590,7 +571,7 @@ BOOL SvUUId::WriteSvIdl( SvStream & rOutStm ) *************************************************************************/ BOOL SvVersion::ReadSvIdl( SvTokenStream & rInStm ) { - long n = 0; + ULONG n = 0; UINT32 nTokPos = rInStm.Tell(); if( ReadRangeSvIdl( SvHash_Version(), rInStm, 0 , 0xFFFF, &n ) ) diff --git a/idl/source/prj/command.cxx b/idl/source/prj/command.cxx index cd3e64c24084..66790b457334 100644 --- a/idl/source/prj/command.cxx +++ b/idl/source/prj/command.cxx @@ -93,7 +93,7 @@ char const * SyntaxStrings[] = { "\t\tAccelConfig, MenuConfig, StatusBarConfig, ToolbarConfig", "\t\tAutomation*", "\t\tAutoUpdate", -"\t\tCachable*, Volatile", +// "\t\tCachable*, Volatile", "\t\tContainer", "\t\tDefault = Identifier", "\t\tExecMethod = Identifier", diff --git a/idl/source/prj/globals.cxx b/idl/source/prj/globals.cxx index 893831a27394..8e7547934616 100644 --- a/idl/source/prj/globals.cxx +++ b/idl/source/prj/globals.cxx @@ -132,7 +132,7 @@ SvGlobalHashNames::SvGlobalHashNames() , MM_SlotId( INS( "SlotId" ) ) , MM_HasCoreId( INS( "HasCoreId" ) ) , MM_Cachable( INS( "Cachable" ) ) - , MM_Volatile( INS( "Volatile" ) ) +// , MM_Volatile( INS( "Volatile" ) ) , MM_Toggle( INS( "Toggle" ) ) , MM_AutoUpdate( INS( "AutoUpdate" ) ) , MM_Synchron( INS( "Synchron" ) ) diff --git a/linguistic/source/lngopt.cxx b/linguistic/source/lngopt.cxx index bd2473528d81..995b0686e2f8 100644 --- a/linguistic/source/lngopt.cxx +++ b/linguistic/source/lngopt.cxx @@ -46,7 +46,9 @@ #include <com/sun/star/registry/XSimpleRegistry.hpp> #include <com/sun/star/registry/XRegistryKey.hpp> #include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/i18n/ScriptType.hpp> #include <unotools/processfactory.hxx> +#include <i18npool/mslangid.hxx> using namespace utl; using namespace osl; @@ -100,13 +102,13 @@ LinguOptions::~LinguOptions() } -BOOL LinguOptions::SetLocale_Impl( INT16 &rLanguage, Any &rOld, const Any &rVal) +BOOL LinguOptions::SetLocale_Impl( INT16 &rLanguage, Any &rOld, const Any &rVal, sal_Int16 nType) { BOOL bRes = FALSE; Locale aNew; rVal >>= aNew; - INT16 nNew = LocaleToLanguage( aNew ); + INT16 nNew = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aNew), nType); if (nNew != rLanguage) { Locale aLocale( CreateLocale( rLanguage ) ); @@ -149,17 +151,17 @@ BOOL LinguOptions::SetValue( Any &rOld, const Any &rVal, INT32 nWID ) case WID_HYPH_MIN_WORD_LENGTH : pnVal = &pData->nHyphMinWordLength; break; case WID_DEFAULT_LOCALE : { - bRes = SetLocale_Impl( pData->nDefaultLanguage, rOld, rVal ); + bRes = SetLocale_Impl( pData->nDefaultLanguage, rOld, rVal, ::com::sun::star::i18n::ScriptType::LATIN ); break; } case WID_DEFAULT_LOCALE_CJK : { - bRes = SetLocale_Impl( pData->nDefaultLanguage_CJK, rOld, rVal ); + bRes = SetLocale_Impl( pData->nDefaultLanguage_CJK, rOld, rVal, ::com::sun::star::i18n::ScriptType::ASIAN ); break; } case WID_DEFAULT_LOCALE_CTL : { - bRes = SetLocale_Impl( pData->nDefaultLanguage_CTL, rOld, rVal ); + bRes = SetLocale_Impl( pData->nDefaultLanguage_CTL, rOld, rVal, ::com::sun::star::i18n::ScriptType::COMPLEX ); break; } default : @@ -227,19 +229,19 @@ void LinguOptions::GetValue( Any &rVal, INT32 nWID ) const case WID_HYPH_MIN_WORD_LENGTH : pnVal = &pData->nHyphMinWordLength; break; case WID_DEFAULT_LOCALE : { - Locale aLocale( CreateLocale( pData->nDefaultLanguage ) ); + Locale aLocale( MsLangId::convertLanguageToLocale( pData->nDefaultLanguage ) ); rVal.setValue( &aLocale, ::getCppuType((Locale*)0 )); break; } case WID_DEFAULT_LOCALE_CJK : { - Locale aLocale( CreateLocale( pData->nDefaultLanguage_CJK ) ); + Locale aLocale( MsLangId::convertLanguageToLocale( pData->nDefaultLanguage_CJK ) ); rVal.setValue( &aLocale, ::getCppuType((Locale*)0 )); break; } case WID_DEFAULT_LOCALE_CTL : { - Locale aLocale( CreateLocale( pData->nDefaultLanguage_CTL ) ); + Locale aLocale( MsLangId::convertLanguageToLocale( pData->nDefaultLanguage_CTL ) ); rVal.setValue( &aLocale, ::getCppuType((Locale*)0 )); break; } diff --git a/linguistic/source/lngopt.hxx b/linguistic/source/lngopt.hxx index 3a92baa32faf..b424970a929b 100644 --- a/linguistic/source/lngopt.hxx +++ b/linguistic/source/lngopt.hxx @@ -77,7 +77,7 @@ class LinguOptions BOOL SetLocale_Impl( INT16 &rLanguage, ::com::sun::star::uno::Any &rOld, - const ::com::sun::star::uno::Any &rVal); + const ::com::sun::star::uno::Any &rVal, sal_Int16 nType ); public: LinguOptions(); diff --git a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu index 26143aa76407..355879f036ac 100644 --- a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu @@ -1245,7 +1245,7 @@ </node> <node oor:name="V_SHIFT_MOD1" oor:op="replace"> <prop oor:name="Command"><value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value> - <value xml:lang="en-US">.uno:PasteClipboard</value> + <value xml:lang="en-US">.uno:PasteSpecial</value> </prop> </node> <node oor:name="X_MOD1" oor:op="replace"> @@ -1872,7 +1872,19 @@ </node> </node> <node oor:name="com.sun.star.presentation.PresentationDocument" oor:op="replace"> - <node oor:name="1_MOD1" oor:op="replace"> + <node oor:name="PAGEDOWN_MOD1_MOD2" oor:op="replace"> + <prop oor:name="Command"> + <value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value> + <value xml:lang="en-US">.uno:NextAnnotation</value> + </prop> + </node> + <node oor:name="PAGEUP_MOD1_MOD2" oor:op="replace"> + <prop oor:name="Command"> + <value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value> + <value xml:lang="en-US">.uno:PreviousAnnotation</value> + </prop> + </node> + <node oor:name="1_MOD1" oor:op="replace"> <prop oor:name="Command"><value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value> <value xml:lang="en-US">.uno:SpacePara1</value> </prop> @@ -2200,7 +2212,7 @@ </node> <node oor:name="V_SHIFT_MOD1" oor:op="replace"> <prop oor:name="Command"><value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value> - <value xml:lang="en-US">.uno:PasteClipboard</value> + <value xml:lang="en-US">.uno:PasteSpecial</value> </prop> </node> <node oor:name="X_MOD1" oor:op="replace"> diff --git a/officecfg/registry/data/org/openoffice/Office/Common.xcu b/officecfg/registry/data/org/openoffice/Office/Common.xcu index 6e25dedba37e..c9747dc9dea0 100644 --- a/officecfg/registry/data/org/openoffice/Office/Common.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Common.xcu @@ -567,4 +567,13 @@ </prop> </node> </node> + <node oor:name="Path"> + <node oor:name="Current"> + <prop oor:name="Temp" oor:type="xs:string"> + <value install:module="macosx">$(userurl)/temp</value> + <value install:module="unx">$(temp)</value> + <value install:module="wnt">$(temp)</value> + </prop> + </node> + </node> </oor:component-data> diff --git a/officecfg/registry/data/org/openoffice/Office/Paths.xcu b/officecfg/registry/data/org/openoffice/Office/Paths.xcu index e4bec2eaee19..b979f0f097c3 100644 --- a/officecfg/registry/data/org/openoffice/Office/Paths.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Paths.xcu @@ -179,12 +179,13 @@ <node oor:name="Temp" oor:op="fuse" oor:mandatory="true"> <prop oor:name="IsSinglePath" oor:finalized="true"> - <value>true</value> + <value>true</value> </prop> - <node oor:name="InternalPaths" oor:finalized="true" /> - <prop oor:name="UserPaths" oor:finalized="true" /> + <node oor:name="InternalPaths" oor:finalized="true"/> + <prop oor:name="UserPaths" oor:finalized="true"/> <prop oor:name="WritePath"> - <value>$(temp)</value> + <value install:module="macosx">$(userurl)/temp</value> + <value install:module="unxwnt">$(temp)</value> </prop> </node> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu index 991ea9a64d10..8c76a2dadd9f 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu @@ -681,12 +681,20 @@ </node> <node oor:name=".uno:NoteVisible" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="en-US">Show Note</value> - </prop> - </node> + <value xml:lang="en-US">Show Comment</value> + </prop> + </node> + <node oor:name=".uno:InsertAnnotation" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Comm~ent</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> <node oor:name=".uno:DeleteNote" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="en-US">Delete Note</value> + <value xml:lang="en-US">Delete Comment</value> </prop> </node> <node oor:name=".uno:InputLineVisible" oor:op="replace"> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu index 104fb106836c..b4d7127a2c89 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu @@ -651,7 +651,7 @@ <value xml:lang="en-US">~Page...</value> </prop> </node> - <node oor:name=".uno:PasteClipboard" oor:op="replace"> + <node oor:name=".uno:PasteSpecial" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">Paste ~Special...</value> @@ -1743,7 +1743,12 @@ <value xml:lang="en-US">~Slide Show</value> </prop> </node> - <node oor:name=".uno:GroupMenu" oor:op="replace"> + <!--node oor:name=".uno:ReviewMenu" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">~Review</value> + </prop> + </node--> + <node oor:name=".uno:GroupMenu" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">~Group</value> @@ -2061,6 +2066,54 @@ <value>1</value> </prop> </node> + <node oor:name=".uno:InsertAnnotation" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Comme~nt</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> + <node oor:name=".uno:ShowAnnotation" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Comme~nts</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> + <node oor:name=".uno:DeleteAnnotation" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">~Delete Comment</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> + <node oor:name=".uno:DeleteAllAnnotation" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Delete ~All Comments</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> + <node oor:name=".uno:NextAnnotation" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Next Comment</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> + <node oor:name=".uno:PreviousAnnotation" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Previous Comment</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> </node> </node> </oor:component-data> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu index 9e6a1be3c80e..e0db837c21a5 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu @@ -666,7 +666,21 @@ <value>true</value> </prop> </node> - <node oor:name="private:resource/toolbar/masterviewtoolbar" oor:op="replace"> + <node oor:name="private:resource/toolbar/commentsbar" oor:op="replace"> + <prop oor:name="Docked" oor:type="xs:boolean"> + <value>false</value> + </prop> + <prop oor:name="Visible" oor:type="xs:boolean"> + <value>false</value> + </prop> + <prop oor:name="UIName" oor:type="xs:string"> + <value xml:lang="en-US">Comments</value> + </prop> + <prop oor:name="HideFromToolbarMenu" oor:type="xs:boolean"> + <value>false</value> + </prop> + </node> + <node oor:name="private:resource/toolbar/masterviewtoolbar" oor:op="replace"> <prop oor:name="Docked" oor:type="xs:boolean"> <value>false</value> </prop> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index 9edbd84d74ce..fa69145371f4 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -1951,7 +1951,7 @@ </node> <node oor:name=".uno:InsertAnnotation" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="en-US">Not~e</value> + <value xml:lang="en-US">Comme~nt</value> </prop> <prop oor:name="Properties" oor:type="xs:int"> <value>1</value> @@ -5134,17 +5134,17 @@ </node> --> <node oor:name=".uno:DeleteAllNotes" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="en-US">Delete All Notes</value> + <value xml:lang="en-US">Delete All Comments</value> </prop> </node> <node oor:name=".uno:DeleteAuthor" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="en-US">Delete All Notes by This Author</value> + <value xml:lang="en-US">Delete All Comments by This Author</value> </prop> </node> <node oor:name=".uno:DeleteNote" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="en-US">Delete Note</value> + <value xml:lang="en-US">Delete Comment</value> </prop> </node> </node> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu index 86bf55f3dc51..cc309efb2f59 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu @@ -196,7 +196,7 @@ <value>false</value> </prop> </node> - <node oor:name="private:resource/toolbar/formtextobjectbar" oor:op="replace"> + <node oor:name="private:resource/toolbar/formtextobjectbar" oor:op="replace"> <prop oor:name="UIName" oor:type="xs:string"> <value xml:lang="en-US">Text Box Formatting</value> </prop> @@ -761,7 +761,21 @@ <value>true</value> </prop> </node> - <node oor:name="private:resource/toolbar/masterviewtoolbar" oor:op="replace"> + <node oor:name="private:resource/toolbar/commentsbar" oor:op="replace"> + <prop oor:name="Docked" oor:type="xs:boolean"> + <value>false</value> + </prop> + <prop oor:name="Visible" oor:type="xs:boolean"> + <value>false</value> + </prop> + <prop oor:name="UIName" oor:type="xs:string"> + <value xml:lang="en-US">Comments</value> + </prop> + <prop oor:name="HideFromToolbarMenu" oor:type="xs:boolean"> + <value>false</value> + </prop> + </node> + <node oor:name="private:resource/toolbar/masterviewtoolbar" oor:op="replace"> <prop oor:name="Docked" oor:type="xs:boolean"> <value>false</value> </prop> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu index 55365975b790..0ba86ef6b1aa 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu @@ -41,7 +41,7 @@ </node> <node oor:name=".uno:ShowAnnotations" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="en-US">Notes</value> + <value xml:lang="en-US">Comments</value> </prop> </node> <node oor:name=".uno:InsertScript" oor:op="replace"> @@ -330,7 +330,7 @@ </node> <node oor:name=".uno:InsertAnnotation" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="en-US">~Note</value> + <value xml:lang="en-US">Comme~nt</value> </prop> <prop oor:name="Properties" oor:type="xs:int"> <value>1</value> diff --git a/officecfg/registry/data/org/openoffice/Office/makefile.mk b/officecfg/registry/data/org/openoffice/Office/makefile.mk index 52f31ee38261..50b67954aeef 100644 --- a/officecfg/registry/data/org/openoffice/Office/makefile.mk +++ b/officecfg/registry/data/org/openoffice/Office/makefile.mk @@ -86,6 +86,8 @@ MODULEFILES= \ Common-cjk.xcu \ Common-ctl.xcu \ Common-korea.xcu \ + Paths-macosx.xcu \ + Paths-unxwnt.xcu \ Writer-cjk.xcu \ Writer-defaultfontarial.xcu \ Writer-directcursor.xcu \ diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs index fd7c52ef4df2..1ab6b58b4d13 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs @@ -124,8 +124,8 @@ <!-- UIHints: Tools - Options -Spreadsheets - Contents - [Section] Display --> <info> <author>NN</author> - <desc>Indicates whether notes are marked.</desc> - <label>Note tags</label> + <desc>Indicates whether comments are marked.</desc> + <label>Comment tags</label> </info> <value>true</value> </prop> diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index e6218530561c..72c0b768ed84 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -903,6 +903,12 @@ Dymamic border coloring means that when the mouse is hovered over a control, and <desc>Contains a list of passwords encoded with the master password.</desc> </info> </set> + <prop oor:name="AuthenticateUsingSystemCredentials" oor:type="oor:string-list"> + <info> + <author>KSO</author> + <desc>Contains a list of URLs that should be accessed using system credentials of the user.</desc> + </info> + </prop> </group> <group oor:name="_3D_Engine"> <info> @@ -1657,10 +1663,11 @@ Dymamic border coloring means that when the mouse is hovered over a control, and </prop> <prop oor:name="Temp" oor:type="xs:string"> <info> + <deprecated>Replaced by org.openoffice.Office.Paths/Temp</deprecated> <author>MBA</author> <desc>Specifies the base directory used by the Office to store temp files.</desc> </info> - <value>$(temp)</value> + <value/> </prop> <prop oor:name="Template" oor:type="oor:string-list"> <info> @@ -2358,14 +2365,19 @@ Dymamic border coloring means that when the mouse is hovered over a control, and <desc>ODFVER_011</desc> </info> </enumeration> - <enumeration oor:value="3"> + <enumeration oor:value="4"> <info> <desc>ODFVER_012</desc> </info> </enumeration> - </constraints> - <value>3</value> - </prop> + <enumeration oor:value="3"> + <info> + <desc>ODFVER_LATEST</desc> + </info> + </enumeration> + </constraints> + <value>3</value> + </prop> </group> </group> <group oor:name="Load"> @@ -6003,7 +6015,7 @@ Dymamic border coloring means that when the mouse is hovered over a control, and <!-- UIHints: Edit Search/Replace --> <info> <author>mod</author> - <desc>Specifies if search includes notes(SwPostItFields)</desc> + <desc>Specifies if search includes comments(SwPostItFields)</desc> </info> <value>false</value> </prop> diff --git a/officecfg/registry/schema/org/openoffice/Office/Draw.xcs b/officecfg/registry/schema/org/openoffice/Office/Draw.xcs index f29972ca7fcf..c7e4f71c677c 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Draw.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Draw.xcs @@ -359,18 +359,26 @@ </constraints> <value>0</value> </prop> - <prop oor:name="SimpleHandles" oor:type="xs:boolean"> - <!-- OldPath: Draw/Other --> - <!-- OldLocation: soffice.cfg --> - <!-- UIHints: Optionbar --> + <prop oor:name="ShowComments" oor:type="xs:boolean"> <info> - <author>AF</author> - <desc>Indicates whether to show simple (true) or 3D-handles (false).</desc> - <label>Simple Handles</label> + <author>CL</author> + <desc>Indicates whether to show comments (true) or hide them (false).</desc> + <label>Show Comments</label> </info> <value>true</value> </prop> - <prop oor:name="BigHandles" oor:type="xs:boolean"> + <prop oor:name="SimpleHandles" oor:type="xs:boolean"> + <!-- OldPath: Draw/Other --> + <!-- OldLocation: soffice.cfg --> + <!-- UIHints: Optionbar --> + <info> + <author>AF</author> + <desc>Indicates whether to show simple (true) or 3D-handles (false).</desc> + <label>Simple Handles</label> + </info> + <value>true</value> + </prop> + <prop oor:name="BigHandles" oor:type="xs:boolean"> <!-- OldPath: Draw/Other --> <!-- OldLocation: soffice.cfg --> <!-- UIHints: Optionbar --> diff --git a/officecfg/registry/schema/org/openoffice/Office/Impress.xcs b/officecfg/registry/schema/org/openoffice/Office/Impress.xcs index 6cf3a7abdc68..bfa2e7dce407 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Impress.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Impress.xcs @@ -398,7 +398,15 @@ </constraints> <value>0</value> </prop> - <prop oor:name="SimpleHandles" oor:type="xs:boolean"> + <prop oor:name="ShowComments" oor:type="xs:boolean"> + <info> + <author>CL</author> + <desc>Indicates whether to show comments (true) or hide them (false).</desc> + <label>Show Comments</label> + </info> + <value>true</value> + </prop> + <prop oor:name="SimpleHandles" oor:type="xs:boolean"> <!-- OldPath: Impress/Other --> <!-- OldLocation: soffice.cfg --> <!-- UIHints: Optionbar --> diff --git a/officecfg/registry/schema/org/openoffice/Office/UI.xcs b/officecfg/registry/schema/org/openoffice/Office/UI.xcs index 02e90d75daef..48368c263b34 100644 --- a/officecfg/registry/schema/org/openoffice/Office/UI.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/UI.xcs @@ -418,11 +418,11 @@ </group> <group oor:name="CalcNotesBackground"> <info> - <desc>Specifies the settings used for the background of notes in Calc.</desc> + <desc>Specifies the settings used for the background of comments in Calc.</desc> </info> <prop oor:name="Color" oor:type="xs:int"> <info> - <desc>Specifies the color used for the background of notes.</desc> + <desc>Specifies the color used for the background of comments.</desc> </info> </prop> </group> diff --git a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs index 1b21017e3f3c..cb22883eba09 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs @@ -1097,8 +1097,8 @@ <!-- UIHints: Tools - Options - Text document - Contents - [Section] Display --> <info> <author>OS</author> - <desc>Specifies if notes are displayed.</desc> - <label>Notes</label> + <desc>Specifies if comments are displayed.</desc> + <label>Comments</label> </info> <value>true</value> </prop> @@ -2145,7 +2145,7 @@ <!-- UIHints: Tools - Options - Text document - Print - [Section] Notes --> <info> <author>OS</author> - <desc>Specifies if and how notes are printed.</desc> + <desc>Specifies if and how comments are printed.</desc> </info> <constraints> <enumeration oor:value="0"> @@ -2155,7 +2155,7 @@ </enumeration> <enumeration oor:value="1"> <info> - <desc>Notes only</desc> + <desc>Comments only</desc> </info> </enumeration> <enumeration oor:value="2"> @@ -5659,13 +5659,13 @@ </group> <group oor:name="Notes"> <info> - <desc>Contains settings for notes</desc> + <desc>Contains settings for comments</desc> </info> <prop oor:name="ShowAnkor" oor:type="xs:boolean"> <info> <author>mod</author> - <desc>configures if note anchor should be shown or hidden when display is off</desc> - <label>Notes Ankor on/off</label> + <desc>configures if comment anchor should be shown or hidden when display is off</desc> + <label>Comments Ankor on/off</label> </info> <value>false</value> </prop> @@ -6983,7 +6983,7 @@ </prop> <prop oor:type="xs:boolean" oor:name="ShowNotes"> <info> - <desc>Show the "notes" heading ? </desc> + <desc>Show the "comments" heading ? </desc> </info> </prop> diff --git a/officecfg/registry/schema/org/openoffice/Office/WriterWeb.xcs b/officecfg/registry/schema/org/openoffice/Office/WriterWeb.xcs index 6063ce1b55c9..ebb9fca30962 100644 --- a/officecfg/registry/schema/org/openoffice/Office/WriterWeb.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/WriterWeb.xcs @@ -93,8 +93,8 @@ <!-- UIHints: Tools - Option - HTML-Document Contents - [Section] Display --> <info> <author>OS</author> - <desc>Specifies if notes are displayed.</desc> - <label>Notes</label> + <desc>Specifies if comments are displayed.</desc> + <label>Comments</label> </info> <value>true</value> </prop> @@ -686,7 +686,7 @@ <!-- UIHints: Tools - Option - HTML-Document Print - [Section] Notes --> <info> <author>OS</author> - <desc>Specifies if notes are printed and how they are printed.</desc> + <desc>Specifies if comments are printed and how they are printed.</desc> </info> <constraints> <enumeration oor:value="0"> @@ -696,7 +696,7 @@ </enumeration> <enumeration oor:value="1"> <info> - <desc>Notes only</desc> + <desc>Comments only</desc> </info> </enumeration> <enumeration oor:value="2"> diff --git a/officecfg/util/alllang.xsl b/officecfg/util/alllang.xsl index 86b2dbe752b8..bd4e7934643c 100644 --- a/officecfg/util/alllang.xsl +++ b/officecfg/util/alllang.xsl @@ -61,7 +61,7 @@ <xsl:choose> <xsl:when test="string-length($locale)"> <xsl:apply-templates select = "@*" mode="locale"/> - <xsl:apply-templates mode="locale"/> + <xsl:apply-templates select = "node|prop" mode="locale"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates select = "@*"/> @@ -85,7 +85,7 @@ <xsl:if test="descendant::value[@xml:lang=$locale]/../value[not (@xml:lang)]"> <xsl:copy> <xsl:apply-templates select = "@*" mode="locale"/> - <xsl:apply-templates mode = "locale"/> + <xsl:apply-templates select = "node|prop|value" mode = "locale"/> </xsl:copy> </xsl:if> </xsl:when> @@ -93,7 +93,7 @@ <xsl:if test="descendant::value[@xml:lang = $locale]"> <xsl:copy> <xsl:apply-templates select = "@*" mode="locale"/> - <xsl:apply-templates mode = "locale"/> + <xsl:apply-templates select = "node|prop|value" mode = "locale"/> </xsl:copy> </xsl:if> </xsl:otherwise> diff --git a/oovbaapi/genconstidl/makefile.mk b/oovbaapi/genconstidl/makefile.mk index 42219545c672..95363d56c3e9 100644 --- a/oovbaapi/genconstidl/makefile.mk +++ b/oovbaapi/genconstidl/makefile.mk @@ -36,6 +36,8 @@ PRJNAME=oovbaapi .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" + .IF "$(ENABLE_VBA)"!="YES" dummy: @echo "not building vba..." @@ -70,3 +72,7 @@ CLEAN : @$(RM) $(MY_GEN_IDL_PATH)$/*.idl @$(RM) $(foreach,i,$(MYSYMFILES) $(MISC)$/$(i:b).done) +.ELSE +ivo: + $(ECHO) +.ENDIF # L10N_framework diff --git a/oovbaapi/ooo/vba/constants/makefile.mk b/oovbaapi/ooo/vba/constants/makefile.mk index 9fb0e9144d28..0b092e6f7999 100644 --- a/oovbaapi/ooo/vba/constants/makefile.mk +++ b/oovbaapi/ooo/vba/constants/makefile.mk @@ -36,6 +36,7 @@ TARGET=constants PACKAGE=org$/vba$/constants # --- Settings ----------------------------------------------------- + .INCLUDE : $(PRJ)$/util$/makefile.pmk .IF "$(ENABLE_VBA)"!="YES" @@ -43,8 +44,8 @@ dummy: @echo "not building vba..." .ELSE +.IF "$(L10N_framework)"=="" # ------------------------------------------------------------------------ - # I tried to use the IDLFILES target but it failed dismally MY_GEN_IDL_PATH=$(MISC)$/idl MY_GEN_UCR_PATH=$(OUT)$/ucr$/$(PACKAGE) @@ -53,10 +54,12 @@ MYTMPIDLFILES=$(shell @ls $(MY_GEN_IDL_PATH)) MYIDLFILES=$(foreach,i,$(MYTMPIDLFILES) $(MY_GEN_IDL_PATH)$/$(i)) MYURDFILES=$(foreach,i,$(MYIDLFILES) $(MY_GEN_UCR_PATH)$/$(i:b).urd) MYDBTARGET=$(OUT)$/ucr/constants.db - +.ENDIF +.ENDIF .INCLUDE : target.mk +.IF "$(L10N_framework)"=="" ALLTAR: $(MYDBTARGET) $(MY_GEN_UCR_PATH)$/%.urd: $(MY_GEN_IDL_PATH)$/%.idl @@ -66,4 +69,3 @@ $(MYDBTARGET) : $(MYURDFILES) $(MYIDLFILES) $(REGMERGE) $(OUT)$/ucr/constants.db /UCR @$(mktmp $(MYURDFILES)) .ENDIF - diff --git a/oovbaapi/ooo/vba/makefile.mk b/oovbaapi/ooo/vba/makefile.mk index ee63d6373feb..6f9815bfeb72 100644 --- a/oovbaapi/ooo/vba/makefile.mk +++ b/oovbaapi/ooo/vba/makefile.mk @@ -44,7 +44,7 @@ dummy: .ENDIF # ------------------------------------------------------------------------ - +.IF "$(L10N_framework)"="" IDLFILES=\ XErrObject.idl \ XGlobals.idl \ @@ -60,5 +60,5 @@ IDLFILES=\ Globals.idl\ # ------------------------------------------------------------------ - +.ENDIF .INCLUDE : target.mk diff --git a/oovbaapi/util/makefile.mk b/oovbaapi/util/makefile.mk index 97e592a7c053..9fbd349b080f 100644 --- a/oovbaapi/util/makefile.mk +++ b/oovbaapi/util/makefile.mk @@ -45,6 +45,7 @@ dummy: @echo "not building vba..." .ENDIF +.IF "$(L10N_framework)"=="" # ------------------------------------------------------------------ UNOIDLDBFILES= \ $(UCR)$/vba.db \ @@ -53,5 +54,6 @@ UNOIDLDBFILES= \ $(UCR)$/constants.db # --- Targets ------------------------------------------------------ +.ENDIF .INCLUDE : target.mk diff --git a/sandbox/com/sun/star/lib/sandbox/makefile.mk b/sandbox/com/sun/star/lib/sandbox/makefile.mk index f68414510c42..81e7fdcacefa 100644 --- a/sandbox/com/sun/star/lib/sandbox/makefile.mk +++ b/sandbox/com/sun/star/lib/sandbox/makefile.mk @@ -37,6 +37,7 @@ PACKAGE = com$/sun$/star$/lib$/sandbox # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" .IF "$(JDK)" == "gcj" all: @@ -81,7 +82,8 @@ JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) RC_SUBDIRSDEPS=$(JAVATARGET) # --- Targets ------------------------------------------------------ +.ENDIF +.ENDIF .INCLUDE : target.mk -.ENDIF diff --git a/sandbox/util/makefile.mk b/sandbox/util/makefile.mk index 3e02636bc86b..ac5684ec8a87 100644 --- a/sandbox/util/makefile.mk +++ b/sandbox/util/makefile.mk @@ -34,7 +34,7 @@ PRJNAME = sandbox TARGET = lib_sandbox_util # --- Settings ----------------------------------------------------- - +.IF "$(L10N_framework)"=="" .INCLUDE : settings.mk JARCLASSDIRS = com$/sun$/star$/lib$/sandbox @@ -42,5 +42,7 @@ JARTARGET = sandbox.jar JARCOMPRESS = TRUE # --- Targets ------------------------------------------------------ +.ENDIF # L10N_framework .INCLUDE : target.mk + diff --git a/scripting/examples/java/makefile.mk b/scripting/examples/java/makefile.mk index c4a4c2a081dd..b8138c755a62 100755 --- a/scripting/examples/java/makefile.mk +++ b/scripting/examples/java/makefile.mk @@ -36,5 +36,7 @@ TARGET=javaexamples .INCLUDE : ant.mk .IF "$(SOLAR_JAVA)"!="" +.IF "$(L10N_framework)"=="" ALLTAR : ANTBUILD .ENDIF +.ENDIF diff --git a/scripting/examples/makefile.mk b/scripting/examples/makefile.mk index 53660595538e..f071060f0234 100755 --- a/scripting/examples/makefile.mk +++ b/scripting/examples/makefile.mk @@ -34,7 +34,7 @@ TARGET=scriptinginstaller no_common_build_zip=true .INCLUDE : settings.mk - +.IF "$(L10N_framework)"=="" .IF "$(SOLAR_JAVA)"!="" ZIP1FLAGS=-r ZIP1TARGET=ScriptsJava @@ -58,5 +58,5 @@ ZIP5FLAGS=-r ZIP5TARGET=scriptbindinglib ZIP5DIR=$(PRJ)$/workben$/bindings ZIP5LIST=*.xlb Highlight.xdl - +.ENDIF .INCLUDE : target.mk diff --git a/scripting/java/makefile.mk b/scripting/java/makefile.mk index bb87b9da2185..9b3255e6be06 100755 --- a/scripting/java/makefile.mk +++ b/scripting/java/makefile.mk @@ -35,6 +35,8 @@ TARGET=scriptruntimeforjava .INCLUDE : ant.mk +.IF "$(L10N_framework)"=="" .IF "$(SOLAR_JAVA)"!="" ALLTAR : ANTBUILD .ENDIF +.ENDIF diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx index 4b1a4489a4a4..b011eaccacc8 100644 --- a/scripting/source/stringresource/stringresource.cxx +++ b/scripting/source/stringresource/stringresource.cxx @@ -359,8 +359,9 @@ sal_Bool StringResourceImpl::isReadOnly() return m_bReadOnly; } -void StringResourceImpl::setCurrentLocale( const Locale& locale, sal_Bool FindClosestMatch ) - throw (IllegalArgumentException, RuntimeException) +void StringResourceImpl::implSetCurrentLocale( const Locale& locale, + sal_Bool FindClosestMatch, sal_Bool bUseDefaultIfNoMatch ) + throw (IllegalArgumentException, RuntimeException) { ::osl::MutexGuard aGuard( getMutex() ); @@ -370,6 +371,9 @@ void StringResourceImpl::setCurrentLocale( const Locale& locale, sal_Bool FindCl else pLocaleItem = getItemForLocale( locale, true ); + if( pLocaleItem == NULL && bUseDefaultIfNoMatch ) + pLocaleItem = m_pDefaultLocaleItem; + if( pLocaleItem != NULL ) { loadLocale( pLocaleItem ); @@ -380,6 +384,13 @@ void StringResourceImpl::setCurrentLocale( const Locale& locale, sal_Bool FindCl } } +void StringResourceImpl::setCurrentLocale( const Locale& locale, sal_Bool FindClosestMatch ) + throw (IllegalArgumentException, RuntimeException) +{ + sal_Bool bUseDefaultIfNoMatch = false; + implSetCurrentLocale( locale, FindClosestMatch, bUseDefaultIfNoMatch ); +} + void StringResourceImpl::setDefaultLocale( const Locale& locale ) throw (IllegalArgumentException, RuntimeException,NoSupportException) { @@ -500,7 +511,7 @@ void StringResourceImpl::newLocale( const Locale& locale ) LocaleItem* pCopyFromItem = m_pDefaultLocaleItem; if( pCopyFromItem == NULL ) pCopyFromItem = m_pCurrentLocaleItem; - if( pCopyFromItem != NULL ) + if( pCopyFromItem != NULL && loadLocale( pCopyFromItem ) ) { const IdToStringMap& rSourceMap = pCopyFromItem->m_aIdToStringMap; IdToStringMap& rTargetMap = pLocaleItem->m_aIdToStringMap; @@ -863,7 +874,8 @@ void StringResourcePersistenceImpl::implInitializeCommonParameters implScanLocales(); sal_Bool FindClosestMatch = true; - setCurrentLocale( aCurrentLocale, FindClosestMatch ); + sal_Bool bUseDefaultIfNoMatch = true; + implSetCurrentLocale( aCurrentLocale, FindClosestMatch, bUseDefaultIfNoMatch ); } // ----------------------------------------------------------------------------- diff --git a/scripting/source/stringresource/stringresource.hxx b/scripting/source/stringresource/stringresource.hxx index e5e3a7c12a35..71d26f05dec7 100644 --- a/scripting/source/stringresource/stringresource.hxx +++ b/scripting/source/stringresource/stringresource.hxx @@ -169,6 +169,9 @@ protected: // Returns the LocalItem for a given locale, if it exists, otherwise NULL // This method performes a closest match search, at least the language must match LocaleItem* getClosestMatchItemForLocale( const ::com::sun::star::lang::Locale& locale ); + void implSetCurrentLocale( const ::com::sun::star::lang::Locale& locale, + sal_Bool FindClosestMatch, sal_Bool bUseDefaultIfNoMatch ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); void implModified( void ); void implNotifyListeners( void ); 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 <com/sun/star/frame/XModuleManager.hpp> #include <comphelper/sequenceashashmap.hxx> +#include <sfx2/signaturestate.hxx> 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/pch/precompiled_sfx2.hxx b/sfx2/inc/pch/precompiled_sfx2.hxx index ad70b76f27ff..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" @@ -542,7 +541,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/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/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/docfilt.hxx b/sfx2/inc/sfx2/docfilt.hxx index dbeba0763c67..47c1cba003e5 100644 --- a/sfx2/inc/sfx2/docfilt.hxx +++ b/sfx2/inc/sfx2/docfilt.hxx @@ -75,6 +75,20 @@ #include <sfx2/sfxdefs.hxx> //======================================================================== + +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; class SFX2_DLLPUBLIC SfxFilter 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 <NULL/> here if and only if the document + The storage is intended to be used for signing. An implementation is + allowed to return <NULL/> 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 <sfx2/signaturestate.hxx> */ 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 <sfx2/signaturestate.hxx> + */ + virtual sal_Bool + hasTrustedScriptingSignature( sal_Bool bAllowUIToAddAuthor ) = 0; /** shows a warning that the document's signature is broken 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 <tools/string.hxx> #include <svtools/hint.hxx> +#include <svtools/eventcfg.hxx> +#include <rtl/ustring.hxx> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/beans/PropertyValue.hpp> @@ -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 71f1729840c0..7e3813584de9 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -43,6 +43,7 @@ #include <com/sun/star/embed/XStorage.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/security/DocumentSignatureInformation.hpp> +#include <com/sun/star/security/XDocumentDigitalSignatures.hpp> #include <com/sun/star/task/XInteractionHandler.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -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,8 +730,11 @@ 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 SEQUENCE< OUSTRING > GetEventNames_Impl(); SAL_DLLPRIVATE void InitBasicManager_Impl(); SAL_DLLPRIVATE SfxObjectShell_Impl* Get_Impl() { return pImp; } @@ -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/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/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/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 <com/sun/star/uno/Reference.h> #include <svtools/lstner.hxx> #include <com/sun/star/ui/XContextMenuInterceptor.hpp> +#include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp> #include <cppuhelper/interfacecontainer.hxx> #include "shell.hxx" #include <tools/gen.hxx> @@ -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/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= \ 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, @@ -1447,60 +1447,6 @@ SfxVoidItem CreateMacro SID_BASICIDE_CREATEMACRO ] //-------------------------------------------------------------------------- -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, @@ -5035,6 +4981,59 @@ SfxVoidItem Paste SID_PASTE ] //-------------------------------------------------------------------------- +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..af31659ec24c 100644 --- a/sfx2/source/appl/appcfg.cxx +++ b/sfx2/source/appl/appcfg.cxx @@ -62,7 +62,7 @@ #include <sot/exchange.hxx> //#include <svtools/agprop.hxx> -#include <sj2/sjapplet.hxx> +//#include <sj2/sjapplet.hxx> #include <svtools/isethint.hxx> #include <unotools/configmgr.hxx> @@ -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() ) @@ -848,6 +850,8 @@ void SfxApplication::SetOptions_Impl( const SfxItemSet& rSet ) // INet Session neu aufsetzen if ( bResetSession ) { + // no more sj2 + #if 0 try { SjApplet2::settingsChanged(); @@ -856,6 +860,7 @@ void SfxApplication::SetOptions_Impl( const SfxItemSet& rSet ) { DBG_ERRORFILE( "SjApplet2::settingsChanged() throws an exception" ); } + #endif } // geaenderte Daten speichern @@ -1037,21 +1042,29 @@ 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 ) ) 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 ) { +#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/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 <vos/mutex.hxx> #include <vcl/menu.hxx> -#include <svtools/loginerr.hxx> #include <vcl/msgbox.hxx> #include <svtools/dateitem.hxx> #include <vcl/menu.hxx> 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/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/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/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 <ownsubfilterservice.hxx> @@ -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/bastyp/helper.cxx b/sfx2/source/bastyp/helper.cxx index fc16b2649d4a..a463e3f1d075 100644 --- a/sfx2/source/bastyp/helper.cxx +++ b/sfx2/source/bastyp/helper.cxx @@ -828,39 +828,6 @@ ULONG SfxContentHelper::GetSize( const String& rContent ) } // ----------------------------------------------------------------------- - -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/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 <com/sun/star/uno/Reference.hxx> // ----------------------------------------------------------------------- - -#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; i<aNames.getLength(); i++ ) - { - SvxMacro* pMacro = SfxEvents_Impl::ConvertToMacro( xEvents->getByName( 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 <SfxBindings::CreateSet_Impl()> - weitere Informationen zu den gemeinsam von einem <Slot-Server> zu - erfragenden Status gesammelt, deren Ids dort in die Ranges eines - <SfxItemSet>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 <SfxApplication> vor <SfxApplication::Init()> angelegt. Wird - eine Instanz ben"otigt, z.B. zum Invalidieren von Slots, sollte diese - "uber den zugeh"origen <SfxViewFrame> besorgt werden. Bestimmte - SfxViewFrame Subklassen (z.B. <SfxInPlaceFrame>) legen ihre eigene - Instanz der SfxBindings an. - - <SfxControllerItem> 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 <SfxControllerItem> - Instanzen, die bei dieser SfxBindings Instanz angemeldet sind. - - Dies sind i.d.R. <SfxPopupWindow>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 <SfxPopupWindows>, die aus - <SfxToolboxControl>s dieser SfxBindings-Instanz abgerissen wurden bzw. - floating <SfxChildWindow>-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 <SfxContollerItem> 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 - <SfxBindings::Invalidate(sal_uInt16)> erzwungen werden. - - - [Anmerkung] - - Es ist g"unstiger, zun"achst alle zu invalidierenden Slot-Ids per - <SfxBindings::Invalidate(sal_uInt16)> 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] - - <SfxShell::Invalidate(sal_uInt16)> - <SfxBindings::Invalidate(sal_uInt16)> - <SfxBindings::InvalidateAll(sal_Bool)> - <SfxBindings::Update()> -*/ - { 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 <SfxContollerItem> - 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 - <Slot-Server> dirty ist. Ersteres kann durch einen Aufruf von - <SfxBindings::Invalidate(sal_uInt16)> erzwungen werden, letzters durch - <SfxBindings::InvalidateAll(sal_Bool)>. - - - [Querverweise] - - <SfxShell::Invalidate(sal_uInt16)> - <SfxBindings::Invalidate(sal_uInt16)> - <SfxBindings::InvalidateAll(sal_Bool)> - <SfxBindings::Update(sal_uInt16)> -*/ - { 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 <SfxBindings::Invalidate()> und das dann im Update - erfolgende Rufen der Status-Methoden an den <SfxShell>s. - - - [Querverweise] - - <SfxBindings::SetState(const SfxPoolItem&)> -*/ - { // 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 <SfxBindings::Invalidate()> und das dann im Update - erfolgende Rufen der Status-Methoden an den <SfxShell>s. - - Mit dieser Methode k"onnen nur <SfxPoolItem>s mit Slot, nicht - aber mit Which-Id gesetzt werden, da kein <SfxItemPool> bekannt ist, - "uber den gemappt werden k"onnte. - - - [Querverweise] - - <SfxBindings::SetState(const SfxItemSet&)> -*/ - { 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 <SfxStatusCache> - 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 <SfxBindings::EnterRegistrations()> g"ultig. - W"ahrend der Umkonfiguration (<SfxBindings::IsInRegistrations()> == 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 <SfxControllerItem> Instanzen, die an dieser - SfxBindings Instanz angemeldet sind, und bei bWithMsg == sal_True - ebenfalls die <Slot-Server>-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] - - <SfxShell::Invalidate(sal_uInt16)> - <SfxBindings::Invalidate(sal_uInt16)> - <SfxBindings::Invalidate(sal_uInt16*)> - <SfxBindings::Update()> - <SfxBindings::Update(sal_uInt16)> -*/ - { 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 <SfxControllerItem> 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] - - <SfxShell::Invalidate(sal_uInt16)> - <SfxBindings::Invalidate(sal_uInt16)> - <SfxBindings::InvalidateAll(sal_uInt16)> - <SfxBindings::Update()> - <SfxBindings::Update(sal_uInt16)> -*/ - { 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 <SfxControllerItem> 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] - - <SfxShell::Invalidate(sal_uInt16)> - <SfxBindings::Invalidate(sal_uInt16)> - <SfxBindings::Update()> - <SfxBindings::Update(sal_uInt16)> -*/ - { 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 <SfxControllerItem> 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] - <SfxBindings::Invalidate(sal_uInt16*)> - <SfxBindings::InvalidateAll(sal_Bool)> - <SfxBindings::Update()> - <SfxBindings::Update(sal_uInt16)> -*/ - { 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 <SfxControllerItem> Instanzen, die auf die Slot-Id - nId gebunden sind und an dieser SfxBindings Instanz angemeldet sind, - und bei bWithMsg == sal_True ebenfalls den <Slot-Server>-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] - <SfxBindings::Invalidate(sal_uInt16*)> - <SfxBindings::InvalidateAll(sal_Bool)> - <SfxBindings::Update()> - <SfxBindings::Update(sal_uInt16)> -*/ - { 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 <SfxControllerItem> Instanzen, die auf die Slot-Id - nId gebunden sind und an dieser SfxBindings Instanz angemeldet sind, - und bei bWithMsg == sal_True ebenfalls den <Slot-Server>-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] - <SfxBindings::Invalidate(sal_uInt16*)> - <SfxBindings::InvalidateAll(sal_Bool)> - <SfxBindings::Update()> - <SfxBindings::Update(sal_uInt16)> -*/ - -{ - DBG_ERROR( "Methode veraltet!" ); -} - //-------------------------------------------------------------------- sal_Bool SfxBindings::IsBound( sal_uInt16 nSlotId, sal_uInt16 nStartSearchAt ) - -/* [Beschreibung] - - Stellt fest, ob die angegebene Slot-Id in einem <SfxControllerItem> - 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 <Slot-Server> 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 <SfxShell> vorhanden oder - disabled) ist oder der Anwender die Ausf"uhrung - abgebrochen hat (Cancel in einem Dialog). - - - [Querverweise] - <SfxDispatcher> -*/ { 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 <SfxBindings::InvalidateAll(sal_Bool)>. -*/ - { 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 <SfxControllerItem> Instanzen mu"s in - EnterRegistrations() und LeaveRegistrations() geklammert werden. - W"ahrend dieser Zeit erfolgen keine Udates der <SfxContollerItem> - 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 - <SfxBindings::LeaveRegistrations(sal_uInt16)> als - Parameter angegeben werden, um die Paarigkeit - der EnterRegistrations() und LeaveRegistrations() - zu pr"ufen. - - - [Querverweise] - <SfxBindings::IsInRegistrations()> - <SfxBindings::Register(SfxControllerItem&)> - <SfxBindings::Release(SfxControllerItem&)> - <SfxBindings::LeaveRegistrations()> -*/ - { (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 <SfxControllerItem> Instanzen mu"s in - EnterRegistrations() und LeaveRegistrations() geklammert werden. - W"ahrend dieser Zeit erfolgen keine Udates der <SfxContollerItem> - 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] - <SfxBindings::IsInRegistrations()> - <SfxBindings::Register(SfxControllerItem&)> - <SfxBindings::Release(SfxControllerItem&)> - <SfxBindings::EnterRegistrations()> -*/ - { (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 <SfxSlot>* 0 - Falls die Slot-Id nicht gebunden ist oder - ein solcher Slot momentan in keiner aktiven - <SfxShell> vorhanden ist. - - != 0 - Falls die Slot-Id gebunden ist und ein solcher - Slot momentan in einer aktiven <SfxShell> - 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 - <SFxBindings::InvalidateAll(sal_Bool)> 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 6de52384a90c..484e953f1cf4 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 ) { @@ -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/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 ) @@ -550,40 +575,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 ) { if ( ! mbHasPassword ) @@ -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/docfile.cxx b/sfx2/source/doc/docfile.cxx index 23093bfa066f..32ae33ec3c8b 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -84,6 +84,7 @@ #include <unotools/tempfile.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/componentcontext.hxx> +#include <framework/interaction.hxx> #include <unotools/streamhelper.hxx> #include <unotools/localedatawrapper.hxx> #ifndef _MSGBOX_HXX //autogen @@ -106,6 +107,7 @@ #include <unotools/streamwrap.hxx> #include <rtl/logfile.hxx> +#include <osl/file.hxx> 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; } //================================================================ @@ -491,18 +488,6 @@ SfxMedium_Impl::~SfxMedium_Impl() pOutStream( 0 ) //------------------------------------------------------------------ -/* -const SvGlobalName& SfxMedium::GetClassFilter() -{ - GetMedium_Impl(); - if( GetError() ) - return aFilterClass; - if( !bSetFilter && GetStorage() ) - SetClassFilter( GetStorage()->GetClassName() ); - return aFilterClass; -}*/ - -//------------------------------------------------------------------ void SfxMedium::ResetError() { eError = SVSTREAM_OK; @@ -557,15 +542,6 @@ sal_uInt32 SfxMedium::GetErrorCode() const } //------------------------------------------------------------------ -long SfxMedium::GetFileVersion() const -{ - if ( !pImp->nFileVersion && pFilter ) - return pFilter->GetVersion(); - else - return pImp->nFileVersion; -} - -//------------------------------------------------------------------ void SfxMedium::CheckFileDate( const util::DateTime& aInitDate ) { GetInitFileDate( sal_True ); @@ -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(); } @@ -942,82 +917,17 @@ sal_Bool SfxMedium::IsPreview_Impl() } //------------------------------------------------------------------ -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 ); @@ -1036,26 +946,6 @@ void SfxMedium::StorageBackup_Impl() } //------------------------------------------------------------------ -::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() { if ( GetError() ) @@ -1231,24 +1121,38 @@ 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 { // 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 ) {} } + // 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 ) @@ -1408,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(); - - // 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; - } + // the storage should be created for repairing mode + CreateTempFile( sal_False ); + GetMedium_Impl(); - if ( bReadOnly ) - aArgs[1] <<= embed::ElementModes::READ; - else - aArgs[1] <<= embed::ElementModes::READWRITE; - } - } + Reference< ::com::sun::star::ucb::XProgressHandler > xProgressHandler; + Reference< ::com::sun::star::task::XStatusIndicator > xStatusIndicator; - 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; + 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 ) ); - pImp->bStorageBasedOnInStream = sal_False; - } + 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; - 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 ) @@ -1631,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(); @@ -1704,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; @@ -1725,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& ) @@ -1758,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 >(); } } @@ -1873,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" ); @@ -1924,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 ); @@ -2229,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 @@ -2594,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 ) { @@ -2691,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; @@ -2898,7 +2552,7 @@ SfxMedium::SfxMedium( const SfxMedium& rMedium, sal_Bool bTemporary ) pFilter = rMedium.pFilter; Init_Impl(); if( bTemporary ) - CreateTempFile(); + CreateTempFile( sal_True ); } //------------------------------------------------------------------ @@ -2977,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(); @@ -3010,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(); @@ -3050,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; @@ -3172,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 ) { @@ -3395,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 ) @@ -3743,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(); - - 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 ); + sal_uInt64 nAttributes = aFileStatus.getAttributes(); - pImp->xStorage->copyToStorage( xNewStorage ); - //if ( aNewStorage->GetError() == SVSTREAM_OK ) - { - CloseInStream(); - CloseStorage(); - if ( pImp->pTempFile ) - DELETEZ( pImp->pTempFile ); - - 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 ) ) ); + nAttributes &= ~(Attribute_OwnWrite | + Attribute_GrpWrite | + Attribute_OthWrite | + Attribute_ReadOnly); + nAttributes |= Attribute_OwnWrite; - 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(); } @@ -3875,6 +3493,7 @@ void SfxMedium::CreateTempFile() //---------------------------------------------------------------- void SfxMedium::CreateTempFileNoCopy() { + // this call always replaces the existing temporary file if ( pImp->pTempFile ) delete pImp->pTempFile; @@ -3932,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; } @@ -4140,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 @@ -4177,7 +3848,7 @@ BOOL SfxMedium::IsOpen() const GetMedium_Impl(); LockOrigFileOnDemand( sal_False, sal_False ); - CreateTempFile(); + CreateTempFile( sal_True ); GetMedium_Impl(); if ( pImp->xStream.is() ) @@ -4235,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/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) 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 <com/sun/star/document/MacroExecMode.hpp> @@ -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 - <TRUE/> 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/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 <sfx2/docfac.hxx> +#include <sfx2/docfile.hxx> #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(); 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 <sfxtypes.hxx> #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/makefile.mk b/sfx2/source/doc/makefile.mk index 4c893288ebb8..1b42844491e0 100644 --- a/sfx2/source/doc/makefile.mk +++ b/sfx2/source/doc/makefile.mk @@ -48,14 +48,13 @@ 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 \ $(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/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 a7910c463cf9..5e3ace93372a 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -87,6 +87,8 @@ #include <comphelper/configurationhelper.hxx> #include <com/sun/star/security/XDocumentDigitalSignatures.hpp> +#include <com/sun/star/task/DocumentMacroConfirmationRequest2.hpp> +#include <com/sun/star/task/InteractionClassification.hpp> #include <com/sun/star/frame/XModel.hpp> using namespace ::com::sun::star; @@ -120,6 +122,7 @@ using namespace ::com::sun::star::container; #include <vcl/svapp.hxx> #include <framework/interaction.hxx> #include <comphelper/storagehelper.hxx> +#include <comphelper/documentconstants.hxx> #include <sfx2/signaturestate.hxx> #include <sfx2/app.hxx> @@ -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(); } //------------------------------------------------------------------------- @@ -425,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 ) ); } //------------------------------------------------------------------------- @@ -1139,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); } } } @@ -1234,10 +1234,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(); + } + } } //------------------------------------------------------------------------- @@ -1392,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 ) ); @@ -1476,7 +1518,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 +2128,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 +2369,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 +2391,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 +2404,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 a47fc1bf4747..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; @@ -1386,7 +1400,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) @@ -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 5a4aed274c30..cd73a92196d7 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -36,6 +36,7 @@ #endif #include <svtools/eitem.hxx> #include <svtools/stritem.hxx> +#include <svtools/intitem.hxx> #include <tools/zcodec.hxx> #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/frame/XModel.hpp> @@ -370,7 +371,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() ) @@ -521,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; } @@ -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,11 +1209,11 @@ 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) || - (!aODFVersion.getLength() && nVersion == SvtSaveOptions::ODFVER_012) + (!aODFVersion.getLength() && nVersion >= SvtSaveOptions::ODFVER_012) ); } } @@ -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." ) ) ); @@ -3255,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& ) { @@ -3415,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 26ba76517d8c..950ecf9ea239 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -61,6 +61,7 @@ #include <basic/sbstar.hxx> #include <svtools/stritem.hxx> #include <basic/sbx.hxx> +#include <svtools/eventcfg.hxx> #include <sfx2/objsh.hxx> #include <sfx2/signaturestate.hxx> @@ -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 ) @@ -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 ) @@ -581,7 +582,8 @@ sal_uInt16 SfxObjectShell::PrepareClose } } - SFX_APP()->NotifyEvent( SfxEventHint(SFX_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 ) { @@ -886,11 +888,6 @@ SfxObjectShell* SfxObjectShell::GetObjectShell() SEQUENCE< OUSTRING > SfxObjectShell::GetEventNames() { - return GetEventNames_Impl(); -} - -SEQUENCE< OUSTRING > SfxObjectShell::GetEventNames_Impl() -{ static uno::Sequence< ::rtl::OUString >* pEventNameContainer = NULL; if ( !pEventNameContainer ) @@ -898,88 +895,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; } } @@ -987,6 +903,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 d4b0b3aaf7ab..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() ); @@ -2850,19 +2848,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 ); } } @@ -2870,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 @@ -2883,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 ); @@ -2893,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 - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <sfx2/sfx.hrc> -#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/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..77162423cabe 100644 --- a/sfx2/source/inc/objshimp.hxx +++ b/sfx2/source/inc/objshimp.hxx @@ -33,6 +33,8 @@ //#include <hash_map> #include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/uno/Sequence.hxx> +#include <rtl/ustring.hxx> #include <com/sun/star/logging/XSimpleLogRing.hpp> #include <tools/datetime.hxx> @@ -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; @@ -171,6 +173,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 +185,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/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() ); @@ -646,24 +640,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 <sfx2/doctempl.hxx> #include <sfx2/app.hxx> #include <sfx2/request.hxx> #include <sfx2/sfxsids.hrc> @@ -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 0769a782de86..592926bca1ce 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -77,6 +77,7 @@ #include <rtl/ustrbuf.hxx> #include <unotools/localfilehelper.hxx> +#include <unotools/ucbhelper.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/configurationhelper.hxx> @@ -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(); } @@ -863,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 @@ -1141,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) ); @@ -1514,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(); @@ -1521,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 ); @@ -1543,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; } @@ -1572,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 <com/sun/star/beans/PropertyValue.hpp> #include <svtools/acceleratorexecute.hxx> +#include <queue> + // 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 <tools/datetime.hxx> #include <sfx2/viewsh.hxx> +#include <sfx2/dispatch.hxx> #include "viewimp.hxx" #include <sfx2/viewfrm.hxx> #include <sfx2/prnmon.hxx> @@ -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 <com/sun/star/system/SystemShellExecuteFlags.hpp> #include <com/sun/star/container/XContainerQuery.hpp> #include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp> +#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> +#include <cppuhelper/implbase1.hxx> #include <osl/file.hxx> #include <vos/mutex.hxx> @@ -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& ) + { + } +} 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) \ diff --git a/shell/source/aqua/sysshell/makefile.mk b/shell/source/aqua/sysshell/makefile.mk index a748e00c154e..b3cf3abdec36 100644 --- a/shell/source/aqua/sysshell/makefile.mk +++ b/shell/source/aqua/sysshell/makefile.mk @@ -40,7 +40,6 @@ ENABLE_EXCEPTIONS=TRUE .INCLUDE : settings.mk -OBJCXXFLAGS=-x objective-c++ -fobjc-exceptions CFLAGSCXX+=$(OBJCXXFLAGS) # --- Files -------------------------------------------------------- diff --git a/shell/source/aqua/sysshell/systemshell.cxx b/shell/source/aqua/sysshell/systemshell.cxx index a9b4afe1a966..a9535c849f77 100644 --- a/shell/source/aqua/sysshell/systemshell.cxx +++ b/shell/source/aqua/sysshell/systemshell.cxx @@ -71,17 +71,49 @@ static rtl::OUString translateToExternalUrl(const rtl::OUString& internalUrl) return extUrl; } +// #i104525# many versions of OSX have problems with some URLs: +// when an app requests OSX to add one of these URLs to the "Recent Items" list +// then this app gets killed (TextEdit, Preview, etc. and also OOo) +static bool isDangerousUrl( const rtl::OUString& rUrl) +{ + // use a heuristic that detects all known cases since there is no official comment + // on the exact impact and root cause of the OSX bug + const int nLen = rUrl.getLength(); + const sal_Unicode* p = rUrl.getStr(); + for( int i = 0; i < nLen-3; ++i, ++p) { + if( p[0] != '%') + continue; + // escaped percent? + if( (p[1] == '2') && (p[2] == '5')) + return true; + // escapes are considered to be UTF-8 encoded + // => check for invalid UTF-8 leading byte + if( (p[1] != 'f') && (p[1] != 'F')) + continue; + int cLowNibble = p[2]; + if( (cLowNibble >= '0') && (cLowNibble <= '9')) + return false; + if( cLowNibble >= 'a') + cLowNibble -= 'a' - 'A'; + if( (cLowNibble < 'A') || (cLowNibble >= 'C')) + return true; + } + + return false; +} + namespace SystemShell { //############################## - void AddToRecentDocumentList(const rtl::OUString& aFileUrl, const rtl::OUString& aMimeType) + void AddToRecentDocumentList(const rtl::OUString& aFileUrl, const rtl::OUString& /*aMimeType*/) { // Convert file URL for external use (see above) rtl::OUString externalUrl = translateToExternalUrl(aFileUrl); if( 0 == externalUrl.getLength() ) externalUrl = aFileUrl; - if( externalUrl.getLength() ) + if( externalUrl.getLength() + && !isDangerousUrl( externalUrl)) { NSString* pString = [[NSString alloc] initWithCharacters: externalUrl.getStr() length: externalUrl.getLength()]; NSURL* pURL = [NSURL URLWithString: pString]; diff --git a/shell/source/backends/macbe/makefile.mk b/shell/source/backends/macbe/makefile.mk index dd2b166ce1ce..c8f6891d6f87 100644 --- a/shell/source/backends/macbe/makefile.mk +++ b/shell/source/backends/macbe/makefile.mk @@ -50,11 +50,10 @@ DLLPRE = .IF "$(OS)" != "MACOSX" dummy: - @echo "Nothing to build for OS $(OS)." + @echo "Nothing to build for OS $(OS)." .ELSE -OBJCXXFLAGS=-x objective-c++ -fobjc-exceptions CFLAGSCXX+=$(OBJCXXFLAGS) SLOFILES= \ diff --git a/sj2/doc/Todo.txt b/sj2/doc/Todo.txt deleted file mode 100644 index 6520abaa10a8..000000000000 --- a/sj2/doc/Todo.txt +++ /dev/null @@ -1,108 +0,0 @@ -Erkenntnisse aus sj/sj1, die in sj2 beachtet werden mssen - - -- Call von C++ -"javascript: ..." nicht wie event behandeln, insbesondere werden -this und document nicht implizit als Search-Objekte gesetzt. - - -- prototype Eigenschaft von Objekten: -Manipuliert Klassen-Informationen, falls an einem beliebigen Objekt -eine Property mit gleichem Namen angelegt wird, so gilt dieses -Ueberschreiben jedoch nur fuer dieses eine Objekt !!! -Im Sj/Sj1 Projekt ist dies jedoch nicht erfuellt ! - -Beispiel: -function Ctor() { ... } - -obj1 = new Ctor(); // obj1 obj2 -obj2 = new Ctor(); //------------------------- -Ctor.prototype.toString = myToString; // myToString myToString -obj1.toString = myToString2; // myToString2 myToString -Ctor.prototype.toString = myToString3; // myToString2 myToString3 - - -- toString() und valueOf() Behandlung des BaseObj bei Type-Konversion - -======================================================================== - -Bemerkungen zur Suchreihenfolge und zum Ueberladen von Funktionen: - -* fuer jede 'Klasse' (z.B. Math, Date, String) gibt es ein Konstruktor- - Objekt in der JavaScript-Umgebung. - In dem Konstruktor-Objekt werden die Properties der Klasse angelegt, - z.B. sin, cos. - Der Konstruktor setzt seine Properties an jedem neu erzeugten - Objekt. Daher hat z.B. jedes Date-Objekt eine (default-behandelte) - Property setMonth. - Zum Setzten der Properties des Konstruktor an das neu erzeugte - Objekt sollte die initProp()-Methode noch einen Bereich der zu - kopierenden Properties bekommen, damit nicht alle nachtraeglich - am Konstruktor-Objekt angelegten Properties auch am Objekt gesetzt - werden. - -* jedes Objekt haelt eine Referenz auf seinen Konstruktor (entweder die - vordefinierten Klassen wie Math, Date oder die Funktion mit der das - Objekt erzeugt wurde). - -* fuer die Suchreihenfolge gibt es folgende drei Moeglichkeiten: - - - Default-behandelte Property: - aStrg = new String( "gulp" ); - aStrg.toString() // --> verwendet toString-Property am - // String-Konstruktor (default-Behandlung) - - - Default-Behandlung ueberladen am Konstruktor: - aStrg = new String( "gulp" ); - String.prototype.toString = myToString; // UEBERLADEN ! - aStrg.toString() // --> verwendet myToString-Funktion. - // Das prototype-Objekt wird am String-Ctor. - // angelegt und ueberschreibt daher die - // default-behandelte Property am Objekt !!! - // Der Interpreter muss dann noch an einem - // ggf. vorhandenen prototype-Objekt am - // Konstruktor nach der Property suchen. - - - ueberladen am Objekt: - aStrg = new String( "gulp" ); - String.prototype.toString = myToString; // am Ctor. ueberladen - aStrg.toString = myToString2; - aStrg.toString() // --> verwendet myToString2-Funktion. - // Die Property toString wird am Objekt - // ueberschrieben und somit das Flag, dass - // die default-Behandlung anzeigt, zurueck - // gesetzt. D.h. der Interpreter muss das - // prototype-Objekt des Konstruktors NICHT - // durchsuchen. - - -======================================================================== - -DEMNAECHST: - -Die Properties der Standard-Objekte (z.B. setSeconds() am Date) -werden am prototype-Objekt des Konstruktors (z.B. DateCtor) angelegt. -Bei der Suche nach Properties an einem beliebigen Objekt wird erst -das Objekt durchsucht und anschliessend das prototype-Objekt des -Konstruktors fuer das Objekt durchsucht. Dieses Verhalten gleicht -dem Netscape-Verhalten (Stand 2.7.1997). - -ACHTUNG, AB 11.8: -Das ist so nicht korrekt, da die entsprechenden Properties direkt -am prototype-Objekt nicht bekannt sind. Die an den Objekten als -Default geflagten Properties bilden daher das Netscape-Verhalten -besser ab. - - -======================================================================== - -WEITERE OFFENE PROBLEME: ------------------------- - - * this auf der Wiese funktioniert noch nicht korrekt - - * Konversion von Typen ? - - - - diff --git a/sj2/doc/concepts.html b/sj2/doc/concepts.html deleted file mode 100644 index 49f336b131d8..000000000000 --- a/sj2/doc/concepts.html +++ /dev/null @@ -1,844 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> -<HTML> -<HEAD> - <TITLE></TITLE> - <META NAME="GENERATOR" CONTENT="StarOffice/4.0 (WinNT/Win95)"> - <META NAME="AUTHOR" CONTENT=" "> - <META NAME="CREATED" CONTENT="19970401;13233926"> - <META NAME="CHANGEDBY" CONTENT=" "> - <META NAME="CHANGED" CONTENT="19970529;8045806"> -</HEAD> -<BODY> -<H1>Stardivision erweiterte Java Grundkonzepte</H1> -<H2><A NAME="Exceptions"></A>Exceptions:</H2> -<P>Die Grundidee von Exceptions ist es einen Fehlerkontext -aufzuspannen, der erst näher betrachtet werden muß, wenn -man Fehler korrigieren will. Der Programmcode sollte durch die -Behandlung von Fehlern nicht undurchsichtig und unleserlich werden. -Meiner Meinung nach sollten Exceptions deswegen auch nicht als -zweiter Returnwert vergewaltigt werden.<BR><B>Ziel:</B> Nach dem -Auftreten einer Exception sollte es möglichst einfach sein das -System in einen definierten arbeitsfähigen Zustand zu -versetzen.<BR>Es gibt grundsätzlich drei verschiedenen Arten von -Exceptions. Diese unterscheiden sich durch den Zustand in dem sie das -Objekt hinterlassen.</P> -<OL> - <LI><P><A NAME="Undefined Exception"></A>Die von der Methode - benutzten Objekte sind in einem undefinierten Zustand. Jede auf dem - Objekt aufgerufene Methode muß nach einer solchen Exception - nicht mehr ihre Spezifikation einhalten. Diese Exception wird im - folgenden mit „Undefined Exception“ benannt. Dabei ist zu - beachten, daß keine weiteren <A HREF="#Resourcen">Resourcen</A>, - außer die angegebenen, benutzt werden. Außerdem werden - „ReadOnly“ Resourcen nicht modifiziert.</P> - <LI><P><A NAME="Defined Exception"></A>Die von der Methode benutzten - Objekte sind in einem genau definierten Zustand, der aber von der - Zusicherung der Methode abweicht. Diese Exception wird im folgenden - mit „Defined Exception“ benannt. Dabei ist zu beachten, - daß keine weiteren <A HREF="#Resourcen">Resourcen</A>, außer - die angegebenen, benutzt werden. Außerdem werden „ReadOnly“ - Resourcen nicht modifiziert.</P> - <LI><P><A NAME="Transacted Exception"></A>Die von der Methode - benutzten Objekte sind in ihrem vorherigen Zustand, der aber von der - Zusicherung der Methode abweicht. Diese Exception wird im folgenden - mit „Transacted Exception“ benannt. Dabei ist zu beachten, - daß keine weiteren <A HREF="#Resourcen">Resourcen</A>, außer - die angegebenen, benutzt werden. Außerdem werden „ReadOnly“ - Resourcen nicht modifiziert. Diese Spezifikation trifft auch auf - „Defined Exception“ zu, wegen ihrer Bedeutung führe - ich sie extra auf.</P> -</OL> -<P>Die Benutzbarkeit eines Objektes, nachdem eine Exception -aufgetreten ist, ist vom obigen Typ der Exception abhängig.</P> -<P><FONT COLOR="#ff0000">Satz 1.1: Nachdem eine „Undefined -Exception“ aufgetreten ist, kann mit dem Objekt sowie allen -„ReadWrite“ Resourcen nicht mehr weiter gearbeitet werden.</FONT></P> -<P><FONT COLOR="#ff0000">Satz 1.2: Nachdem eine „Defined -Exception“ aufgetreten ist, kann aufgrund des genau definierten -Zustandes weiter gearbeitet werden.</FONT></P> -<P><FONT COLOR="#ff0000">Satz 1.3: Nach einer „Transacted -Exception“ ist der gleiche Zustand wie vor dem Aufruf -wiederhergestellt.</FONT></P> -<P>Es sollten möglichst nur „Transacted Exception“ -ausgelöst werden. Bei komplizierten Methoden läßt -sich aber eine „Defined Exception“ nicht immer vermeiden. -Eine „Undefined Exception“ deutet immer auf eine -Programmierfehler hin. Der Typ der Exeption kann nur in Zusammenhang -mit der Methode in der sie Auftritt ermittelt werden.</P> -<P><FONT COLOR="#ff0000">Satz 1.4: Durch die Klasse der Exception -kann niemals alleine der Typ (undefined, defined oder transacted) -entschieden werden.</FONT></P> -<H2><A NAME="Resourcen"></A>Resourcen (under construction)</H2> -<P>Die Grundidee von Resourcen ist die Aufteilung eines Gebildes in -weitere Einheiten. Auf diesen können dann verschiedene Aufträge -gleichzeitig arbeiten, wenn sie nicht dieselben Resourcen benutzen. -Z.B. kann man in einer Textverarbeitung die einzelnen Dokumente als -Einheiten betrachten. Aufträge, die sich nur auf ein Dokument -beziehen, können parallel zu anderen Dokumenten bearbeitet -werden.<BR>Mit Resourcen sind im System bzw. der Applikation -vorhandene Objekte, Services, Kanäle ... gemeint, die zur Zeit -nur von einem Thread benutzt werden können. Als Konsequenz -müssen Resourcen einem Thread zugeordnet werden, bevor dieser -sie benutzt.<BR><B>Ziel:</B> Es muß möglich sein, 1. -Aufträge parallel abzuarbeiten, 2. die Frage „Warum können -zwei Aufträge nicht parallel arbeiten?“ beantwortet zu -können.<BR>Es gibt verschiedene Möglichkeiten diese -Zuordnung vorzunehmen. Zwei stelle ich kurz vor.</P> -<OL> - <LI><P><A NAME="Prealloc Resource Konzept"></A>Eine Art der - Zuordnung ist das vorherige Anfordern aller für den Auftrag - benötigten Resourcen. Ist dies möglich, kann der Auftrag - ohne weitere Störungen ablaufen. Die Resourcen dürfen - freigegeben werden, bevor der Auftrag beendet ist. Dies gilt - natürlich nur für nicht mehr verwendete Resourcen. Es darf - ebenfalls das Zuordnungsrecht von lesend und schreibend auf lesend - zurückgenommen werden. Diese Zuornungsart wird im weiteren mit - „Prealloc Resource Konzept“ bezeichnet.</P> - <LI><P><A NAME="Ondemand Resource Konzept"></A>Eine andere Art der - Zuordnung ist das Anfordern der Resourcen, wenn sie benötigt - werden. Dabei kann es zu Störungen kommen, wenn sich - verschiedene Aufträge um die gleiche Resource bewerben. Die - Resourcen dürfen freigegeben werden, bevor der Auftrag beendet - ist. Dies gilt natürlich nur für nicht mehr verwendete - Resourcen. Es darf ebenfalls das Zuordnungsrecht von lesend und - schreibend auf lesend zurückgenommen werden. Diese Zuornungsart - wird im weiteren mit „Ondemand Resource Konzept“ - bezeichnet.</P> -</OL> -<P>Es gibt noch weitere Möglichkeiten Aufträge zu -bearbeiten, die die gleichen Resourcen benutzen. Häufig findet -man solche Lösungen bei Datenbankanwendungen.<BR>In der -folgenden Tabelle stehen sich die beiden Konzepte mit ihren Vor- und -Nachteilen und ihren Anforderungen gegenüber.</P> -<TABLE WIDTH=100% BORDER=1 CELLPADDING=5 FRAME=BOX RULES=ALL> - <COLGROUP> - <COL WIDTH=85*> - <COL WIDTH=85*> - <COL WIDTH=85*> - </COLGROUP> - <THEAD> - <TR> - <TH WIDTH=33% VALIGN=TOP> - <P><BR></TH> - <TD WIDTH=33% VALIGN=TOP><DL> - <DD>Prealloc Resource Konzept </DD> - </DL> - </TD> - <TD WIDTH=33% VALIGN=TOP> - <DL> - <DD>Ondemand Resource Konzept </DD> - </DL> - </TD> - </TR> - </THEAD> - <TBODY> - <TR> - <TD VALIGN=TOP> - <P>Alle Resourcen müssen vor der Auftragsausführung - bekannt sein.</TD> - <TD VALIGN=TOP> - <P>Ja</TD> - <TD VALIGN=TOP> - <P>Nein</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P>Nicht mehr benötigte Resourcen dürfen freigegeben - werden.</TD> - <TD VALIGN=TOP> - <P>Ja</TD> - <TD VALIGN=TOP> - <P>Ja</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P>Es kann zu Verklemmungen oder „Races“ kommen.</TD> - <TD VALIGN=TOP> - <P>Nein</TD> - <TD VALIGN=TOP> - <P>Ja</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P>In Bearbeitung befindliche Aufträge müssen, aufgrund - fehlender Resourcen, abgebrochen werden.</TD> - <TD VALIGN=TOP> - <P>Nein</TD> - <TD VALIGN=TOP> - <P>Ja</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P>Der Zustand der Resourcen ist zu jedem Zeitpunkt der - Auftragsabarbeitung bekannt.</TD> - <TD VALIGN=TOP> - <P>Ja</TD> - <TD VALIGN=TOP> - <P>Nein</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P>Algorithmus zur Resourcevergabe.</TD> - <TD VALIGN=TOP> - <P>Einfach, da nur überprüft werden muß, ob alle - benötigten Resourcen verfügbar sind.</TD> - <TD VALIGN=TOP> - <P>Komplex, da neben dem Anfordern von Resourcen auch noch - überprüft werden muß, ob das System <A HREF="#lebendig">lebendig</A> - ist.</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P>Parallelität</TD> - <TD VALIGN=TOP> - <P>Hoch, da unabhängige Aufträge meistens nur lesend - auf gemeinsame Resourcen zugreifen.</TD> - <TD VALIGN=TOP> - <P>Sehr hoch, da die benötigten Resourcen erst angefordert - werden, wenn man sie braucht.</TD> - </TR> - </TBODY> -</TABLE> -<P ALIGN=LEFT>Meiner Meinung nach ist nur das „Prealloc Resource -Konzept“ ohne richtige Programmierwerkzeuge zur Entwicklung -paralleler Algorithmen (z.B. Netzprogrammierung) wenigstens ein -bißchen beherschbar.</P> -<P ALIGN=LEFT>Es stellt sich die Frage wie das „Prealloc -Resource Konzept“ in einem Komponenten-Modell und in einem -Objekt-Environment integriert werden kann. Ein Objekt-Environment ist -ein mehr oder weniger dynamische Menge von Objekten die miteinander -in Verbindung stehen. Aus dem obigen Beispiel könnte man die -Verbindung der Textverarbeitung zu ihren Dokumenten als -Objekt-Environment bezeichnen. Ein Objekt in diesem Environment kann -nun über seine Verbindungen mit anderen Objekten kommunizieren. -Die Schnittstellen mit denen über die Verbindung kommuniziert -wird nennt man Komponenten-Modell. Die Idee des Objekt-Environments -ist es weitere Objekte möglichst einfach zu integrieren. So -könnten in unserem Beispiel weitere Dokumenttypen wie ein -HTML-Dokument eingebunden werden. Die Schittstellen müßten -nur dem, von der Textverarbeitung geforderten, Komponenten-Modell -genügen. Liefert aber das Modell, wie heute üblich, keine -Information über die benötigten Resourcen bei Benutzung der -Schnittstellen, dann können Verklemmungen bzw. Inkonsistenzen -nicht vermieden werden. Aus diesem Grunde ist es notwendig, das -Resource-Konzept in das Komponenten-Modell zu integrieren.<BR><B>Ziel:</B> -Es muß ein Kompromiß zwischen hoher Nebenläufigkeit -und der damit verbundenen Komplexität, sowie einfacher -Programmierung und geringer Nebenläufigkeit gefunden -werden.<BR><B>Folgen:</B> In einem Objekt-Environment müssen die -einzelnen Objekte also dynamisch auf Verbindungen zu Objekten mit -hoher oder geringer Nebenläufigkeit reagieren. Die Komplexität -dieser Aufgabe darf aber nicht in die Objekte verlagert werden, da -von einem seriellen Objekt (bzw. dessen Programmierer) nicht die -Steuerung nebenläufiger Aufträge verlangt werden -kann.<BR><B>Lösungsansatz:</B> Die Behandlung der -Nebenläufigkeit wird nicht in einer einfachen Komponente -implementiert. Das bedeutet sie muß mit einer -Default-Behandlung zufrieden sein, die minimale Nebeläufigkeit -nach sich zieht. Eine Komponente kann sich aber in die Vergabe der -Resourcen einmischen. So kann sie ihren Grad der Nebenläufigkeit -erhöhen. Dies ist dann aber auch mit erhöhtem -Implementationsaufwand zu bezahlen. Auf der anderen Seite macht es -aber keinen Sinn serielle oder Komponenten mit zu großem -Resourcebedarf einzubinden, wenn das Objekt-Environment danach -praktisch nicht mehr lauffähig ist. Das bedeutet, daß das -Objekt-Environment auch Forderungen bezüglich des Resourcebedarf -an die Komponenten stellen darf.</P> -<H3>Anforderungen</H3> -<OL> - <LI><P ALIGN=LEFT>Es muß ein Modell geben, in dem alle - vorhandenen Resourcen und deren Beziehung zueinander eingetragen - werden. Dadurch kann abgeschätzt werden, welchen Resourcebedarf - eine Komponente hat. Das „Schätzen“ ist wörtlich - zu nehmen. (Im Zusammenhang mit <A HREF="#Security">Security</A> - wird man aber auch noch sehen, daß der Zugriff auf bestimmte - Resourcen nicht möglich ist.) Für das „Prealloc - Resource Konzept“ gilt, es müssen mindestens die - benötigten Resourcen verfügbar sein. Zur Not sind diese - alle.</P> - <LI><P ALIGN=LEFT>Eine nebenläufige Komponente muß in - jeder ihrer von außen erreichbaren Methoden kontrollieren, ob - die entsprechenden Resourcen für sie angefordert wurden. Damit - serielle Komponenten diese Methoden nutzen können, können - die benötigten Resourcen angefordert werden, wenn vorher noch - <B>keine einzige</B> durch den ausführenden Auftrag belegt war. - Zur Erläuterung: Serielle Komponenten belegen keine Resourcen. - Damit würde jeder Aufruf einer nebenläufigen Komponente - scheitern. Um dies zu vermeiden, werden die Resourcen in der - nebenläufigen Komponente angefordert.</P> - <LI><P ALIGN=LEFT>Serielle Komponenten müssen also damit - rechnen eine Fehlermeldung über nicht verfügbare Resourcen - zu bekommen.</P> -</OL> -<H3>Szenarien</H3> -<P>Von unserem bisherigen Beispiel ausgehend, gibt es eine -Applikation in der sich drei Dokumente befinden. Ein serielles -Textdokument, ein nebenläufiges Tabellendokument und ein -nebenläufiges Präsentationsdokument. Die Applikation selbst -ist nebenläufig. Die Relationen gehen von der Applikation zu den -Dokumenten und umgekehrt. Die Dokumente kennen sich nicht.</P> -<P>Fall 1:<BR>In das serielle Textdokument soll eine Zeichenfolge -eingefügt werden. Da es sich um eine serielle Komponente -handelt, kann dieses Einfügen nicht von selbst ausgelöst -werden, es muß von einer nebenläufigen Komponente, hier -die Applikation, angestoßen werden. Die Applikation ist aber -verpflichtet die Resourcen vorher zu reservieren. Für diese -Abschätzung gibt es drei realistische Möglichkeiten. 1. Sie -reserviert nur das Textdokument selbst. Das bedeutet, das -Textdokument kann mit keinem anderen Objekt, auch nicht mit der -Applikation, kommunizieren. 2. Die Applikation und das Textdokument -wird reserviert. Es ist also nur der Zugriff auf die anderen -Dokumente verwehrt. 3. Alle Objekte werden reserviert. Geht es nach -dem „Prealloc Resource Konzept“ muß 3. gewählt -werden. Aufgrund von Sicherheitsbeschränkungen werden wir aber -noch sehen, das serielle Komponenten in ihrer Auftragsbearbeitung -gestoppt werden können. Wenn der Abbruch eines Auftrags möglich -ist, spielt es aber keine Rolle durch wen (Resourcen oder <A HREF="#Security">Security</A>) -dies geschehen ist.</P> -<P>Fall 2:<BR>In das nebenläufige Tabellendokument soll eine -Zeichenfolge eingefügt werden. Dieser Auftrag kann von der -Applikation oder der Komponente selbst ausgelöst werden. In -jedem Fall müssen die Resourcen vor der Auftragsbearbeitung -reserviert werden. Man kann dies auch der Komponente überlassen -(siehe Anforderung 2.), aber man scheitert, wenn zwei Aufträge -zu einem Auftrag zusammengefaßt werden sollen. Dies passiert -z.B., wenn der Auftrag „Text ersetzen“ aus den Aufträgen -„Löschen“ und „Einfügen“ besteht. Auf -jeden Fall wird nur das Tabellendokument selbst reserviert, da das -Einfügen keine Auswirkung auf andere Komponenten hat.</P> -<P>Fall 3:<BR>In das nebenläufige Tabellendokument wird der -Applikationsname aus der Applikation eingefügt. Dazu fragt das -Tabellendokument nach den benötigten Resourcen, um den Namen zu -holen und ihn einzufügen. Zum Holen wird die Applikation -benötigt und zum Einfügen das Tabellendokument. Beide -müssen vor der Auftragsausführung reserviert werden.</P> -<P>Fall 4:<BR>Das nebenläufige Tabellendokument fügt -selektierten Text aus dem seriellen Textdokument ein. Da das -Textdokument seinen Resourcebedarf nicht mitteilt, wird einer aus -Fall eins abgeschätzte Bedarf genommen. Man kann sehen, daß -der Auftrag für alle drei Möglichkeiten erteilt werden -kann. Seine Nebenläufigkeit wird dann durch die Abschätzung -eingeschränkt. Zusätzlich müssen natürlich die -benötigten Resourcen für das Einfügen geholt werden. -Alle müssen vor der Auftragsausführung reserviert werden.</P> -<H3>Programmierkonzepte</H3> -<P>Welche Konzepte können in einer objektorientierten Sprache -wie c++ oder Java oder einer prozeduralen Sprache wie Fortran oder -„c“ eingesetzt werden, um Nebenläufigkeit zu -erreichen. </P> -<OL> - <LI><P>Es gibt zwei Möglichkeiten eine Resource zu belegen. Das - ist Exclusive (lesen, schreiben) und „ReadOnly“. Eine - Resource kann von mehreren Aufträgen benutzt werden, wenn diese - nur „ReadOnly“ benötigen.</P> - <LI><P>Es gibt Resourcen für die man die Resourceverteilung - optimieren kann. Ein Objekt welches nicht geändert werden kann - und das während der Auftragsausführung immer konsistent - ist kann die Anforderung „Exclusiv“ automatisch auf - „ReadOnly“ abschwächen. Dies lohnt sich, wenn man - serielle Komponenten hat, die nichts über die - Resourceanforderungen mitteilen. Als Beispiel möchte ich eine - Instanz der Klasse String in Java nennen. Ein weitere Art von - Resourcen fordern bei Aufträgen an sie 1. keine weiteren - Aufträge an, 2. beenden sie die Aufträge schnell und 3. - die Reihenfolge der Änderung an ihnen ist für andere nicht - wichtig. Dies ist zum Beispiel bei der Speicherverwaltung in c der - Fall. Diese Art der Resource darf zu einem späteren Zeitpunkt - angefordert werden. Sie muß sofort benutzt und wieder - freigegeben werden. Aus diesem Grund erledigen solche Resourcen das - Anfordern und Freigeben selbst.</P> - <LI><P>Bevor ein Auftrag ausgeführt werden kann, müssen - alle von ihm benötigten Resourcen reserviert werden. Dies ist - für einen Auftrag, der aus mehreren Teilaufträgen besteht, - aufwendig. Eine Optimierung kann darin bestehen die Teilaufträge - asynchron auszuführen. Allerdings dringt diese Verhaltensweise - nach außen. Z.B. müssen Aufträge, die diesen dann - asynchronen Auftrag nutzen, dann auch asynchron sein. Eine weitere - Optimierung in der Autragsvergabe gibt es, wenn ein Autrag die - Resourcervergabe nicht ändert. Es ist dann möglich mehr - Aufträge vorzuziehen.</P> - <LI><P>Es muß eine Queue geben, in die Aufträge eingefügt - werden können. Konfliktfreie Aufträge können parallel - ausgeführt werden. <B>Achtung:</B> Der Resourcebedarf eines - Auftrages kann nur bestimmt werden, wenn alle benötigten - Resourcen „ReadOnly“ reserviert werden können, es sei - denn kein vor ihm laufender Auftrag ändert die Resourcevergabe. - Warum ist das so? Ein Auftrag kann eine Resource dahingehend ändern, - daß danach andere Resourcen benötigt werden als vorher. - Der vorher bestimmte Bedarf ist dann falsch.</P> - <LI><P>Das Modell der Resourcen kann vergröbert oder verfeinert - werden. In einem Tabellendokument könnte man jede einzelne - Zelle zu einer Resource machen. Um die Komplexität der - Resourcemodells zu vereinfachen kann man aber weiter alle Zellen der - Dokument-Resource zuordnen. Wird also aus einer anderen Komponente - die Zelle angefordert, wird automatisch das ganze Dokument - reserviert. Daraus ergeben sich zwei Vorteile: 1. Für den - Auftraggeber ist die Vergröberung transparent und 2. Kann die - Resource an dem Objekt reserviert werden, das man ohnehin kennt.</P> - <LI><P>Das Resource-Modell ist hierarchisch. Eine Resource kann nur - einer Vergröberung zugeordnet werden. Die Tabellenzellen dürfen - also nur dem Tabellendokument zugeordnet werden. Daraus ergibt sich, - daß innerhalb einer solchen Hierarchie nebenläufig - gearbeitet werden kann. Es dürfen dann aber keine Resourcen - außerhalb der Hierarchie benutzt werden, selbst wenn diese - reserviert sind.</P> -</OL> -<H3>Probleme und Lösungen</H3> -<P>Über den Benutzer müssen Daten abgefragt werden, die -über die Benutzung von Resourcen entscheidet (z.B. -Dateiname):<BR>Ein solcher Auftrag muß in zwei Teilaufträge -unterteilt werden. Der erste erledigt die Abfrage. Danach werden alle -Resourcen freigegeben und dann fordert der zweite seine Resourcen und -wird bearbeitet. Eventuell kann ein solcher Auftrag den vorherigen -ersetzten, um zu verhindern das andere abhängige Aufträge -vor dem Aufgeteilten bearbeitet werden.</P> -<P>Ich habe mich bei einem Objekt als Listener angemeldet:<BR>Es gibt -zwei Arten von Benachrichtigungen die ich erhalte. 1. Aufgrund der -Ausführung eines Auftrages und 2. einen Event von einer -nebenläufigen Komponente. Im ersten Fall überprüfe ich -den Resourcebedarf und führe dann den Auftrag aus. Im zweiten -Fall reserviere ich die benötigten Resourcen und führen den -Auftrag aus. Sind Resourcen reserviert, ist dies Fall eins, sonst -Fall zwei.</P> -<P>Ich bin Broadcaster:<BR>Broadcaste ich aufgrund eines Auftrags tue -ich nichts weiter. Löse ich den Broadcast ohne Auftrag aus, muß -ich die Resourcen für die Listener bestimmen und sie vor dem -Aufruf reservieren. Die einzelnen Listener werden als unabhängig -betrachtet. Im Detail findet folgender Ablauf statt. 1. Die Liste der -Listener wird kopiert. 2. Für den ersten Listener wird der -Resourcebedarf ermittelt.</P> -<H3>Implementation</H3> -<P>Die Basis für die Implementation des Resourcekonzeptes legen -die Klassen <A HREF="stardiv.resource.Resource.html#Resource">Resource</A>, -<A HREF="stardiv.resource.ResourceList.html#ResourceList">ResourceList</A>, -<A HREF="stardiv.resource.ResourceLockException.html#ResourceLockException">ResourceLockException</A>, -<A HREF="stardiv.resource.Task.html#Task">Task</A>, <A HREF="stardiv.resource.TaskManager.html#TaskManager">TaskManager</A>, -<A HREF="stardiv.resource.TaskThread.html#Task">TaskThread</A>, -<A HREF="stardiv.resource.ThreadData.html#ThreadData">ThreadData</A> -und das Interface <A HREF="stardiv.resource.Resourceable.html#Resourceable">Resourceable</A> -fest. Um ein Objekt in das Resourcekonzept einbinden zu können -sind folgende Schritte notwendig:<BR>1. Das Resourceable Interface -muß implementiert werden. 2. Ein Konstruktor mit der dem -Objekte zugewiesenen Resource. 3. Jede public Methode bekommt eine -*_Resource(...) Methode zur Seite, mit der der Resourcebedarf -ermittelt werden kann. 4. Innerhalb der public Methode wird der -Resourcebedarf ermittelt. 5. Mit dieser Information die als -ResourceListe vorliegt, wird eine Auftrag (Task) erzeugt. 6. Dieser -Auftrag wird beim TaskManager angemeldet. 7. Nach der Zuteilung durch -den TaskManager wird der Auftrag ausgeführt. 8. Alle Resourcen -und der Auftrag werden wieder freigegeben.<BR>Diese Liste ist -detailliert aber nicht <B>vollständig</B>. In der Klasse -Resource steht imm eine Beispiel, welches aktuell sein sollte.</P> -<P>Folgende Programmierrichtlinien gibt es, um das „Prealloc -Resource Konzept“ in Java zu integrieren:</P> -<OL> - <LI><P ALIGN=LEFT>Es muß das Interface <A HREF="stardiv.resource.Resourceable.html#Resourceable">Resourceable</A> - implementiert werden. Mit Hilfe dieses Interfaces kann der - Resourcebedarf eines Objektes erfragt werden. Diese Richtlinien - gelten dann auch für die Superklasse.</P> - <LI><P ALIGN=LEFT>???Es muß das Interface <A HREF="stardiv.concepts.ModifyTestable.html#ModifyTestable">ModifyTestable</A> - implementiert werden. Damit kann überprüft werden, ob an - den Resourcen Veränderungen vorgenommen wurden.</P> - <LI><P ALIGN=LEFT>Nur Methoden die über die Lebensdauer des - Objektes keine veränderten Werte liefern dürfen immer - gerufen werden. Das sind zum Beispiel alle Methoden der Klasse - java.lang.Object.</P> - <LI><P ALIGN=LEFT>Um den Resourcebedarf einzelner Methoden genauer - zu ermitteln kann eine Methode mit dem, um _Resource( ResourceList - aRL, boolean bCheck, ... ) erweiterten Namen, gerufen werden. Ein - Beispiel befindet sich in der Klasse <A HREF="stardiv.resource.Resource.html#Resource">Resource</A>.</P> -</OL> -<H2><A NAME="Security"></A>Security</H2> -<H2><A NAME="Data Requests"></A>Data Requests</H2> -<P>Diese Schnittstelle soll das Anfordern von Daten vereinheitlichen. -Das Problem, welches zu diesem Ansatz führte, ist das Lesen von -Daten über einen „langsamen“ Internet-Stream. Das -bedeutet es werden Daten benötigt, die erst noch übertragen -werden müssen. Da das Pull-Modell immer einen eigenen Thread -vorraussetzt, um die restliche Anwendung nicht zu blockieren, habe -ich das Push-Modell gewählt.<BR><B>Ziel:</B> Für die -Implementation sollte es möglichst transparent sein, wie die -Daten herangeschafft werden. Als zweites soll die Schnittstelle für -denjenigen einfach sein, der alle Daten sofort bereithält.<BR><B>Lösung:</B> -Der Datenverarbeiter ist passiv. Das bedeutet, beim Entgegennehmen -der Daten beginnt er nicht sie zu verarbeiten. Dies muß extra -angestoßen werden. Zweitens, der Datenverarbeiter hält den -Status des Datenlieferanten. Dies können EOF, für alle -Daten gelesen, READY, für sind Daten da, PENDING, es kommen noch -weitere Daten und NO_SOURCE, es wurden nicht alle Daten verarbeitet -und es kommen keine weiteren Daten mehr. <B>Achtung</B> der Status -ist nur zu bestimmten Zeitpunkten gültig. Der Datenverarbeiter -darf nur im Zustand PENDING Daten bekommen. Diese Annahme schützt -ihn vor der Implementation eines Puffers. Das <A HREF="stardiv.concepts.QueryData.html#QueryData">QueryData</A> -- Interface ist die Spezifikation für dieses Verhalten.</P> -<H2><A NAME="Modify"></A>Modify</H2> -<P>Das Ziel ist nur eine Schnittstelle zu erstellen, mit der ein -Objekt auf Änderungen überprüft werden kann. Da es für -ein Objekt verschiedene Möglichkeiten gibt Änderungen an -sich zu prüfen (z.B. Änderungszähler, Kopie), muß -die Schnittstelle möglichst flexibel sein, um vielen -Implementationen gerecht zu werden. Die Lösung sind zwei -Methoden. Mit der einen (getModifyHandle()) kann der Zeitpunkt -festgemacht werden, zu dem mögliche Änderungen überprüft -werden sollen. Der Rückgabewert ist eine beliebiges Objekt, so -daß in ihm die benötigte Überprüfungsinformation -(z.B. der Änderungszähler) untergebracht werden kann. -Danach kann mit der zweiten Methode (isModified(Object)) überprüft -werden, ob eine Änderung stattgefunden hat. Das Interface für -dieses Konzept heißt <A HREF="stardiv.concepts.ModifyTestable.html#ModifyTestable">ModifyTestable</A> -.</P> -<H2><A NAME="LifeConnect"></A>LifeConnect</H2> -<P>LifeConnect ist die Kommunikation zwischen PlugIns, Applets und -JavaScript. Die Kommunikation kann in beide Richtungen erfolgen.Unter -JavaScript kann auf alle Systemklassen zugegriffen werden. Die -Abbildung der JavaScript-Aufrufe nach Java ist die Aufgabe der Klasse -<A HREF="stardiv.js.ip.CallJava.html#CallJava">CallJava</A>. Dazu -wird das in Java 1.1 implementierte Package java.lang.reflect -benutzt. Da JavaScript eine nicht typisierte Sprache ist, werden die -Werte nach JavaScript-Regeln in die entsprechenden Javatypen -umgesetzt. Bezüglich der Sicherheit wird ein JavaScript-Programm -auf die gleiche Stufe wie ein Applet gestellt. Um den Zugriff der -Applets auf JavaScript zu gestatten, muß das HTML-Tag MYSCRIPT -angegeben werden. Auf die Java-Klassen kann in JavaScript mit dem -Prefix „Package“ zugegriffen werden (sun, java und netscape -benötigen keinen Prefix). Die Klassen netscape.plugin.Plugin, -netscape.javascript.JSObject und netscape.javascript.JSException -dienen zur Kommunikation von Java mit JavaScript.</P> -<P>Konvertierungstabelle anhand der Spezifikation „JavaScript -Language Specifications“ 3.1.2 TypeConversion</P> -<TABLE WIDTH=100% BORDER=1 CELLPADDING=5 CELLSPACING=0 FRAME=HSIDES RULES=ALL> - <COLGROUP> - <COL WIDTH=26*> - <COL WIDTH=40*> - <COL WIDTH=47*> - <COL WIDTH=47*> - <COL WIDTH=47*> - <COL WIDTH=47*> - </COLGROUP> - <THEAD> - <TR> - <TH WIDTH=10% VALIGN=TOP> - <P><BR></TH> - <TH WIDTH=16% VALIGN=TOP> - <P><I>byte</I></TH> - <TH WIDTH=19% VALIGN=TOP> - <P><I>short</I></TH> - <TH WIDTH=19% VALIGN=TOP> - <P><I>char</I></TH> - <TH WIDTH=19% VALIGN=TOP> - <P><I>int</I></TH> - <TH WIDTH=19% VALIGN=TOP> - <P><I>long</I></TH> - </TR> - </THEAD> - <TBODY> - <TR> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Undef.</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Fehler</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Fehler</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Fehler</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Fehler</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Fehler</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Function</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(10) valueOf/error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(11) valueOf/error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(11) valueOf/error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(12) valueOf/error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(13) valueOf/error</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Object</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(10) valueOf/error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(11) valueOf/error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(11) valueOf/error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(12) valueOf/error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(13) valueOf/error</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Object (null)</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(10) 0</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(11) 0</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(11) 0</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(12) 0</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(13) 0</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P ALIGN=LEFT>double</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(10) Zahl oder Fehler, wenn Bereichs-überschreitung</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(11) Zahl oder Fehler, wenn Bereichs-überschreitung</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(11) Zahl oder Fehler, wenn Bereichs-überschreitung</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(12) Zahl oder Fehler, wenn Bereichs-überschreitung</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(13) Zahl oder Fehler, wenn Bereichs-überschreitung</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P ALIGN=LEFT>boolean</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) 0/1</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) 0/1</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) 0/1</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) 0/1</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) 0/1</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Leer String</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>error</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P ALIGN=LEFT>String</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(10) error/ Zahl</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(11) error/ Zahl</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(11) error/ Zahl</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(12) error/ Zahl</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(13) error/ Zahl</TD> - </TR> - </TBODY> -</TABLE><DL> - <DT><BR></DT> -</DL> -<TABLE WIDTH=100% BORDER=1 CELLPADDING=5 CELLSPACING=0 FRAME=BOX RULES=ALL> - <COLGROUP> - <COL WIDTH=27*> - <COL WIDTH=59*> - <COL WIDTH=44*> - <COL WIDTH=35*> - <COL WIDTH=36*> - <COL WIDTH=55*> - </COLGROUP> - <THEAD> - <TR> - <TH WIDTH=10% VALIGN=TOP> - <P><BR></TH> - <TH WIDTH=23% VALIGN=TOP> - <P><I>float</I></TH> - <TH WIDTH=17% VALIGN=TOP> - <P><I>double</I></TH> - <TH WIDTH=14% VALIGN=TOP> - <P><I>boolean</I></TH> - <TH WIDTH=14% VALIGN=TOP> - <P><I>String</I></TH> - <TH WIDTH=22% VALIGN=TOP> - <P><I>Object</I></TH> - </TR> - </THEAD> - <TBODY> - <TR> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Undef.</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Fehler</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Fehler</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>false</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>„undefined“</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>null</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Function</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(14) valueOf/error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) valueOf/error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) valueOf/ true</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) JS-Code der Funktion</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(30) netscape .javascript. JSObject</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Object</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(14) valueOf/error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) valueOf/error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) valueOf/ true</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) valueOf / toString - </TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(30) Java-Cast/ error</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Object (null)</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(14) 0</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) 0</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) false</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) „null“</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(30) null</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P ALIGN=LEFT>double</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(14) Zahl oder Fehler, wenn Bereichs-überschreitung</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(30) Zahl</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(7) 0, NaN -> false !0, -+Infinite -> true</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(8) Zahl, NaN, Infinity oder -Infinity</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(9) Number/ error - </TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P ALIGN=LEFT>boolean</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) 0/1</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) 0/1</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(30) boolean</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) „false“/ “true“</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) Boolean/ error</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P ALIGN=LEFT>Leer String</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>error</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) false</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(30) String</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) String/ error</TD> - </TR> - <TR> - <TD VALIGN=TOP> - <P ALIGN=LEFT>String</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(14) error/ Zahl</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) error/ Zahl</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) true</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(30) String</TD> - <TD VALIGN=TOP> - <P ALIGN=LEFT>(15) String/ error</TD> - </TR> - </TBODY> -</TABLE> -<P><BR></P> -<P>Der Algorithmus zum mappen der polymorphen Methoden in Java:<BR>1. -Die Anzahl der Parameter muß übereinstimmen.<BR>2. Die -Parameter müssen, nach der obigen Tabelle, konvertiert werden -können.<BR>3. Es gibt ein Punktesystem, nach dem die Methode -ausgewählt wird. Die Punkte stehen in Klammern in den -Tabelleneinträgen. Die Konvertierungspunkte für Zahlen sind -typabhängig und nicht wertabhängig. Dadurch ist -sichergestellt, das nicht unterschiedliche Methoden bei sich -ändernden Werten gerufen werden. Kommt es allerdings zu einem -Konvertierungsfehler (Überlauf), dann wird versucht eine andere -Methode zu finden.<BR>4. Es wird vorausgesetzt, daß die -Methoden „valueOf“ und „toString“ keine -Seiteneffekte haben. Sie dürfen also beliebig oft aufgerufen -werden.<BR>5. Es wird nur null auf eine Java-Array abgebildet.</P> -<H2><A NAME="Testen"></A>Testen</H2> -<P>Das Ziel dieses Abschnitts ist es Vorgehensweisen zu entwickeln, -mit denen sich die Java Grundkonzepte testen lassen. Folgende -Checkliste ist für jede Methode abzuarbeiten.</P> -<OL> - <LI><P>Zu jeder Klasse gibt es eine entsprechende Testklasse. Diese - steht im Package „test“.... Der Name der Klasse wird mit - „Test“ erweitert. Beispiel: stardiv.memory.BitArray wird - zu test.memory.BitArrayTest. Jede dieser Klassen hat eine Methode - „public static void main( String [] )“. Diese Methode wird - aufgerufen, um den Test aller Methoden anzustoßen. Der Test - ist nicht interaktiv. Wird ein Fehler festgestellt, wird das - Programm mit exit( -1 ) verlassen.</P> - <LI><P>Jede Methode muß unabhängig von ihren Environment - getestet werden. Alle Resourcen für die Methode werden als - Dummy für den Test implementiert. Diese Forderung führt zu - sauberen Schnittstellen, da ansonsten für den Test ja ganze - Objekte implementiert werden müssen.</P> - <LI><P>Das Testprotokoll protokolliert mit „System.out.println“. - Vor dem Test der einzelnen Methoden wird in einer Zeile kurz über - den Test informiert. Scheitert der Test, dann wird eine - Fehlermeldung ausgegeben in der „failed“ enthalten sein - muß. </P> - <LI><P>Um <A HREF="#Defined Exception">Defined Exception</A> und - <A HREF="#Transacted Exception">Transacted Exception</A> testen zu - können, sollten die <A HREF="stardiv.concepts.Resource.html#Resource">Resource</A> - und <A HREF="stardiv.concepts.ModifyTestable.html#ModifyTestable">ModifyTestable</A> - Interfaces implementiert werden. Es kann damit automatisch geprüft - werden, ob sich eine Resource unerlaubter Weise geändert hat.</P> -</OL> -<H2>Begriffe</H2> -<P><A NAME="lebendig"></A>Lebendig: Ein System wird als lebendig -bezeichnet, wenn alle in ihm befindlichen Aufträge -fertiggestellt werden können. Sie sich also nicht in einer -Verklemmung oder einem „Race“ befinden.</P> -</BODY> -</HTML>
\ No newline at end of file diff --git a/sj2/inc/sjapplet.hxx b/sj2/inc/sjapplet.hxx deleted file mode 100644 index fa8a18fee827..000000000000 --- a/sj2/inc/sjapplet.hxx +++ /dev/null @@ -1,85 +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: sjapplet.hxx,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _SJ_SJAPPLET_HXX -#define _SJ_SJAPPLET_HXX - -#include "com/sun/star/uno/Reference.hxx" -#include <tools/string.hxx> - -class INetURLObject; -class Size; -class SjJScriptAppletObject; -class SvCommandList; -class Window; -namespace com { namespace sun { namespace star { namespace uno { - class XComponentContext; -} } } } - -struct SjApplet2_Impl; - -enum SjNetAccess -{ - NET_UNRESTRICTED, NET_NONE, NET_HOST -}; - -class SjApplet2 -{ - SjApplet2_Impl * _pImpl; - -public: - static void settingsChanged(void); - - SjApplet2(); - virtual ~SjApplet2(); - void Init( - com::sun::star::uno::Reference< - com::sun::star::uno::XComponentContext > const & context, - Window * pParentWin, const INetURLObject & rDocBase, - const SvCommandList & rCmdList); - void setSizePixel( const Size & ); - void appletRestart(); - void appletReload(); - void appletStart(); - void appletStop(); - void appletClose(); - - // Fuer SO3, Wrapper fuer Applet liefern - SjJScriptAppletObject * GetJScriptApplet(); - - virtual void appletResize( const Size & ) = 0; - virtual void showDocument( const INetURLObject &, const XubString & ) = 0; - virtual void showStatus( const XubString & ) = 0; -// virtual SjJSbxObject * getJScriptWindowObj() = 0; -}; - - - -#endif // _REF_HXX diff --git a/sj2/prj/build.lst b/sj2/prj/build.lst deleted file mode 100644 index 82fe969d0295..000000000000 --- a/sj2/prj/build.lst +++ /dev/null @@ -1,8 +0,0 @@ -j2 sj2 : jvmaccess sandbox svtools NULL -j2 sj2 usr1 - all j2_mkout NULL -j2 sj2\stardiv\applet nmake - all j2_starappl j2_contr NULL -j2 sj2\stardiv\applet\resources nmake - all j2_appres j2_starappl NULL -j2 sj2\stardiv\controller nmake - all j2_contr NULL -j2 sj2\stardiv\app nmake - all j2_starapp j2_starappl j2_contr NULL -j2 sj2\source\jscpp nmake - all j2_jscpp j2_starapp NULL -j2 sj2\util nmake - all j2_util j2_jscpp NULL diff --git a/sj2/prj/d.lst b/sj2/prj/d.lst deleted file mode 100644 index c70fb0ef2b19..000000000000 --- a/sj2/prj/d.lst +++ /dev/null @@ -1,9 +0,0 @@ -mkdir: %_DEST%\inc%_EXT%\sj2 -..\%__SRC%\class\classes.jar %_DEST%\bin%_EXT%\classes.jar -..\inc\sjapplet.hxx %_DEST%\inc%_EXT%\sj2\sjapplet.hxx - -..\%__SRC%\lib\sj.lib %_DEST%\lib%_EXT%\sj.lib -..\%__SRC%\lib\lib*.so %_DEST%\lib%_EXT% -..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib -..\%__SRC%\slb\sj.lib %_DEST%\lib%_EXT%\xsj.lib -..\%__SRC%\bin\j?????_g.dll %_DEST%\bin%_EXT%\j?????_g.dll diff --git a/sj2/source/inc/java_lang_object.hxx b/sj2/source/inc/java_lang_object.hxx deleted file mode 100644 index 6b2aba1aad3f..000000000000 --- a/sj2/source/inc/java_lang_object.hxx +++ /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: java_lang_object.hxx,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <jni.h> -#ifdef OS2 -#include <typedefs.h> -#endif - -#ifndef _SJ_JAVA_LANG_OBJECT_HXX -#define _SJ_JAVA_LANG_OBJECT_HXX - -#include <tools/string.hxx> - - -#ifdef HAVE_64BIT_POINTERS -#error "no 64 bit pointer" -#else -#ifdef OS2 -#define INT64_TO_PVOID(x) (void *)x.lo -inline jlong Make_Os2_Int64( INT32 hi, INT32 lo ) {jlong x = CONST64( hi, lo ); return x; } -#define PVOID_TO_INT64(x) Make_Os2_Int64( 0, (INT32)x ) -#else //OS2 -#define PVOID_TO_INT64(x) (jlong)(INT32)x -#define INT64_TO_PVOID(x) (void *)x -#endif //Os2 -#endif - -//===================================================================== -class java_lang_Class; -class java_lang_Object -{ - // Zuweisungsoperator und Copy Konstruktor sind verboten - java_lang_Object& operator = (java_lang_Object&) { return *this;}; - java_lang_Object(java_lang_Object&) {}; - - static jclass getMyClass(); - // nur zum Zerstoeren des C++ Pointers in vom JSbxObject - // abgeleiteten Java Objekten - //static jclass getJSbxObjectClass(); - -protected: - // der JAVA Handle zu dieser Klasse - jobject object; - // Klassendefinition - - // neu in SJ2: - static jclass theClass; // die Klasse braucht nur einmal angefordert werden ! - static jclass theJSbxObjectClass; // die Klasse braucht nur einmal angefordert werden ! - static ULONG nObjCount; // Zaehler fuer die Anzahl der Instanzen - -public: - // der Konstruktor, der fuer die abgeleiteten Klassen verwendet - // werden soll. - java_lang_Object( JNIEnv * pEnv, jobject myObj ); - // der eigentliche Konstruktor - java_lang_Object(); - - virtual ~java_lang_Object(); - - void saveRef( JNIEnv * pEnv, jobject myObj ); - jobject getJavaObject() const { return object; } - java_lang_Object * GetWrapper() { return this; } - - java_lang_Class * getClass(); - -}; - -#endif diff --git a/sj2/source/jscpp/sjapplet.cxx b/sj2/source/jscpp/sjapplet.cxx deleted file mode 100644 index 08b07b8c2965..000000000000 --- a/sj2/source/jscpp/sjapplet.cxx +++ /dev/null @@ -1,126 +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: sjapplet.cxx,v $ - * $Revision: 1.16 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "sal/config.h" - -#include "sjapplet.hxx" - -#include "osl/diagnose.h" -#include "rtl/string.hxx" -#include "rtl/ustring.hxx" - -#include "sjapplet_impl.hxx" - -using namespace ::rtl; -using namespace ::com::sun::star::uno; - -SjApplet2::SjApplet2() - : _pImpl(new SjApplet2_Impl()) -{ -} - -SjApplet2::~SjApplet2() -{ - delete _pImpl; -} - -//========================================================================= -void SjApplet2::Init( - com::sun::star::uno::Reference< - com::sun::star::uno::XComponentContext > const & context, - Window * pParentWin, const INetURLObject & rDocBase, - const SvCommandList & rCmdList) -{ - try { - if(_pImpl) - _pImpl->init(pParentWin, context, rDocBase, rCmdList); - } - catch(RuntimeException & runtimeException) { -#if OSL_DEBUG_LEVEL > 1 - OString message = OUStringToOString(runtimeException.Message, RTL_TEXTENCODING_ASCII_US); - OSL_TRACE("sjapplet.cxx: SjApplet2::Init - exception occurred: %s\n", message.getStr()); -#else - (void) runtimeException; // avoid warning -#endif - - delete _pImpl; - _pImpl = 0; - } -} - -//========================================================================= -void SjApplet2::setSizePixel( const Size & rSize ) -{ - if(_pImpl) - _pImpl->setSize(rSize); -} - -void SjApplet2::appletRestart() -{ - if(_pImpl) - _pImpl->restart(); -} - -void SjApplet2::appletReload() -{ - if(_pImpl) - _pImpl->reload(); -} - -void SjApplet2::appletStart() -{ - if(_pImpl) - _pImpl->start(); -} - -void SjApplet2::appletStop() -{ - if(_pImpl) - _pImpl->stop(); -} - -void SjApplet2::appletClose() -{ - if(_pImpl) - _pImpl->close(); -} - -// Fuer SO3, Wrapper fuer Applet liefern -SjJScriptAppletObject * SjApplet2::GetJScriptApplet() -{ - OSL_TRACE("SjApplet2::GetJScriptApplet\n"); - - return NULL; -} - -// Settings are detected by the JavaVM service -// This function is not necessary anymore -void SjApplet2::settingsChanged(void) -{} diff --git a/sj2/source/jscpp/sjapplet_impl.cxx b/sj2/source/jscpp/sjapplet_impl.cxx deleted file mode 100644 index fdae4863a80a..000000000000 --- a/sj2/source/jscpp/sjapplet_impl.cxx +++ /dev/null @@ -1,617 +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: sjapplet_impl.cxx,v $ - * $Revision: 1.32 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "sjapplet_impl.hxx" - -#ifdef WNT -#include <tools/prewin.h> -#include <windows.h> -#include <tools/postwin.h> -#elif (defined QUARTZ) -#include "premac.h" -#include <Cocoa/Cocoa.h> -#include "postmac.h" -#elif (defined UNX) -#include <tools/prex.h> -#include "X11/Xlib.h" -#include <tools/postx.h> -#endif - -#include "rtl/ustring.hxx" -#include <rtl/process.h> -#include <osl/mutex.hxx> - -#include <tools/urlobj.hxx> -#include <tools/debug.hxx> - -#include <svtools/ownlist.hxx> - -#include <vcl/svapp.hxx> -#include <vcl/window.hxx> -#include <vcl/wrkwin.hxx> -#include <vcl/syschild.hxx> -#include <vcl/sysdata.hxx> -#include <com/sun/star/java/XJavaVM.hpp> -#include "com/sun/star/lang/XMultiComponentFactory.hpp" -#include "com/sun/star/uno/XComponentContext.hpp" -#include "jvmaccess/classpath.hxx" - -using namespace ::rtl; -using namespace ::osl; -#ifdef SOLAR_JAVA -using namespace ::com::sun::star::java; -#endif // SOLAR_JAVA -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; - -namespace css = ::com::sun::star; -#ifdef SOLAR_JAVA - -static void testJavaException(JNIEnv * pEnv) throw(com::sun::star::uno::RuntimeException) -{ - jthrowable jtThrowable = pEnv->ExceptionOccurred(); - if(jtThrowable) { // is it a java exception ? -#if OSL_DEBUG_LEVEL > 1 - pEnv->ExceptionDescribe(); -#endif - pEnv->ExceptionClear(); - - jclass jcThrowable = pEnv->FindClass("java/lang/Throwable"); - jmethodID jmThrowable_getMessage = pEnv->GetMethodID(jcThrowable, "getMessage", "()Ljava/lang/String;"); - - jstring jsMessage = (jstring)pEnv->CallObjectMethod(jtThrowable, jmThrowable_getMessage); - - rtl::OUString ouMessage; - if(jsMessage) { - const jchar * jcMessage = pEnv->GetStringChars(jsMessage, NULL); - ouMessage = rtl::OUString(jcMessage); - pEnv->ReleaseStringChars(jsMessage, jcMessage); - } - - throw css::uno::RuntimeException(ouMessage, css::uno::Reference<XInterface>()); - } -} -#else // !SOLAR_JAVA -static void throwException() throw(com::sun::star::uno::RuntimeException) -{ - throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Java applets not supported.")), css::uno::Reference<XInterface>()); -} -#endif - -#ifdef SOLAR_JAVA -#if defined (UNX) && !defined(QUARTZ) -struct EmbeddedWindow { - jobject _joWindow; - - EmbeddedWindow(JNIEnv * pEnv, SystemEnvData const * pEnvData) throw(com::sun::star::uno::RuntimeException); - void dispose(JNIEnv * pEnv); -}; - -EmbeddedWindow::EmbeddedWindow(JNIEnv * pEnv, SystemEnvData const * pEnvData) - throw(com::sun::star::uno::RuntimeException) : _joWindow(0) -{ - // ensure that all operations for the window contained in pEnvData - // have been processed by the Xserver since java will access that - // window by a separate connection to the Xserver - XSync( (Display*)pEnvData->pDisplay, False); - try - { //java < 1.5 - jclass jcToolkit = pEnv->FindClass("java/awt/Toolkit"); testJavaException(pEnv); - jmethodID jmToolkit_getDefaultToolkit = pEnv->GetStaticMethodID( - jcToolkit, "getDefaultToolkit", "()Ljava/awt/Toolkit;" ); testJavaException(pEnv); - pEnv->CallStaticObjectMethod(jcToolkit, jmToolkit_getDefaultToolkit); testJavaException(pEnv); - - jclass jcMotifAppletViewer = pEnv->FindClass( - "sun/plugin/navig/motif/MotifAppletViewer"); - if(pEnv->ExceptionOccurred()) - { - pEnv->ExceptionClear(); - jcMotifAppletViewer = pEnv->FindClass( - "sun/plugin/viewer/MNetscapePluginContext"); testJavaException(pEnv); - } - - jclass jcClassLoader = pEnv->FindClass("java/lang/ClassLoader"); testJavaException(pEnv); - jmethodID jmClassLoader_loadLibrary = pEnv->GetStaticMethodID( - jcClassLoader, "loadLibrary", - "(Ljava/lang/Class;Ljava/lang/String;Z)V" ); testJavaException(pEnv); - jstring jsplugin = pEnv->NewStringUTF("javaplugin_jni"); testJavaException(pEnv); - pEnv->CallStaticVoidMethod(jcClassLoader, jmClassLoader_loadLibrary, - jcMotifAppletViewer, jsplugin, JNI_FALSE); testJavaException(pEnv); - - jmethodID jmMotifAppletViewer_getWidget = pEnv->GetStaticMethodID( - jcMotifAppletViewer, "getWidget", "(IIIII)I" ); testJavaException(pEnv); - jint ji_widget = pEnv->CallStaticIntMethod(jcMotifAppletViewer, - jmMotifAppletViewer_getWidget, pEnvData->aWindow, - 0, 0, 1, 1); testJavaException(pEnv); - jclass jcFrame = pEnv->FindClass("sun/awt/motif/MEmbeddedFrame"); testJavaException(pEnv); - jmethodID jmFrame_rinit = pEnv->GetMethodID(jcFrame, "<init>", "(J)V" ); testJavaException(pEnv); - jobject joFrame = pEnv->AllocObject(jcFrame); testJavaException(pEnv); - pEnv->CallVoidMethod(joFrame, jmFrame_rinit, (jlong)ji_widget); testJavaException(pEnv); - _joWindow = pEnv->NewGlobalRef(joFrame); - } - catch (RuntimeException & ) - { - } - - if (_joWindow) - return; - //try Java > 1.5 -#ifdef SOLARIS - jclass jcFrame = pEnv->FindClass("sun/awt/motif/MEmbeddedFrame"); testJavaException(pEnv); - jobject joFrame = pEnv->AllocObject(jcFrame); testJavaException(pEnv); - jmethodID jmFrame_rinit = pEnv->GetMethodID(jcFrame, "<init>", "(JZ)V" ); testJavaException(pEnv); - pEnv->CallVoidMethod(joFrame, jmFrame_rinit, (jlong) pEnvData->aWindow, JNI_FALSE); testJavaException(pEnv); - _joWindow = pEnv->NewGlobalRef(joFrame); -#elif LINUX - jclass jcFrame = pEnv->FindClass("sun/awt/X11/XEmbeddedFrame"); testJavaException(pEnv); - jobject joFrame = pEnv->AllocObject(jcFrame); testJavaException(pEnv); - jmethodID jmFrame_rinit = pEnv->GetMethodID(jcFrame, "<init>", "(J)V" ); testJavaException(pEnv); - - pEnv->CallVoidMethod(joFrame, jmFrame_rinit, (jlong) pEnvData->aWindow); testJavaException(pEnv); - _joWindow = pEnv->NewGlobalRef(joFrame); -#endif -} - -#else // UNX && !QUARTZ - -struct EmbeddedWindow { -jobject _joWindow; - -EmbeddedWindow(JNIEnv * pEnv, SystemEnvData const * pEnvData) throw(com::sun::star::uno::RuntimeException); -void dispose(JNIEnv * pEnv); -}; - - -#ifdef WNT -EmbeddedWindow::EmbeddedWindow(JNIEnv * pEnv, SystemEnvData const * pEnvData) throw(com::sun::star::uno::RuntimeException) -{ -jclass jcFrame = pEnv->FindClass("sun/awt/windows/WEmbeddedFrame"); testJavaException(pEnv); -jmethodID jmFrame_rinit = pEnv->GetMethodID(jcFrame, "<init>", "(I)V"); testJavaException(pEnv); - -jobject joFrame = pEnv->AllocObject(jcFrame); testJavaException(pEnv); -pEnv->CallVoidMethod(joFrame, jmFrame_rinit, (jint)pEnvData->hWnd); testJavaException(pEnv); - -_joWindow = pEnv->NewGlobalRef(joFrame); -} - -#elif defined QUARTZ -EmbeddedWindow::EmbeddedWindow(JNIEnv * pEnv, SystemEnvData const * pEnvData) throw(com::sun::star::uno::RuntimeException) -{ - /* The WNT code (above) that this code derives from, may be using quite old - ways of interacting with native windows. More modern approaches seems to - point towards JAWT_* and com.apple.eawt */ -#if 0 -// FIXME: this is not going to work on cocoa -jclass jcFrame = pEnv->FindClass("apple/awt/CEmbeddedFrame"); testJavaException(pEnv); -jmethodID jmFrame_rinit = pEnv->GetMethodID(jcFrame, "<init>", "(I)V"); testJavaException(pEnv); - -jobject joFrame = pEnv->AllocObject(jcFrame); testJavaException(pEnv); -pEnv->CallVoidMethod(joFrame, jmFrame_rinit, (jint)pEnvData->pView); testJavaException(pEnv); - -_joWindow = pEnv->NewGlobalRef(joFrame); -#endif -} - -#else - -EmbeddedWindow::EmbeddedWindow(JNIEnv * pEnv, SystemEnvData const * pEnvData) throw(com::sun::star::uno::RuntimeException) -{ -jclass jcFrame = pEnv->FindClass("java/awt/Frame"); testJavaException(pEnv); -jmethodID jmFrame_rinit = pEnv->GetMethodID(jcFrame, "<init>", "()V"); testJavaException(pEnv); -jobject joFrame = pEnv->AllocObject(jcFrame); testJavaException(pEnv); -pEnv->CallVoidMethod(joFrame, jmFrame_rinit); testJavaException(pEnv); - -_joWindow = pEnv->NewGlobalRef(joFrame); -} - -#endif - -#endif // UNX && !QUARTZ - -void EmbeddedWindow::dispose(JNIEnv * pEnv) -{ -jclass jcWindow = pEnv->FindClass("java/awt/Window"); testJavaException(pEnv); -jmethodID jmWindow_dispose = pEnv->GetMethodID(jcWindow, "dispose", "()V" ); testJavaException(pEnv); - -pEnv->CallVoidMethod(_joWindow, jmWindow_dispose); testJavaException(pEnv); -pEnv->DeleteGlobalRef(_joWindow); - -_joWindow = 0; -} -#endif // SOLAR_JAVA - - -#ifdef SOLAR_JAVA -SjApplet2_Impl::SjApplet2_Impl() throw(com::sun::star::uno::RuntimeException) - : - _joAppletExecutionContext(0), - _jcAppletExecutionContext(0) - -{} -#else // !SOLAR_JAVA -SjApplet2_Impl::SjApplet2_Impl() throw(com::sun::star::uno::RuntimeException) -{} -#endif - - -SjApplet2_Impl::~SjApplet2_Impl() throw() -{ -#ifdef SOLAR_JAVA - if (_joAppletExecutionContext) - { - try - { - if ( ! _virtualMachine.is()) - return; - jvmaccess::VirtualMachine::AttachGuard vmAttachGuard(_virtualMachine); - JNIEnv * pEnv = vmAttachGuard.getEnvironment(); - _pEmbeddedWindow->dispose(pEnv); - delete _pEmbeddedWindow; - - pEnv->DeleteGlobalRef(_joAppletExecutionContext); - pEnv->DeleteGlobalRef(_jcAppletExecutionContext); - } - catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) - { - } - } -#endif -} - -void SjApplet2_Impl::init( - Window * pParentWin, - css::uno::Reference< css::uno::XComponentContext > const & context, - const INetURLObject & rDocBase, const SvCommandList & rCmdList) - throw(com::sun::star::uno::RuntimeException) -{ -#ifdef SOLAR_JAVA - _pParentWin = pParentWin; - - - // Java URL erzeugen - rtl::OUString url = rDocBase.GetMainURL(INetURLObject::DECODE_TO_IURI); - - if(!url.getLength()) - url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///")); - - if (url.getLength()) { - //WorkAround, weil Java mit dem | nicht zurecht kommt - if(rDocBase.GetProtocol() == INET_PROT_FILE && url.pData->buffer[9] == INET_ENC_DELIM_TOKEN) { - rtl::OUString tmp = url.copy(0, 9); - tmp += String(INET_DELIM_TOKEN); - tmp += url.copy(10); - - url = tmp; - } - } - - -#if OSL_DEBUG_LEVEL > 1 - rtl::OString tmp = rtl::OUStringToOString(url, RTL_TEXTENCODING_ASCII_US); - OSL_TRACE("SjApplet2_Impl::init - mainUrl: %s\n", tmp.getStr()); -#endif - - css::uno::Reference<XJavaVM> _xJavaVM = css::uno::Reference<XJavaVM>( - (css::uno::Reference< css::lang::XMultiComponentFactory >( - context->getServiceManager(), css::uno::UNO_QUERY_THROW)-> - createInstanceWithContext( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.java.JavaVirtualMachine")), - context)), - UNO_QUERY); - Sequence<sal_Int8> processID(17); - rtl_getGlobalProcessId((sal_uInt8 *)processID.getArray()); - processID[16] = 0; - - OSL_ENSURE(sizeof (sal_Int64) - >= sizeof (jvmaccess::VirtualMachine *), - "Pointer cannot be represented as sal_Int64"); - sal_Int64 nPointer = reinterpret_cast< sal_Int64 >( - static_cast< jvmaccess::VirtualMachine * >(0)); - _xJavaVM->getJavaVM(processID) >>= nPointer; - _virtualMachine = reinterpret_cast< jvmaccess::VirtualMachine * >(nPointer); - if (!_virtualMachine.is()) - return; - - try - { - jvmaccess::VirtualMachine::AttachGuard vmAttachGuard(_virtualMachine); - - JNIEnv * pEnv = vmAttachGuard.getEnvironment(); - - _jcAppletExecutionContext = jvmaccess::ClassPath::loadClass( - context, pEnv, - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "vnd.sun.star.expand:$ORIGIN/classes/classes.jar")), - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "stardiv.applet.AppletExecutionContext"))); - testJavaException(pEnv); - _jcAppletExecutionContext = (jclass) pEnv->NewGlobalRef(_jcAppletExecutionContext ); testJavaException(pEnv); - - jclass jcURL = pEnv->FindClass("java/net/URL"); testJavaException(pEnv); - jmethodID jmURL_rinit = pEnv->GetMethodID(jcURL, "<init>", "(Ljava/lang/String;)V"); testJavaException(pEnv); - jobject joDocBase = pEnv->AllocObject(jcURL); testJavaException(pEnv); - jstring jsURL = pEnv->NewString(url.getStr(), url.getLength()); testJavaException(pEnv); - pEnv->CallVoidMethod(joDocBase, jmURL_rinit, jsURL); testJavaException(pEnv); - - jclass jcHashtable = pEnv->FindClass("java/util/Hashtable"); testJavaException(pEnv); - jmethodID jmHashtable_rinit = pEnv->GetMethodID(jcHashtable, "<init>", "()V"); testJavaException(pEnv); - jmethodID jmHashtable_put = pEnv->GetMethodID(jcHashtable, "put", - "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); testJavaException(pEnv); - jobject joParameters = pEnv->AllocObject(jcHashtable); testJavaException(pEnv); - pEnv->CallVoidMethod(joParameters, jmHashtable_rinit); testJavaException(pEnv); - - for(sal_uInt32 i = 0; i < rCmdList.Count(); ++i) { - const SvCommand & rCmd = rCmdList[i]; - String aCmd = rCmd.GetCommand(); - String aLoweredCmd = aCmd.ToLowerAscii(); - -#if OSL_DEBUG_LEVEL > 1 - rtl::OUString command = aCmd; - rtl::OUString value = rCmd.GetArgument(); - rtl::OString cmd_tmp = rtl::OUStringToOString(command, RTL_TEXTENCODING_ASCII_US); - rtl::OString value_tmp = rtl::OUStringToOString(value, RTL_TEXTENCODING_ASCII_US); - OSL_TRACE("command: %s=%s", cmd_tmp.getStr(), value_tmp.getStr()); -#endif - jstring jsCommand = pEnv->NewString(aLoweredCmd.GetBuffer(), aLoweredCmd.Len()); testJavaException(pEnv); - jstring jsArg = pEnv->NewString(rCmd.GetArgument().GetBuffer(), rCmd.GetArgument().Len()); testJavaException(pEnv); - pEnv->CallObjectMethod(joParameters, jmHashtable_put, jsCommand, jsArg); testJavaException(pEnv); - } - - SystemEnvData const * pEnvData = ((SystemChildWindow *)pParentWin)->GetSystemData(); - _pEmbeddedWindow = new EmbeddedWindow(pEnv, pEnvData); - - jmethodID jmAppletExecutionContext_rinit = pEnv->GetMethodID(_jcAppletExecutionContext, "<init>", - "(Ljava/net/URL;Ljava/util/Hashtable;Ljava/awt/Container;J)V"); testJavaException(pEnv); - jmethodID jmAppletExecutionContext_init = pEnv->GetMethodID(_jcAppletExecutionContext, "init", "()V"); testJavaException(pEnv); - jmethodID jmAppletExecutionContext_startUp = pEnv->GetMethodID(_jcAppletExecutionContext, "startUp", "()V"); testJavaException(pEnv); - - _joAppletExecutionContext = pEnv->AllocObject(_jcAppletExecutionContext); testJavaException(pEnv); - _joAppletExecutionContext = pEnv->NewGlobalRef(_joAppletExecutionContext); testJavaException(pEnv); - pEnv->CallVoidMethod(_joAppletExecutionContext, jmAppletExecutionContext_rinit, - joDocBase, joParameters, _pEmbeddedWindow->_joWindow, (jlong)0); testJavaException(pEnv); - pEnv->CallVoidMethod(_joAppletExecutionContext, jmAppletExecutionContext_init); testJavaException(pEnv); - pEnv->CallVoidMethod(_joAppletExecutionContext, jmAppletExecutionContext_startUp); testJavaException(pEnv); - - } - catch(jvmaccess::VirtualMachine::AttachGuard::CreationException & ) - { - throw RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "sjapplet_impl.cxx: Could not create jvmaccess::" - "VirtualMachine::AttachGuard!")), 0); - } - -#else // !SOLAR_JAVA - throwException(); -#endif -} - -void SjApplet2_Impl::setSize(const Size & rSize) throw(com::sun::star::uno::RuntimeException) -{ - -#ifdef SOLAR_JAVA - try - { - if ( ! _virtualMachine.is()) - return; - jvmaccess::VirtualMachine::AttachGuard vmAttachGuard(_virtualMachine); - JNIEnv * pEnv = vmAttachGuard.getEnvironment(); - - _pParentWin->SetSizePixel(rSize); - - jmethodID jmAppletExecutionContext_resize = pEnv->GetMethodID( - _jcAppletExecutionContext, "appletResize", "(II)V"); - testJavaException(pEnv); - pEnv->CallVoidMethod(_joAppletExecutionContext, - jmAppletExecutionContext_resize, (jint)rSize.Width(), - (jint)rSize.Height()); - testJavaException(pEnv); - } - catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) - { - throw RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "SjApplet2_Impl::setSize, Could not create jvmaccess::" - "VirtualMachine::AttachGuard!")), 0); - } -#else // !SOLAR_JAVA - throwException(); -#endif -} - -void SjApplet2_Impl::restart() throw(com::sun::star::uno::RuntimeException) -{ -#ifdef SOLAR_JAVA - try - { - if ( ! _virtualMachine.is()) - return; - jvmaccess::VirtualMachine::AttachGuard vmAttachGuard(_virtualMachine); - JNIEnv * pEnv = vmAttachGuard.getEnvironment(); - jmethodID jmAppletExecutionContext_restart = pEnv->GetMethodID( - _jcAppletExecutionContext, "restart", "()V"); - testJavaException(pEnv); - pEnv->CallVoidMethod(_joAppletExecutionContext, jmAppletExecutionContext_restart); - testJavaException(pEnv); - } - catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) - { - throw RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "SjApplet2_Impl::restart, Could not create jvmaccess::" - "VirtualMachine::AttachGuard!")), 0); - } -#else // !SOLAR_JAVA - throwException(); -#endif -} - -void SjApplet2_Impl::reload() throw(com::sun::star::uno::RuntimeException) -{ -#ifdef SOLAR_JAVA - try - { - if ( ! _virtualMachine.is()) - return; - jvmaccess::VirtualMachine::AttachGuard vmAttachGuard(_virtualMachine); - JNIEnv * pEnv = vmAttachGuard.getEnvironment(); - jmethodID jmAppletExecutionContext_reload = pEnv->GetMethodID( - _jcAppletExecutionContext, "reload", "()V"); - testJavaException(pEnv); - pEnv->CallVoidMethod(_joAppletExecutionContext, jmAppletExecutionContext_reload); - testJavaException(pEnv); - } - catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) - { - throw RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "SjApplet2_Impl::reload, Could not create jvmaccess::" - "VirtualMachine::AttachGuard!")), 0); - } -#else // !SOLAR_JAVA - throwException(); -#endif -} - -void SjApplet2_Impl::start() throw(com::sun::star::uno::RuntimeException) -{ -#ifdef SOLAR_JAVA - try - { - if ( ! _virtualMachine.is()) - return; - jvmaccess::VirtualMachine::AttachGuard vmAttachGuard(_virtualMachine); - JNIEnv * pEnv = vmAttachGuard.getEnvironment(); - jmethodID jmAppletExecutionContext_sendStart = pEnv->GetMethodID( - _jcAppletExecutionContext, "sendStart", "()V"); - testJavaException(pEnv); - pEnv->CallVoidMethod(_joAppletExecutionContext, jmAppletExecutionContext_sendStart); - testJavaException(pEnv); - } - catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) - { - throw RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "SjApplet2_Impl::restart, Could not create jvmaccess::" - "VirtualMachine::AttachGuard!")), 0); - } -#else // !SOLAR_JAVA - throwException(); -#endif -} - -void SjApplet2_Impl::stop() throw(com::sun::star::uno::RuntimeException) -{ -#ifdef SOLAR_JAVA - try - { - if ( ! _virtualMachine.is()) - return; - jvmaccess::VirtualMachine::AttachGuard vmAttachGuard(_virtualMachine); - JNIEnv * pEnv = vmAttachGuard.getEnvironment(); - jmethodID jmAppletExecutionContext_sendStop = pEnv->GetMethodID( - _jcAppletExecutionContext, "sendStop", "()V"); - testJavaException(pEnv); - pEnv->CallVoidMethod(_joAppletExecutionContext, jmAppletExecutionContext_sendStop); - testJavaException(pEnv); - } - catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) - { - throw RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "SjApplet2_Impl::restart, Could not create jvmaccess::" - "VirtualMachine::AttachGuard!")), 0); - } -#else // !SOLAR_JAVA - throwException(); -#endif -} - -void SjApplet2_Impl::close() throw(com::sun::star::uno::RuntimeException) -{ -#ifdef SOLAR_JAVA - try - { - if ( ! _virtualMachine.is()) - return; - jvmaccess::VirtualMachine::AttachGuard vmAttachGuard(_virtualMachine); - JNIEnv * pEnv = vmAttachGuard.getEnvironment(); - - jmethodID jmAppletExecutionContext_shutdown = pEnv->GetMethodID( - _jcAppletExecutionContext, "shutdown", "()V"); - testJavaException(pEnv); - pEnv->CallVoidMethod(_joAppletExecutionContext, jmAppletExecutionContext_shutdown); - testJavaException(pEnv); - - jmethodID jmWaitForDispose= pEnv->GetMethodID( - _jcAppletExecutionContext,"waitForDispose","()V"); - testJavaException(pEnv); - //blocks until the applet has destroyed itself and the container was disposed - //(stardiv.applet.AppletExecutionContext.dispose) - pEnv->CallVoidMethod(_joAppletExecutionContext, jmWaitForDispose); - - // now that the applet is disposed, we dispose the AppletExecutionContext, that will end the thread - // which dispatches the applet methods, such as init, start, stop , destroy. - jmethodID jmAppletExecutionContext_dispose= pEnv->GetMethodID( - _jcAppletExecutionContext,"dispose", "()V"); - testJavaException(pEnv); - pEnv->CallVoidMethod(_joAppletExecutionContext, jmAppletExecutionContext_dispose); - testJavaException(pEnv); - - if( _pParentWin ) - { - WorkWindow* pAppWin = Application::GetAppWindow(); - if(pAppWin) - { - while(_pParentWin->GetChildCount()) - { - Window* pChild = _pParentWin->GetChild(0); - pChild->Show( FALSE ); - pChild->SetParent( pAppWin ); - } - } - } - } - catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) - { - throw RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "SjApplet2_Impl::close, Could not create jvmaccess::" - "VirtualMachine::AttachGuard!")), 0); - } -#else // !SOLAR_JAVA - throwException(); -#endif -} - diff --git a/sj2/source/jscpp/sjapplet_impl.hxx b/sj2/source/jscpp/sjapplet_impl.hxx deleted file mode 100644 index 61867984f407..000000000000 --- a/sj2/source/jscpp/sjapplet_impl.hxx +++ /dev/null @@ -1,56 +0,0 @@ -#include <cstdarg> - -#ifdef SOLAR_JAVA -#include <jni.h> -#endif // SOLAR_JAVA - -#ifdef SOLAR_JAVA -#include <com/sun/star/java/XJavaVM.hpp> -#include <com/sun/star/java/XJavaThreadRegister_11.hpp> -#else -#include <com/sun/star/uno/RuntimeException.hpp> -#endif // SOLAR_JAVA - -#include "rtl/ref.hxx" -#include "com/sun/star/uno/Reference.hxx" -#include "jvmaccess/virtualmachine.hxx" - -class Window; -class INetURLObject; -class SvCommandList; -class Size; -namespace com { namespace sun { namespace star { namespace uno { - class XComponentContext; -} } } } - -#ifdef SOLAR_JAVA -struct EmbeddedWindow; -#endif // SOLAR_JAVA - -struct SjApplet2_Impl { -#ifdef SOLAR_JAVA - Window * _pParentWin; - - rtl::Reference<jvmaccess::VirtualMachine> _virtualMachine; - - jobject _joAppletExecutionContext; - jclass _jcAppletExecutionContext; - - EmbeddedWindow * _pEmbeddedWindow; -#endif // SOLAR_JAVA - SjApplet2_Impl() throw(com::sun::star::uno::RuntimeException); - ~SjApplet2_Impl() throw(); - - void init(Window * pParentWin, - com::sun::star::uno::Reference< - com::sun::star::uno::XComponentContext > const & context, - const INetURLObject & rDocBase, - const SvCommandList & rCmdList) throw(com::sun::star::uno::RuntimeException); - - void setSize(const Size & rSize) throw(com::sun::star::uno::RuntimeException); - void restart() throw(com::sun::star::uno::RuntimeException); - void reload() throw(com::sun::star::uno::RuntimeException); - void start() throw(com::sun::star::uno::RuntimeException); - void stop() throw(com::sun::star::uno::RuntimeException); - void close() throw(com::sun::star::uno::RuntimeException); -}; diff --git a/sj2/stardiv/app/AppletMessageHandler.java b/sj2/stardiv/app/AppletMessageHandler.java deleted file mode 100644 index 07782c11183c..000000000000 --- a/sj2/stardiv/app/AppletMessageHandler.java +++ /dev/null @@ -1,117 +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: AppletMessageHandler.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package stardiv.app; - -import java.util.ResourceBundle; -import java.util.MissingResourceException; -import java.text.MessageFormat; - -/** - * An hanlder of localized messages. - * - * @version 1.8, 03/03/97 - * @author Koji Uno - */ -public class AppletMessageHandler { - private static ResourceBundle rb; - private String baseKey = null; - - static { - try { - rb = ResourceBundle.getBundle("stardiv.app.MsgAppletViewer"); - } catch (MissingResourceException e) { - System.out.println(e.getMessage()); - } - }; - - public AppletMessageHandler(String baseKey) { - this.baseKey = baseKey; - } - - public String getMessage(String key) { - return (String)rb.getString(getQualifiedKey(key)); - } - - public String getMessage(String key, Object arg){ - String basemsgfmt = (String)rb.getString(getQualifiedKey(key)); - MessageFormat msgfmt = new MessageFormat(basemsgfmt); - Object msgobj[] = new Object[1]; - if (arg == null) { - arg = "null"; // mimic java.io.PrintStream.print(String) - } - msgobj[0] = arg; - return msgfmt.format(msgobj); - } - - public String getMessage(String key, Object arg1, Object arg2) { - String basemsgfmt = (String)rb.getString(getQualifiedKey(key)); - MessageFormat msgfmt = new MessageFormat(basemsgfmt); - Object msgobj[] = new Object[2]; - if (arg1 == null) { - arg1 = "null"; - } - if (arg2 == null) { - arg2 = "null"; - } - msgobj[0] = arg1; - msgobj[1] = arg2; - return msgfmt.format(msgobj); - } - - public String getMessage(String key, Object arg1, Object arg2, Object arg3) { - String basemsgfmt = (String)rb.getString(getQualifiedKey(key)); - MessageFormat msgfmt = new MessageFormat(basemsgfmt); - Object msgobj[] = new Object[3]; - if (arg1 == null) { - arg1 = "null"; - } - if (arg2 == null) { - arg2 = "null"; - } - if (arg3 == null) { - arg3 = "null"; - } - msgobj[0] = arg1; - msgobj[1] = arg2; - msgobj[2] = arg3; - return msgfmt.format(msgobj); - } - - public String getMessage(String key, Object arg[]) { - String basemsgfmt = (String)rb.getString(getQualifiedKey(key)); - MessageFormat msgfmt = new MessageFormat(basemsgfmt); - return msgfmt.format(arg); - } - - public String getQualifiedKey(String subKey) { - return baseKey + "." + subKey; - } -} diff --git a/sj2/stardiv/app/AppletProps.java b/sj2/stardiv/app/AppletProps.java deleted file mode 100644 index b1ad41e638e0..000000000000 --- a/sj2/stardiv/app/AppletProps.java +++ /dev/null @@ -1,190 +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: AppletProps.java,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package stardiv.app; - -import stardiv.app.AppletMessageHandler; -import stardiv.applet.AppletExecutionContext; - -import java.awt.*; -import java.io.*; -import java.util.Properties; -import sun.net.www.http.HttpClient; -import sun.net.ftp.FtpClient; - -public class AppletProps extends Frame { - TextField proxyHost; - TextField proxyPort; - Choice networkMode; - Choice accessMode; - Choice unsignedMode; - - AppletExecutionContext appletExecutionContext; - - AppletProps(AppletExecutionContext appletExecutionContext) { - this.appletExecutionContext = appletExecutionContext; - - setTitle(amh.getMessage("title")); - Panel p = new Panel(); - p.setLayout(new GridLayout(0, 2)); - - p.add(new Label(amh.getMessage("label.http.server", "Http proxy server:"))); - p.add(proxyHost = new TextField()); - - p.add(new Label(amh.getMessage("label.http.proxy"))); - p.add(proxyPort = new TextField()); - - p.add(new Label(amh.getMessage("label.network"))); - p.add(networkMode = new Choice()); - networkMode.addItem(amh.getMessage("choice.network.item.none")); - networkMode.addItem(amh.getMessage("choice.network.item.applethost")); - networkMode.addItem(amh.getMessage("choice.network.item.unrestricted")); - - String securityMode = System.getProperty("appletviewer.security.mode"); - securityMode = (securityMode == null) ? "none" : securityMode; - securityMode = securityMode.equals("host") ? "applethost" : securityMode; - networkMode.select(amh.getMessage("choice.network.item." + securityMode)); - - p.add(new Label(amh.getMessage("label.class"))); - p.add(accessMode = new Choice()); - accessMode.addItem(amh.getMessage("choice.class.item.restricted")); - accessMode.addItem(amh.getMessage("choice.class.item.unrestricted")); - - accessMode.select(Boolean.getBoolean("package.restrict.access.sun") - ? amh.getMessage("choice.class.item.restricted") - : amh.getMessage("choice.class.item.unrestricted")); - - p.add(new Label(amh.getMessage("label.unsignedapplet"))); - p.add(unsignedMode = new Choice()); - unsignedMode.addItem(amh.getMessage("choice.unsignedapplet.no")); - unsignedMode.addItem(amh.getMessage("choice.unsignedapplet.yes")); - - add("Center", p); - p = new Panel(); - p.add(new Button(amh.getMessage("button.apply"))); - p.add(new Button(amh.getMessage("button.reset"))); - p.add(new Button(amh.getMessage("button.cancel"))); - add("South", p); - setLocation(200, 150); - pack(); - reset(); - } - - void reset() { - // if (Boolean.getBoolean("package.restrict.access.sun")) { - // accessMode.select(amh.getMessage("choice.class.item.restricted")); - // } else { - // accessMode.select(amh.getMessage("choice.class.item.unrestricted")); - // } - - if (System.getProperty("http.proxyHost") != null) { - proxyHost.setText(System.getProperty("http.proxyHost")); - proxyPort.setText(System.getProperty("http.proxyPort")); - // HttpClient.proxyPort = Integer.valueOf(System.getProperty("http.proxyPort")).intValue(); - } - else { - proxyHost.setText(""); - proxyPort.setText(""); - } - - // if (Boolean.getBoolean("appletviewer.security.allowUnsigned")) { - // unsignedMode.select(amh.getMessage("choice.unsignedapplet.yes")); - // } else { - // unsignedMode.select(amh.getMessage("choice.unsignedapplet.no")); - // } - } - - void apply() { - // Get properties, set version - Properties props = System.getProperties(); - if (proxyHost.getText().length() > 0) { - props.put("http.proxyHost", proxyHost.getText().trim()); - props.put("http.proxyPort", proxyPort.getText().trim()); - } else { - props.remove("http.proxyHost"); - } - if ("None".equals(networkMode.getSelectedItem())) { - props.put("appletviewer.security.mode", "none"); - } else if ("Unrestricted".equals(networkMode.getSelectedItem())) { - props.put("appletviewer.security.mode", "unrestricted"); - } else { - props.put("appletviewer.security.mode", "host"); - } - - if ("Restricted".equals(accessMode.getSelectedItem())) { - props.put("package.restrict.access.sun", "true"); - props.put("package.restrict.access.netscape", "true"); - props.put("package.restrict.access.stardiv", "true"); - } else { - props.put("package.restrict.access.sun", "false"); - props.put("package.restrict.access.netscape", "false"); - props.put("package.restrict.access.stardiv", "false"); - } - - if ("Yes".equals(unsignedMode.getSelectedItem())) { - props.put("appletviewer.security.allowUnsigned", "true"); - } else { - props.put("appletviewer.security.allowUnsigned", "false"); - } - - // Save properties - try { - reset(); - - FileOutputStream out = new FileOutputStream(AppletViewer.theUserPropertiesFile); - props.save(out, "AppletViewer"); - out.close(); - setVisible( false ); - } catch (IOException e) { - System.out.println(amh.getMessage("apply.exception", e)); - e.printStackTrace(); - reset(); - } - } - - public boolean action(Event evt, Object obj) { - if (amh.getMessage("button.apply").equals(obj)) { - apply(); - return true; - } - if (amh.getMessage("button.reset").equals(obj)) { - reset(); - return true; - } - if (amh.getMessage("button.cancel").equals(obj)) { - setVisible( false ); - return true; - } - return false; - } - - private static AppletMessageHandler amh = new AppletMessageHandler("appletprops"); - -} diff --git a/sj2/stardiv/app/AppletViewer.java b/sj2/stardiv/app/AppletViewer.java deleted file mode 100644 index db54daecd3f7..000000000000 --- a/sj2/stardiv/app/AppletViewer.java +++ /dev/null @@ -1,995 +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: AppletViewer.java,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -package stardiv.app; - -import java.awt.Toolkit; - -import java.net.InetAddress; - -//import stardiv.applet.AppletMessageHandler; -import stardiv.applet.AppletExecutionContext; -import stardiv.applet.DocumentProxy; - -//import stardiv.js.ip.RootTaskManager; -//import stardiv.js.ip.BaseObj; -//import stardiv.js.ide.Ide; -//import stardiv.js.ne.RunTime; -//import stardiv.js.base.IdentifierPool; -//import stardiv.js.base.Identifier; -//import stardiv.memory.AtomUnion; -//import stardiv.js.ip.Ctor; -import stardiv.controller.SjSettings; - -import java.util.*; -import java.io.*; -import java.awt.*; -import java.awt.event.*; -import java.applet.*; -import java.net.URL; -import java.net.MalformedURLException; - - -/** - * A frame to show the applet tag in. - */ -class TextFrame extends Frame { - /** - * Create the tag frame. - */ - TextFrame(int x, int y, String title, String text) { - setTitle(title); - TextArea txt = new TextArea(20, 60); - txt.setText(text); - txt.setEditable(false); - - add("Center", txt); - - Panel p = new Panel(); - add("South", p); - Button b = new Button(amh.getMessage("button.dismiss", "Dismiss")); - p.add(b); - - class ActionEventListener implements ActionListener { - public void actionPerformed(ActionEvent evt) { - dispose(); - } - } - b.addActionListener(new ActionEventListener()); - - pack(); - setLocation(x, y); - setVisible(true); - - WindowListener windowEventListener = new WindowAdapter() { - - public void windowClosing(WindowEvent evt) { - dispose(); - } - }; - - addWindowListener(windowEventListener); - } - private static AppletMessageHandler amh = new AppletMessageHandler("textframe"); - -} - -/** - * The toplevel applet viewer. - */ -public class AppletViewer extends Frame implements Observer { - com.sun.star.lib.sandbox.ResourceViewer resourceViewer; - - /** - * Some constants... - */ - private static String defaultSaveFile = "Applet.ser"; - - /** - * Look here for the properties file - */ - public static File theUserPropertiesFile; - public static File theAppletViewerPropsFile; - - //private Ide aIde; - //private RootTaskManager aRTM; - //private BaseObj aRootObj; - - private AppletExecutionContext appletExecutionContext = null; - Hashtable atts = null; - - static DocumentProxy documentViewer = null; - - /** - * The status line. - */ - Label label; - - /** - * output status messages to this stream - */ - - PrintStream statusMsgStream; - - static Vector contexts = new Vector(); - - private final class UserActionListener implements ActionListener { - public void actionPerformed(ActionEvent evt) { - processUserAction(evt); - } - } - - static { - String sep = File.separator; - - File userHome = new File(System.getProperty("user.home")); - - File AVHome = new File(userHome, ".hotjava"); - // ensure the props folder can be made - AVHome.mkdirs(); - - theUserPropertiesFile = new File(AVHome, "properties"); - File JH = new File(System.getProperty("java.home")); - theAppletViewerPropsFile = new File(JH, "lib" + sep + "appletviewer.properties"); - }; - - /** - * Create the applet viewer - */ - public AppletViewer(int x, int y, URL doc, Hashtable atts, PrintStream statusMsgStream) { -// resourceViewer = new stardiv.util.ResourceViewer(); -// resourceViewer.show(); - //sun.awt.ScreenUpdater does not exist in Java 1.4 -// System.err.println("#*#*#*:" + sun.awt.ScreenUpdater.updater); - this.statusMsgStream = statusMsgStream; - this.atts = atts; - - setTitle(amh.getMessage("tool.title", atts.get("code"))); - - MenuBar mb = new MenuBar(); - - Menu m = new Menu(amh.getMessage("menu.applet")); - - addMenuItem(m, "menuitem.restart"); - addMenuItem(m, "menuitem.reload"); - addMenuItem(m, "menuitem.stop"); - addMenuItem(m, "menuitem.save"); - addMenuItem(m, "menuitem.start"); - addMenuItem(m, "menuitem.clone"); - m.add(new MenuItem("-")); - addMenuItem(m, "menuitem.tag"); - addMenuItem(m, "menuitem.info"); - addMenuItem(m, "menuitem.edit").setEnabled( false ); - addMenuItem(m, "menuitem.encoding"); - m.add(new MenuItem("-")); - addMenuItem(m, "menuitem.print"); - m.add(new MenuItem("-")); - addMenuItem(m, "menuitem.props"); - m.add(new MenuItem("-")); - addMenuItem(m, "menuitem.close"); - // if (factory.isStandalone()) { - addMenuItem(m, "menuitem.quit"); - // } - - mb.add(m); - - setMenuBar(mb); - - addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent evt) { - appletExecutionContext.shutdown(); - } - - public void windowIconified(WindowEvent evt) { - appletExecutionContext.sendLoad(); - } - - public void windowDeiconified(WindowEvent evt) { - appletExecutionContext.sendStart(); - } - }); - - add("South", label = new Label(amh.getMessage("label.hello"))); - - appletExecutionContext = new AppletExecutionContext(doc, atts, this, 0); - appletExecutionContext.init(); - - appletExecutionContext.addObserver(this); - contexts.addElement(appletExecutionContext); - - pack(); - setVisible(true); - -// appletExecutionContext.send(); - appletExecutionContext.startUp(); - -/* - if( atts.get( "mayscript" ) != null ) { - aIde = new Ide(); - aRTM = aIde.getActRootTaskManager(); - aRootObj = new BaseObj( aRTM ); - //Ctor aCtor = new AppletCtor( aRTM, "Window" ); - //aRootObj.initProperties( aCtor, aCtor.getStaticPropCount(), aCtor.getBasePropCount() ); - //aRootObj.setCtor( aCtor ); - aRTM.setRootObj( aRootObj ); - RunTime aRT = new RunTime( aRootObj, aRTM ); - aIde.setRootObj( aRootObj ); - - AtomUnion aAU = new AtomUnion(); - BaseObj aDocument = new BaseObj( aRTM ); - aAU.setObject( aDocument ); - Identifier aId = IdentifierPool.aGlobalPool.addIdentifier( "RootObject" ); - aRootObj.newProperty( aId, aAU ); - IdentifierPool.aGlobalPool.releaseIdentifier( aId ); - - String pName = (String)atts.get( "name" ); - if( pName != null ) { - BaseObj aApplet = new BaseObj( aRTM ); - aAU.setObject( aApplet ); - aId = IdentifierPool.aGlobalPool.addIdentifier( pName ); - aDocument.newProperty( aId, aAU ); - IdentifierPool.aGlobalPool.releaseIdentifier( aId ); - } - } - */ - } - - public MenuItem addMenuItem(Menu m, String s) { - MenuItem mItem = new MenuItem(amh.getMessage(s)); - mItem.addActionListener(new UserActionListener()); - return m.add(mItem); - } - - /** - * Ignore. - */ - public void showDocument(URL url) { - } - - /** - * Ignore. - */ - public void showDocument(URL url, String target) { - } - - /** - * Show status. - */ - public void showStatus(String status) { - label.setText(status); - } - - public void update(Observable observable, Object status) { - showStatus((String)status); - } - - public Object getJavaScriptJSObjectWindow() { - //if( aRootObj != null ) - // return aRootObj.getJSObject(); - return null; - } - - - /** - * System parameters. - */ - static Hashtable systemParam = new Hashtable(); - - static { - systemParam.put("codebase", "codebase"); - systemParam.put("code", "code"); - systemParam.put("alt", "alt"); - systemParam.put("width", "width"); - systemParam.put("height", "height"); - systemParam.put("align", "align"); - systemParam.put("vspace", "vspace"); - systemParam.put("hspace", "hspace"); - } - - /** - * Print the HTML tag. - */ - public static void printTag(PrintStream out, Hashtable atts) { - out.print("<applet"); - - String v = (String)atts.get("codebase"); - if (v != null) { - out.print(" codebase=\"" + v + "\""); - } - - v = (String)atts.get("code"); - if (v == null) { - v = "applet.class"; - } - out.print(" code=\"" + v + "\""); - v = (String)atts.get("width"); - if (v == null) { - v = "150"; - } - out.print(" width=" + v); - - v = (String)atts.get("height"); - if (v == null) { - v = "100"; - } - out.print(" height=" + v); - - v = (String)atts.get("name"); - if (v != null) { - out.print(" name=\"" + v + "\""); - } - out.println(">"); - - // A very slow sorting algorithm - int len = atts.size(); - String params[] = new String[len]; - len = 0; - for (Enumeration e = atts.keys() ; e.hasMoreElements() ;) { - String param = (String)e.nextElement(); - int i = 0; - for (; i < len ; i++) { - if (params[i].compareTo(param) >= 0) { - break; - } - } - System.arraycopy(params, i, params, i + 1, len - i); - params[i] = param; - len++; - } - - for (int i = 0 ; i < len ; i++) { - String param = params[i]; - if (systemParam.get(param) == null) { - out.println("<param name=" + param + - " value=\"" + atts.get(param) + "\">"); - } - } - out.println("</applet>"); - } - - /** - * Make sure the atrributes are uptodate. - */ - public void updateAtts() { - Dimension d = getSize(); - Insets in = getInsets(); - atts.put("width", new Integer(d.width - (in.left + in.right)).toString()); - atts.put("height", new Integer(d.height - (in.top + in.bottom)).toString()); - } - - /** - * Save the applet to a well known file (for now) as a serialized object - */ - void appletSave() { - // REMIND -- should check that the applet has really stopped - FileDialog fd = new FileDialog(this, "Serialize Applet into File", FileDialog.SAVE); - // needed for a bug under Solaris... - fd.setDirectory(System.getProperty("user.dir")); - fd.setFile(defaultSaveFile); - fd.show(); - String fname = fd.getFile(); - if (fname == null) { - return; // cancelled - } - String dname = fd.getDirectory(); - File file = new File(dname, fname); - - try { - OutputStream s = new FileOutputStream(file); - ObjectOutputStream os = new ObjectOutputStream(s); - showStatus(amh.getMessage("appletsave.err1", - appletExecutionContext.getApplet().toString(), file.toString())); - os.writeObject(appletExecutionContext.getApplet()); - } catch (IOException ex) { - System.err.println(amh.getMessage("appletsave.err2", ex)); - } - } - - /** - * Clone the viewer and the applet. - */ - void appletClone() { - Point p = getLocation(); - updateAtts(); - // factory.createAppletViewer(p.x + 30, p.y + 10, - // pHelper.panel.documentURL, (Hashtable)pHelper.panel.atts.clone()); - } - - /** - * Show the applet tag. - */ - void appletTag() { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - updateAtts(); - printTag(new PrintStream(out), atts); - showStatus(amh.getMessage("applettag")); - - Point p = getLocation(); - new TextFrame(p.x + 50, p.y + 20, amh.getMessage("applettag.textframe"), out.toString()); - } - - /** - * Show the applet info. - */ - void appletInfo() { - String str = appletExecutionContext.getApplet().getAppletInfo(); - if (str == null) { - str = amh.getMessage("appletinfo.applet"); - } - str += "\n\n"; - - String atts[][] = appletExecutionContext.getApplet().getParameterInfo(); - if (atts != null) { - for (int i = 0 ; i < atts.length ; i++) { - str += atts[i][0] + " -- " + atts[i][1] + " -- " + atts[i][2] + "\n"; - } - } else { - str += amh.getMessage("appletinfo.param"); - } - - Point p = getLocation(); - new TextFrame(p.x + 50, p.y + 20, amh.getMessage("appletinfo.textframe"), str); - - } - - /** - * Show character encoding type - */ - void appletCharacterEncoding() { - showStatus(amh.getMessage("appletencoding", encoding)); - } - - /** - * Edit the applet. - */ - void appletEdit() { - } - - /** - * Print the applet. - */ - void appletPrint() { - PrintJob pj = Toolkit.getDefaultToolkit(). - getPrintJob(this, amh.getMessage("appletprint.printjob"), (Properties)null); - - - if (pj != null) { - Dimension pageDim = pj.getPageDimension(); - int pageRes = pj.getPageResolution(); - boolean lastFirst = pj.lastPageFirst(); - - Graphics g = pj.getGraphics(); - if (g != null) { - appletExecutionContext.getApplet().printComponents(g); - g.dispose(); - } else { - statusMsgStream.println(amh.getMessage("appletprint.fail")); - } - statusMsgStream.println(amh.getMessage("appletprint.finish")); - pj.end(); - - } else { - statusMsgStream.println(amh.getMessage("appletprint.cancel")); - } - } - - /** - * Properties. - */ - AppletProps props; - public synchronized void networkProperties() { - if (props == null) { - props = new AppletProps(appletExecutionContext); - } - props.addNotify(); - props.setVisible(true); - } - - /** - * Close this viewer. - * Stop, Destroy, Dispose and Quit an AppletView, then - * reclaim resources and exit the program if this is - * the last applet. - */ - public void appletClose() { - appletExecutionContext.shutdown(); - contexts.removeElement(this); - - if (contexts.size() == 0) { - appletSystemExit(); - } - } - - -// public static void writeClasses() { -// try { -// java.io.FileOutputStream file = new FileOutputStream("classes.txt"); -// java.io.PrintStream printStream = new java.io.PrintStream(file); - -// printStream.println("- .* .*"); -// Enumeration elements = stardiv.util.HardClassContext.classList.elements(); -// while(elements.hasMoreElements()) { -// String string = (String)elements.nextElement(); - -// String packageName = ""; -// String className = string; - -// int lastIndex = string.lastIndexOf('.'); -// if(lastIndex > -1) { -// packageName = string.substring(0, lastIndex); -// className = string.substring(lastIndex + 1); -// } - -// printStream.print("+ "); -// int index; -// while((index = packageName.indexOf('.')) > -1) { -// printStream.print(packageName.substring(0, index) + "\\\\"); -// packageName = packageName.substring(index + 1); -// } -// printStream.print(packageName + " "); - -// while((index = className.indexOf('$')) > -1) { -// printStream.print(className.substring(0, index) + "\\$"); -// className = className.substring(index + 1); -// } -// printStream.println(className + "\\.class"); -// } -// file.close(); -// } -// catch(java.io.IOException eio) { -// System.err.println("IOException:" + eio); -// } -// } - - /** - * Exit the program. - * Exit from the program (if not stand alone) - do no clean-up - */ - private void appletSystemExit() { - // if (factory.isStandalone()) - System.exit(0); - } - - /** - * Quit all viewers. - * Shutdown all viewers properly then - * exit from the program (if not stand alone) - */ - protected void appletQuit() { - appletExecutionContext.shutdown(); - appletSystemExit(); - } - - /** - * Handle events. - */ - public void processUserAction(ActionEvent evt) { - - String label = ((MenuItem)evt.getSource()).getLabel(); - - if (amh.getMessage("menuitem.restart").equals(label)) { - appletExecutionContext.restart(); - return; - } - - if (amh.getMessage("menuitem.reload").equals(label)) { - appletExecutionContext.reload(); - return; - } - - if (amh.getMessage("menuitem.clone").equals(label)) { - appletClone(); - return; - } - - if (amh.getMessage("menuitem.stop").equals(label)) { - appletExecutionContext.sendStop(); - return; - } - - if (amh.getMessage("menuitem.save").equals(label)) { - appletSave(); - return; - } - - if (amh.getMessage("menuitem.start").equals(label)) { - appletExecutionContext.sendStart(); - return; - } - - if (amh.getMessage("menuitem.tag").equals(label)) { - appletTag(); - return; - } - - if (amh.getMessage("menuitem.info").equals(label)) { - appletInfo(); - return; - } - - if (amh.getMessage("menuitem.encoding").equals(label)) { - appletCharacterEncoding(); - return; - } - - if (amh.getMessage("menuitem.edit").equals(label)) { - appletEdit(); - return; - } - - if (amh.getMessage("menuitem.print").equals(label)) { - appletPrint(); - return; - } - - if (amh.getMessage("menuitem.props").equals(label)) { - networkProperties(); - return; - } - - if (amh.getMessage("menuitem.close").equals(label)) { - appletClose(); - return; - } - - if (/*factory.isStandalone() && */amh.getMessage("menuitem.quit").equals(label)) { - appletQuit(); - return; - } - //statusMsgStream.println("evt = " + evt); - } - - /** - * Prepare the enviroment for executing applets. - */ - public static void init() { - Properties props = new Properties(); - props.put( "http.proxyHost", "wwwproxy" ); - props.put( "http.proxyPort", "3128" ); - props.put( "ftpProxySet", "true" ); - props.put( "ftpProxyHost", "wwwproxy" ); - props.put( "ftpProxyPort", "3128" ); - props.put( "ftpProxyPort", "3128" ); - props.put( "stardiv.debug.trace", "window" ); - props.put( "stardiv.debug.warning", "window" ); - props.put( "stardiv.debug.error", "window" ); - props.put( "stardiv.security.defaultSecurityManager", "true" ); - - // Try loading the appletviewer properties file to get messages, etc. -// try { -// FileInputStream in = new FileInputStream(theAppletViewerPropsFile); -// props.load(new BufferedInputStream(in)); -// in.close(); -// } catch (Exception e) { -// System.out.println(amh.getMessage("init.err")); -// } - - // Try loading the saved user properties file to override some - // of the above defaults. - try { - FileInputStream in = new FileInputStream(theUserPropertiesFile); - props.load(new BufferedInputStream(in)); - in.close(); - } catch (Exception e) { - /* is it really necessary to say this? - This is always the case the first time we run.. - System.out.println("[no properties loaded, using defaults]"); */ - } - - // Install a property list. - - SjSettings.changeProperties(props); - } - - /** - * The current character. - */ - static int c; - - /** - * Scan spaces. - */ - public static void skipSpace(Reader in) throws IOException { - while ((c >= 0) && ((c == ' ') || (c == '\t') || (c == '\n') || (c == '\r'))) { - c = in.read(); - } - } - - /** - * Scan identifier - */ - public static String scanIdentifier(Reader in) throws IOException { - StringBuffer buf = new StringBuffer(); - while (true) { - if (((c >= 'a') && (c <= 'z')) || - ((c >= 'A') && (c <= 'Z')) || - ((c >= '0') && (c <= '9')) || (c == '_')) { - buf.append((char)c); - c = in.read(); - } else { - return buf.toString(); - } - } - } - - /** - * Scan tag - */ - public static Hashtable scanTag(Reader in) throws IOException { - Hashtable atts = new Hashtable(); - skipSpace(in); - while (c >= 0 && c != '>') { - String att = scanIdentifier(in); - String val = ""; - skipSpace(in); - if (c == '=') { - int quote = -1; - c = in.read(); - skipSpace(in); - if ((c == '\'') || (c == '\"')) { - quote = c; - c = in.read(); - } - StringBuffer buf = new StringBuffer(); - while ((c > 0) && - (((quote < 0) && (c != ' ') && (c != '\t') && - (c != '\n') && (c != '\r') && (c != '>')) - || ((quote >= 0) && (c != quote)))) { - buf.append((char)c); - c = in.read(); - } - if (c == quote) { - c = in.read(); - } - skipSpace(in); - val = buf.toString(); - } - //statusMsgStream.println("PUT " + att + " = '" + val + "'"); - atts.put(att.toLowerCase(), val); - skipSpace(in); - } - return atts; - } - - static int x = 100; - static int y = 50; - - static String encoding = null; - - static private Reader makeReader(InputStream is) { - if (encoding != null) { - try { - return new BufferedReader(new InputStreamReader(is, encoding)); - } catch (IOException x) { } - } - InputStreamReader r = new InputStreamReader(is); - encoding = r.getEncoding(); - return new BufferedReader(r); - } - - /** - * Scan an html file for <applet> tags - */ - public static void parse(URL url) throws IOException { - parse(url, System.out); - } - - public static void parse(URL url, PrintStream statusMsgStream) throws IOException { - - // warning messages - String requiresNameWarning = amh.getMessage("parse.warning.requiresname"); - String paramOutsideWarning = amh.getMessage("parse.warning.paramoutside"); - String requiresCodeWarning = amh.getMessage("parse.warning.requirescode"); - String requiresHeightWarning = amh.getMessage("parse.warning.requiresheight"); - String requiresWidthWarning = amh.getMessage("parse.warning.requireswidth"); - String appNotLongerSupportedWarning = amh.getMessage("parse.warning.appnotLongersupported"); - - java.net.URLConnection conn = url.openConnection(); - Reader in = makeReader(conn.getInputStream()); - /* The original URL may have been redirected - this - * sets it to whatever URL/codebase we ended up getting - */ - url = conn.getURL(); - - Hashtable atts = null; - while(true) { - c = in.read(); - if (c == -1) - break; - - if (c == '<') { - c = in.read(); - if (c == '/') { - c = in.read(); - String nm = scanIdentifier(in); - if (nm.equalsIgnoreCase("applet")) { - if (atts != null) { - new AppletViewer(x, y, url, atts, System.out); - x += 50; - y += 20; - // make sure we don't go too far! - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - if (x > d.width - 30) - x = 100; - if (y > d.height - 30) - y = 50; - } - atts = null; - } - } - else { - String nm = scanIdentifier(in); - if (nm.equalsIgnoreCase("param")) { - Hashtable t = scanTag(in); - String att = (String)t.get("name"); - if (att == null) { - statusMsgStream.println(requiresNameWarning); - } else { - String val = (String)t.get("value"); - if (val == null) { - statusMsgStream.println(requiresNameWarning); - } else if (atts != null) { - atts.put(att.toLowerCase(), val); - } else { - statusMsgStream.println(paramOutsideWarning); - } - } - } - else if (nm.equalsIgnoreCase("applet")) { - atts = scanTag(in); - if (atts.get("code") == null && atts.get("object") == null) { - statusMsgStream.println(requiresCodeWarning); - atts = null; - } else if (atts.get("width") == null) { - statusMsgStream.println(requiresWidthWarning); - atts = null; - } else if (atts.get("height") == null) { - statusMsgStream.println(requiresHeightWarning); - atts = null; - } - } - else if (nm.equalsIgnoreCase("app")) { - statusMsgStream.println(appNotLongerSupportedWarning); - Hashtable atts2 = scanTag(in); - nm = (String)atts2.get("class"); - if (nm != null) { - atts2.remove("class"); - atts2.put("code", nm + ".class"); - } - nm = (String)atts2.get("src"); - if (nm != null) { - atts2.remove("src"); - atts2.put("codebase", nm); - } - if (atts2.get("width") == null) { - atts2.put("width", "100"); - } - if (atts2.get("height") == null) { - atts2.put("height", "100"); - } - printTag(statusMsgStream, atts2); - statusMsgStream.println(); - } - } - } - } - in.close(); - } - - /** - * Print usage - */ - static void usage() { - System.out.println(amh.getMessage("usage")); - } - - static boolean didInitialize = false; - - /** - * mainInit can be called by direct clients - */ - public static void mainInit() { - if (! didInitialize) { - didInitialize = true; - - init(); - - } - } - - /** - * Main - */ - public static void main(String argv[]) { - mainInit(); - - // Parse arguments - if (argv.length == 0) { - System.out.println(amh.getMessage("main.err.inputfile")); - usage(); - return; - } - - // Parse the documents - for (int i = 0 ; i < argv.length ; i++) { - try { - URL url = null; - - if (argv[i].equals("-encoding")) { - if(i + 1 < argv.length) { - i++; - encoding = argv[i]; - continue; - } else { - usage(); - System.exit(1); - } - } - else - if (argv[i].indexOf(':') <= 1) { - String userDir = System.getProperty("user.dir"); - String prot; - // prepend native separator to path iff not present - if (userDir.charAt(0) == '/' || - userDir.charAt(0) == java.io.File.separatorChar) { - prot = "file:"; - } else { - prot = "file:/"; - } - url = new URL(prot + userDir.replace(File.separatorChar, '/') - + "/"); - url = new URL(url, argv[i]); - } else { - url = new URL(argv[i]); - } - - parse(url); - documentViewer = DocumentProxy.getDocumentProxy(url, Toolkit.getDefaultToolkit()); - } catch (MalformedURLException e) { - System.out.println(amh.getMessage("main.err.badurl", argv[i], e.getMessage())); - System.exit(1); - } catch (IOException e) { - System.out.println(amh.getMessage("main.err.io", e.getMessage())); - if (argv[i].indexOf(':') < 0) { - System.out.println(amh.getMessage("main.err.readablefile", argv[i])); - } else { - System.out.println(amh.getMessage("main.err.correcturl", argv[i])); - } - System.exit(1); - } - } - /* - if (documentViewer.countApplets() == 0) { - System.out.println(amh.getMessage("main.warning")); - usage(); - System.exit(1); - }*/ - } - private static AppletMessageHandler amh = new AppletMessageHandler("appletviewer"); -} diff --git a/sj2/stardiv/app/AppletViewerFactory.java b/sj2/stardiv/app/AppletViewerFactory.java deleted file mode 100644 index da73f0648187..000000000000 --- a/sj2/stardiv/app/AppletViewerFactory.java +++ /dev/null @@ -1,46 +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: AppletViewerFactory.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -/* - * AppletViewerFactory.java - */ - -package stardiv.app; - -import java.util.Hashtable; -import java.net.URL; -import java.awt.MenuBar; - -public -interface AppletViewerFactory { - public AppletViewer createAppletViewer(int x, int y, URL doc, Hashtable atts); - public MenuBar getBaseMenuBar(); - public boolean isStandalone(); -} diff --git a/sj2/stardiv/app/MsgAppletViewer.java b/sj2/stardiv/app/MsgAppletViewer.java deleted file mode 100644 index 4f15a57758b6..000000000000 --- a/sj2/stardiv/app/MsgAppletViewer.java +++ /dev/null @@ -1,189 +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: MsgAppletViewer.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -package stardiv.app; - -import java.util.ListResourceBundle; - -public class MsgAppletViewer extends ListResourceBundle { - - public Object[][] getContents() { - return contents; - } - - static final Object[][] contents = { - {"textframe.button.dismiss", "Dismiss"}, - {"appletviewer.tool.title", "Applet Viewer: {0}"}, - {"appletviewer.menu.applet", "Applet"}, - {"appletviewer.menuitem.restart", "Restart"}, - {"appletviewer.menuitem.reload", "Reload"}, - {"appletviewer.menuitem.stop", "Stop"}, - {"appletviewer.menuitem.save", "Save..."}, - {"appletviewer.menuitem.start", "Start"}, - {"appletviewer.menuitem.clone", "Clone..."}, - {"appletviewer.menuitem.tag", "Tag..."}, - {"appletviewer.menuitem.info", "Info..."}, - {"appletviewer.menuitem.edit", "Edit"}, - {"appletviewer.menuitem.encoding", "Character Encoding"}, - {"appletviewer.menuitem.print", "Print..."}, - {"appletviewer.menuitem.props", "Properties..."}, - {"appletviewer.menuitem.close", "Close"}, - {"appletviewer.menuitem.quit", "Quit"}, - {"appletviewer.label.hello", "Hello..."}, - {"appletviewer.status.start", "starting applet..."}, - {"appletviewer.appletsave.err1", "serializing an {0} to {1}"}, - {"appletviewer.appletsave.err2", "in appletSave: {0}"}, - {"appletviewer.applettag", "Tag shown"}, - {"appletviewer.applettag.textframe", "Applet HTML Tag"}, - {"appletviewer.appletinfo.applet", "-- no applet info --"}, - {"appletviewer.appletinfo.param", "-- no parameter info --"}, - {"appletviewer.appletinfo.textframe", "Applet Info"}, - {"appletviewer.appletprint.printjob", "Print Applet"}, - {"appletviewer.appletprint.fail", "Printing failed."}, - {"appletviewer.appletprint.finish", "Finished printing."}, - {"appletviewer.appletprint.cancel", "Printing cancelled."}, - {"appletviewer.appletencoding", "Character Encoding: {0}"}, - {"appletviewer.init.err", "[no appletviewer.properties file found!]"}, - {"appletviewer.parse.warning.requiresname", "Warning: <param name=... value=...> tag requires name attribute."}, - {"appletviewer.parse.warning.paramoutside", "Warning: <param> tag outside <applet> ... </applet>."}, - {"appletviewer.parse.warning.requirescode", "Warning: <applet> tag requires code attribute."}, - {"appletviewer.parse.warning.requiresheight", "Warning: <applet> tag requires height attribute."}, - {"appletviewer.parse.warning.requireswidth", "Warning: <applet> tag requires width attribute."}, - {"appletviewer.parse.warning.appnotLongersupported", "Warning: <app> tag no longer supported, use <applet> instead:"}, - {"appletviewer.usage", "usage: appletviewer [-debug] [-J<javaflag>] [-encoding <character encoding type> ] url|file ..."}, - {"appletviewer.main.err.inputfile", "No input files specified."}, - {"appletviewer.main.err.badurl", "Bad URL: {0} ( {1} )"}, - {"appletviewer.main.err.io", "I/O exception while reading: {0}"}, - {"appletviewer.main.err.readablefile", "Make sure that {0} is a file and is readable."}, - {"appletviewer.main.err.correcturl", "Is {0} the correct URL?"}, - {"appletviewer.main.warning", "Warning: No Applets were started. Make sure the input contains an <applet> tag."}, - {"appletioexception.loadclass.throw.interrupted", "class loading interrupted: {0}"}, - {"appletioexception.loadclass.throw.notloaded", "class not loaded: {0}"}, - {"appletclassloader.loadcode.verbose", "Opening stream to: {0} to get {1}"}, - {"appletclassloader.filenotfound", "File not found when looking for: {0}"}, - {"appletclassloader.fileformat", "File format exception when loading: {0}"}, - {"appletclassloader.fileioexception", "I/O exception when loading: {0}"}, - {"appletclassloader.fileexception", "{0} exception when loading: {1}"}, - {"appletclassloader.filedeath", "{0} killed when loading: {1}"}, - {"appletclassloader.fileerror", "{0} error when loading: {1}"}, - {"appletclassloader.findclass.verbose.findclass", "{0} find class {1}"}, - {"appletclassloader.findclass.verbose.openstream", "Opening stream to: {0} to get {1}"}, - {"appletclassloader.getresource.verbose.forname", "AppletClassLoader.getResource for name: {0}"}, - {"appletclassloader.getresource.verbose.found", "Found resource: {0} as a system resource"}, - {"appletclassloader.getresourceasstream.verbose", "Found resource: {0} as a system resource"}, - {"appletcopyright.title", "Copyright Notice"}, - {"appletcopyright.button.accept", "Accept"}, - {"appletcopyright.button.reject", "Reject"}, - {"appletcopyright.defaultcontent", "Copyright (c) 1995, 1996, 1997 Sun Microsystems, Inc."}, - {"appletcopyright.copyrightfile", "COPYRIGHT"}, - {"appletcopyright.copyrightencoding", "8859_1"}, - {"appletpanel.runloader.err", "Either object or code parameter!"}, - {"appletpanel.runloader.exception", "exception while deserializing {0}"}, - {"appletpanel.destroyed", "Applet destroyed."}, - {"appletpanel.loaded", "Applet loaded."}, - {"appletpanel.started", "Applet started."}, - {"appletpanel.inited", "Applet initialized."}, - {"appletpanel.stopped", "Applet stopped."}, - {"appletpanel.disposed", "Applet disposed."}, - {"appletpanel.nocode", "APPLET tag missing CODE parameter."}, - {"appletpanel.notfound", "load: class {0} not found."}, - {"appletpanel.nocreate", "load: {0} can''t be instantiated."}, - {"appletpanel.noconstruct", "load: {0} is not public or has no public constructor."}, - {"appletpanel.death", "killed"}, - {"appletpanel.exception", "exception: {0}."}, - {"appletpanel.exception2", "exception: {0}: {1}."}, - {"appletpanel.error", "error: {0}."}, - {"appletpanel.error2", "error: {0}: {1}."}, - {"appletpanel.notloaded", "Init: applet not loaded."}, - {"appletpanel.notinited", "Start: applet not initialized."}, - {"appletpanel.notstarted", "Stop: applet not started."}, - {"appletpanel.notstopped", "Destroy: applet not stopped."}, - {"appletpanel.notdestroyed", "Dispose: applet not destroyed."}, - {"appletpanel.notdisposed", "Load: applet not disposed."}, - {"appletpanel.bail", "Interrupted: bailing out."}, - {"appletpanel.filenotfound", "File not found when looking for: {0}"}, - {"appletpanel.fileformat", "File format exception when loading: {0}"}, - {"appletpanel.fileioexception", "I/O exception when loading: {0}"}, - {"appletpanel.fileexception", "{0} exception when loading: {1}"}, - {"appletpanel.filedeath", "{0} killed when loading: {1}"}, - {"appletpanel.fileerror", "{0} error when loading: {1}"}, - {"appletillegalargumentexception.objectinputstream", "AppletObjectInputStream requires non-null loader"}, - {"appletprops.title", "AppletViewer Properties"}, - {"appletprops.label.http.server", "Http proxy server:"}, - {"appletprops.label.http.proxy", "Http proxy port:"}, - {"appletprops.label.network", "Network access:"}, - {"appletprops.choice.network.item.none", "None"}, - {"appletprops.choice.network.item.applethost", "Applet Host"}, - {"appletprops.choice.network.item.unrestricted", "Unrestricted"}, - {"appletprops.label.class", "Class access:"}, - {"appletprops.choice.class.item.restricted", "Restricted"}, - {"appletprops.choice.class.item.unrestricted", "Unrestricted"}, - {"appletprops.label.unsignedapplet", "Allow unsigned applets:"}, - {"appletprops.choice.unsignedapplet.no", "No"}, - {"appletprops.choice.unsignedapplet.yes", "Yes"}, - {"appletprops.button.apply", "Apply"}, - {"appletprops.button.cancel", "Cancel"}, - {"appletprops.button.reset", "Reset"}, - {"appletprops.apply.exception", "Failed to save properties: {0}"}, - {"appletsecurityexception.checkcreateclassloader", "Security Exception: classloader"}, - {"appletsecurityexception.checkaccess.thread", "Security Exception: thread"}, - {"appletsecurityexception.checkaccess.threadgroup", "Security Exception: threadgroup: {0}"}, - {"appletsecurityexception.checkexit", "Security Exception: exit: {0}"}, - {"appletsecurityexception.checkexec", "Security Exception: exec: {0}"}, - {"appletsecurityexception.checklink", "Security Exception: link: {0}"}, - {"appletsecurityexception.checkpropsaccess", "Security Exception: properties"}, - {"appletsecurityexception.checkpropsaccess.key", "Security Exception: properties access {0}"}, - {"appletsecurityexception.checkread.exception1", "Security Exception: {0}, {1}"}, - {"appletsecurityexception.checkread.exception2", "Security Exception: file.read: {0}"}, - {"appletsecurityexception.checkread", "Security Exception: file.read: {0} == {1}"}, - {"appletsecurityexception.checkwrite.exception", "Security Exception: {0}, {1}"}, - {"appletsecurityexception.checkwrite", "Security Exception: file.write: {0} == {1}"}, - {"appletsecurityexception.checkread.fd", "Security Exception: fd.read"}, - {"appletsecurityexception.checkwrite.fd", "Security Exception: fd.write"}, - {"appletsecurityexception.checklisten", "Security Exception: socket.listen: {0}"}, - {"appletsecurityexception.checkaccept", "Security Exception: socket.accept: {0}:{1}"}, - {"appletsecurityexception.checkconnect.networknone", "Security Exception: socket.connect: {0}->{1}"}, - {"appletsecurityexception.checkconnect.networkhost1", "Security Exception: Couldn''t connect to {0} with origin from {1}."}, - {"appletsecurityexception.checkconnect.networkhost2", "Security Exception: Couldn''t resolve IP for host {0} or for {1}. "}, - {"appletsecurityexception.checkconnect.networkhost3", "Security Exception: Could not resolve IP for host {0}. See the trustProxy property."}, - {"appletsecurityexception.checkconnect", "Security Exception: connect: {0}->{1}"}, - {"appletsecurityexception.checkpackageaccess", "Security Exception: cannot access package: {0}"}, - {"appletsecurityexception.checkpackagedefinition", "Security Exception: cannot define package: {0}"}, - {"appletsecurityexception.cannotsetfactory", "Security Exception: cannot set factory"}, - {"appletsecurityexception.checkmemberaccess", "Security Exception: check member access"}, - {"appletsecurityexception.checkgetprintjob", "Security Exception: getPrintJob"}, - {"appletsecurityexception.checksystemclipboardaccess", "Security Exception: getSystemClipboard"}, - {"appletsecurityexception.checkawteventqueueaccess", "Security Exception: getEventQueue"}, - {"appletsecurityexception.checksecurityaccess", "Security Exception: security operation: {0}"}, - {"appletsecurityexception.getsecuritycontext.unknown", "unknown class loader type. unable to check for getContext"}, - {"appletsecurityexception.checkread.unknown", "unknown class loader type. unable to check for checking read {0}"}, - {"appletsecurityexception.checkconnect.unknown", "unknown class loader type. unable to check for checking connect"}, - {"appletsecurityexception.getresource.noclassaccess", "Cannot use getResource to access .class file: {0} in JDK1.1"}, - }; -} diff --git a/sj2/stardiv/applet/AppletExecutionContext.java b/sj2/stardiv/applet/AppletExecutionContext.java deleted file mode 100644 index d69b440572ac..000000000000 --- a/sj2/stardiv/applet/AppletExecutionContext.java +++ /dev/null @@ -1,383 +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: AppletExecutionContext.java,v $ - * $Revision: 1.9 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package stardiv.applet; - -import java.applet.Applet; -import java.applet.AppletStub; -import java.applet.AppletContext; -import java.applet.AudioClip; - -import java.awt.BorderLayout; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Panel; -import java.awt.Toolkit; -import java.awt.Window; - -import java.io.IOException; -import java.io.InputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; - -import java.net.URL; -import java.net.MalformedURLException; - -import java.util.Hashtable; -import java.util.Vector; - -import sun.misc.Queue; - -import com.sun.star.lib.sandbox.ClassContextProxy; -import com.sun.star.lib.sandbox.ExecutionContext; -import com.sun.star.lib.sandbox.JarEntry; -import com.sun.star.lib.sandbox.ResourceProxy; -import com.sun.star.lib.sandbox.SandboxSecurity; -import com.sun.star.lib.sandbox.CodeSource; - -import stardiv.controller.SjSettings; - -public final class AppletExecutionContext extends ExecutionContext - implements AppletStub, LiveConnectable -{ - private static final boolean DEBUG = false; // Enable / disable debug output - - private Applet _applet; - private Container _container; - - private DocumentProxy _documentProxy; - private Hashtable _parameters; - - private String _className; - private Vector _jarResourceProxys = new Vector(); - - private URL _documentBase = null; - private URL _baseURL = null; - - private Toolkit _toolkit; - - //************** C++ WRAPPER ****************** - private long pCppJSbxObject; - - synchronized public void ClearNativeHandle() { - pCppJSbxObject = 0; - if(DEBUG)System.err.println("### AppletExecutionContext.ClearNativeHandle"); - } - - public AppletExecutionContext(long pCppJSbxObject) { - this.pCppJSbxObject = pCppJSbxObject; - } - //************** C++ WRAPPER ****************** - - public AppletExecutionContext( URL documentBase, - Hashtable parameters, - Container container, - long pCppJSbxObject) - { - this(pCppJSbxObject); - - if(DEBUG) System.err.println("#### AppletExecutionContext.<init>:" + documentBase + " " + parameters + " " + container + " " + pCppJSbxObject); - _documentBase = documentBase; - _parameters = parameters; - _container = container; - - _toolkit = container.getToolkit(); - - _documentProxy = DocumentProxy.getDocumentProxy(documentBase, _toolkit); - addObserver(_documentProxy); - } - - public void init() { - _baseURL = null; - - try { - String codeBase = getParameter("codebase"); - - if (!codeBase.endsWith("/")) { - codeBase += "/"; - } - _baseURL = new URL(_documentBase, codeBase); - } - catch (MalformedURLException e) { - if(DEBUG) System.err.println("#### AppletExecutionContext: Could not create base Url"); - } - - if(_baseURL == null) - _baseURL = _documentBase; - - if(DEBUG) System.err.println("##### " + getClass().getName() + ".init - baseUrl:" + _baseURL); - - _className = getParameter("code"); - String defaultExtension = ".class"; - String oldExtension = ".java"; - - int extensionIndex = _className.lastIndexOf('.'); - String extension = ""; - - if (extensionIndex != -1) { - extension = _className.substring(extensionIndex); - - if(!extension.equals(defaultExtension) && !extension.equals(oldExtension)) { - extension = defaultExtension; - } - else - _className = _className.substring(0, extensionIndex); - } - - String nm = "applet-" + _className; - - _documentProxy.addExecutionContext(this, _className); - - super.init(nm, ClassContextProxy.create(_baseURL, null, null, false)); - - // Set the property stardiv.security.noExit to true. That value will be used in - // SjSettings.changeProperties in the constructor of the SecurityManager SandboxSecurity - if (System.getSecurityManager() == null) - System.setProperty("stardiv.security.noExit", "true"); - // SjSettings.changeProperties puts a lot of applet relating properties into the system properties - // and it sets the SecurityManager - SjSettings.changeProperties( System.getProperties()); - - if(DEBUG) System.err.println("#####" + getClass().getName() + ".init: _className=" + _className + " _baseURL=" + _baseURL); - } - - void sDispose(long timeout) { - if(DEBUG) System.err.println("#### AppletExecutionContext.sDispose"); - - _container = null; - _jarResourceProxys = null; - - super.dispose(timeout); - } - - public void dispose(long timeout) { - sDispose(timeout); // call direct - -/* Deadlock with TKT - class DisposeEvent extends java.awt.AWTEvent - implements java.awt.peer.ActiveEvent, - java.awt.ActiveEvent - { - private AppletExecutionContext executionContext; - private long timeout; - - public DisposeEvent(AppletExecutionContext executionContext, long timeout) { - super(executionContext, 0); - - this.executionContext = executionContext; - this.timeout = timeout; - } - - public void dispatch() { - executionContext.sDispose(timeout); - } - } - - toolkit.getSystemEventQueue().postEvent(new DisposeEvent(this, timeout)); -*/ - } - - protected int getIntParameter(String name) { - int value = 0; - String string = getParameter(name); - if(string != null) - value = Integer.valueOf(string).intValue(); - - return value; - } - - protected void xload() - throws ClassNotFoundException, - InstantiationException, - IllegalAccessException - { - String archives = getParameter("archive"); - - try { - if(archives != null) { - int index = archives.indexOf(","); - while(index > -1) { - try { // try to load archive - loadArchive(archives.substring(0, index)); - } - catch(MalformedURLException malformedURLException) { - System.err.println("#### can't load archive:" + archives.substring(0, index)); - } - catch(IOException ioException) { - System.err.println("#### can't load archive:" + archives.substring(0, index) + " reason:" + ioException); - } - - archives = archives.substring(index + 1).trim(); - - index = archives.indexOf(","); - } - if(archives.length() > 0) loadArchive(archives); - } - - Class appletClass = classContext.loadClass(_className); - synchronized(_className) { - _applet = (Applet)appletClass.newInstance(); - _applet.setStub(this); - - appletResize(_container.getSize().width, _container.getSize().height); - - _className.notifyAll(); - } - } - catch(IOException eio) { - throw new ClassNotFoundException(eio.getMessage()); - } - } - - protected void xinit() { - java.awt.Dimension size = new Dimension(getIntParameter("width"), getIntParameter("height")); - - _container.setLayout(null); - _container.setVisible(true); - _container.setSize(size); - _container.add(_applet); - - _applet.setVisible(false); - _applet.setSize(size); - - _container.validate(); - - _applet.init(); - } - - protected void xstart() { - _applet.setVisible(true); - _container.validate(); - - _applet.start(); - } - - protected void xstop() { - _applet.stop(); - } - - protected void xdestroy() { - if(DEBUG) System.err.println("##### " + getClass().getName() + ".xdestroy"); - - _applet.destroy(); - _applet.setVisible(false); - _applet.setStub(null); - - _documentProxy.removeExecutionContext(_applet.getClass().getName()); - } - - protected void xdispose() { - if(DEBUG) System.err.println("##### " + getClass().getName() + ".xdispose"); - - if(_container != null) { - _container.remove(_applet); - - if(_container instanceof Window) - ((Window)_container).dispose(); - } - - _applet = null; - } - - private void loadArchive(String archive) throws MalformedURLException, IOException { - ResourceProxy jarResourceProxy = ResourceProxy.load(new URL(_baseURL, archive), null /*_protectionDomain*/); - jarResourceProxy.loadJar(_baseURL); - _jarResourceProxys.addElement(jarResourceProxy); - } - - public Applet getApplet() { - synchronized(_className) { - if(_applet == null) { - if(DEBUG)System.err.println("#### AppletExecutionContext.getApplet - waiting for applet"); - try { - _className.wait(); - } - catch(InterruptedException interruptedException) { - System.err.println("#### AppletExecutionContext.getApplet:" + interruptedException); - } - if(DEBUG)System.err.println("#### AppletExecutionContext.getApplet - got it"); - } - } - return _applet; - } - - /* - * Methods for AppletStub interface - */ - public void appletResize(int width, int height) { - if(DEBUG) System.err.println("##### " + getClass().getName() + ".appletResize: " + width + " " + height); - - _container.setSize(width, height); - if(_applet != null) - _applet.setSize(width, height); - } - - public AppletContext getAppletContext() { - return _documentProxy; - } - - public URL getCodeBase() { - return classContext.getBase(); - } - - public URL getDocumentBase() { - return _documentProxy.getDocumentBase(); - } - - public String getParameter(String name) { - String string = (String)_parameters.get(name.toLowerCase()); - if(string != null) - string = string.trim(); - - return string; - } - - public boolean isActive() { - return getStatus() == STARTED && pCppJSbxObject != 0; - } - - public void finalize() { - if(DEBUG) System.err.println("#### AppletExecutionContext finalized"); - } - - // sollte eigentlich im DocumentProxy sein, geht aber nicht - private native void xshowStatus(String status); - private native void xshowDocument(URL url, String aTarget); - - void printStatus(String status) { - if(pCppJSbxObject != 0) xshowStatus(status); - } - - void printDocument(URL url, String aTarget) { - if(pCppJSbxObject != 0) xshowDocument(url, aTarget); - } - - native public Object getJavaScriptJSObjectWindow(); -} diff --git a/sj2/stardiv/applet/Document.java b/sj2/stardiv/applet/Document.java deleted file mode 100644 index ac677f19d914..000000000000 --- a/sj2/stardiv/applet/Document.java +++ /dev/null @@ -1,166 +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: Document.java,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -package stardiv.applet; - -import java.awt.Image; - -// import java.applet.Applet; -// import java.applet.AppletContext; -// import java.applet.AudioClip; - - -import java.io.IOException; - -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Observer; -import java.util.Observable; - -import java.net.URL; - -import java.applet.Applet; -import java.applet.AppletContext; -import java.applet.AudioClip; - -import com.sun.star.lib.sandbox.ExecutionContext; -import com.sun.star.lib.sandbox.ResourceProxy; - -class Document implements LiveConnectable { - private Hashtable executionContexts = new Hashtable(); - private URL documentBase = null; - private java.awt.Toolkit toolkit; - - Document(URL url, java.awt.Toolkit toolkit) { - // Create the document base. - //For example, suppose an applet is contained within the document: - //http://java.sun.com/products/jdk/1.2/index.html - //The document base is: - //http://java.sun.com/products/jdk/1.2/ - - String s= url.toString(); - int index= s.lastIndexOf('/'); - if( index != -1) - { - s=s.substring(0, index + 1); - } - try{ - documentBase = new URL(s); - }catch(Exception e){ - } - this.toolkit = toolkit; - } - - void addExecutionContext(ExecutionContext executionContext, String name) { - executionContexts.put(name, executionContext); - } - - void removeExecutionContext(String name) { - executionContexts.remove(name); - } - - Enumeration getExecutionContexts() { - return executionContexts.elements(); - } - - URL getDocumentBase() { - return documentBase; - } - - ExecutionContext getExecutionContext(String name) { - return (ExecutionContext)executionContexts.get(name); - } - - Enumeration getExcutionContexts() { - return executionContexts.elements(); - } - - /** - * Get the javascript environment for this applet. - */ - /* - public native Object getJavaScriptJSObjectWindow(); - public native void appletResize( int width, int height ); - public native void showDocument( URL url, String aTarget ); - public native void showStatus( String status ); - */ - - public AudioClip getAudioClip(URL url) { - ResourceProxy resourceProxy = ResourceProxy.load(url, null); - AudioClip audioClip = resourceProxy.getAudioClip(); - - return audioClip; - } - - public Image getImage(URL url) { - ResourceProxy resourceProxy = ResourceProxy.load(url, null); - Image image = toolkit.createImage(resourceProxy.getImageProducer()); - - return image; - } - - AppletExecutionContext getAppletExecutionContext() { - AppletExecutionContext appletExecutionContext = null; - - for(Enumeration e = executionContexts.elements(); e.hasMoreElements();) { - Object object = e.nextElement(); - if(object instanceof AppletExecutionContext) { - appletExecutionContext = (AppletExecutionContext)object; - } - } - return appletExecutionContext; - } - - - void showDocument(URL url, String aTarget) { - AppletExecutionContext appletExecutionContext = getAppletExecutionContext(); - if(appletExecutionContext != null) appletExecutionContext.printDocument(url, aTarget); - } - - public void showDocument(URL url) { - showDocument(url, "_top"); - } - - void showStatus(String status) { - status = (status == null) ? "" : status; - - AppletExecutionContext appletExecutionContext = getAppletExecutionContext(); - if(appletExecutionContext != null) appletExecutionContext.printStatus(status); - } - - public Object getJavaScriptJSObjectWindow() { - Object object = null; - - AppletExecutionContext appletExecutionContext = getAppletExecutionContext(); - if(appletExecutionContext != null) - object = appletExecutionContext.getJavaScriptJSObjectWindow(); - - return object; - } -} diff --git a/sj2/stardiv/applet/DocumentProxy.java b/sj2/stardiv/applet/DocumentProxy.java deleted file mode 100644 index 8de93fa9c6f0..000000000000 --- a/sj2/stardiv/applet/DocumentProxy.java +++ /dev/null @@ -1,194 +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: DocumentProxy.java,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -package stardiv.applet; - -import java.awt.Toolkit; -import java.awt.Image; - -import java.applet.Applet; -import java.applet.AppletContext; -import java.applet.AudioClip; - -import java.io.IOException; - -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Observer; -import java.util.Observable; -import java.util.Iterator; -import java.io.InputStream; - -import java.net.URL; - -import com.sun.star.lib.sandbox.Cachable; -import com.sun.star.lib.sandbox.ExecutionContext; -import com.sun.star.lib.sandbox.WeakRef; -import com.sun.star.lib.sandbox.WeakTable; -import com.sun.star.lib.sandbox.ResourceProxy; - -public class DocumentProxy implements AppletContext, Cachable, Observer, LiveConnectable { - static private int instances; - - synchronized static public DocumentProxy getDocumentProxy(URL url, Toolkit toolkit) { - DocumentProxy documentProxy = (DocumentProxy)WeakTable.get("Document: " + url); - - if(documentProxy == null) { - documentProxy = new DocumentProxy(url, toolkit); - WeakTable.put("Document: " + url, documentProxy); - } - - return documentProxy; - } - - // AppletContext. This method is new since 1.4. We insert it so as to - // have the project buildable - public void setStream( String key,InputStream stream) - throws java.io.IOException { - } - // AppletContext. This method is new since 1.4. We insert it so as to - // have the project buildable - public InputStream getStream( String key) { - return null; - } - // AppletContext. This method is new since 1.4. We insert it so as to - // have the project buildable - public Iterator getStreamKeys() { - return null; - } - - - /* - ** interface cachable methods - */ - private Document document; - private WeakRef weakRef; - - public DocumentProxy() { - instances ++; - } - - public Object getHardObject() { - return document; - } - - public void setWeakRef(WeakRef weakRef) { - document = (Document)weakRef.getRef(); - - weakRef.incRefCnt(); - this.weakRef = weakRef; - } - - public void finalize() { - weakRef.decRefCnt(); - instances --; - } - - /* - ** DocumentProxy methods - */ - private Toolkit toolkit; - - private DocumentProxy(URL url, Toolkit toolkit) { - this(); - document = new Document(url, toolkit); - } - - void addExecutionContext(ExecutionContext executionContext, String name) { - document.addExecutionContext(executionContext, name); - } - - void removeExecutionContext(String name) { - document.removeExecutionContext(name); - } - - public URL getDocumentBase() { - return document.getDocumentBase(); - } - - /* - ** AppletContext interface methods - */ - public Applet getApplet(String name) { - return ((AppletExecutionContext)document.getExecutionContext(name)).getApplet(); - } - - public Enumeration getApplets() { - return new Enumeration() { - Enumeration contexts = document.getExecutionContexts(); - - public boolean hasMoreElements() { - return contexts.hasMoreElements(); - } - - public Object nextElement() { - return ((AppletExecutionContext)contexts.nextElement()).getApplet(); - } - }; - } - - public AudioClip getAudioClip(URL url) { - return document.getAudioClip(url); - } - - public Image getImage(URL url) { - return document.getImage(url); - } - - public void showDocument(URL url) { - document.showDocument(url); - } - - /** - * Get the javascript environment for this applet. - */ - /* - public native Object getJavaScriptJSObjectWindow(); - public native void appletResize( int width, int height ); - public native void showDocument( URL url, String aTarget ); - public native void showStatus( String status ); - */ - - public void showDocument(URL url, String aTarget) { - document.showDocument(url, aTarget); - } - - public void showStatus(String status) { - document.showStatus(status); - } - - public void update(Observable observable, Object object) { - showStatus((String)object); - } - - public Object getJavaScriptJSObjectWindow() { - return document.getJavaScriptJSObjectWindow(); - } -} - diff --git a/sj2/stardiv/applet/makefile.mk b/sj2/stardiv/applet/makefile.mk deleted file mode 100644 index 3096d15eceba..000000000000 --- a/sj2/stardiv/applet/makefile.mk +++ /dev/null @@ -1,78 +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: makefile.mk,v $ -# -# $Revision: 1.4 $ -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PRJNAME=sj2 -TARGET=applet - -PACKAGE=stardiv$/applet - -.INCLUDE : $(PRJ)$/util$/makefile.pmk - -.IF "$(JDK)" == "gcj" -all: - @echo This dir cannot be build with gcj because of com.sun.star.lib.sandbox.ResourceProxy -.ELSE - -# --- Files -------------------------------------------------------- - -JARFILES= \ - sandbox.jar - -JAVAFILES=\ - AppletExecutionContext.java \ - Document.java \ - DocumentProxy.java \ - LiveConnectable.java - -#.IF "$(GUI)"=="WNT" -#JAVAFILES += WNativeAppletViewerFrame.java -#.ENDIF - -JAVACLASSFILES= \ - $(CLASSDIR)$/$(PACKAGE)$/DocumentProxy.class \ - $(CLASSDIR)$/$(PACKAGE)$/Document.class \ - $(CLASSDIR)$/$(PACKAGE)$/LiveConnectable.class \ - $(CLASSDIR)$/$(PACKAGE)$/AppletExecutionContext.class - -.ENDIF - -#.IF "$(GUI)"=="WNT" -#JAVACLASSFILES += $(CLASSDIR)$/stardiv$/applet$/WNativeAppletViewerFrame.class -#.ENDIF - - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - -.INCLUDE : $(PRJ)$/util$/target.pmk diff --git a/sj2/stardiv/applet/resources/MsgAppletViewer.java b/sj2/stardiv/applet/resources/MsgAppletViewer.java deleted file mode 100644 index e50dd2463482..000000000000 --- a/sj2/stardiv/applet/resources/MsgAppletViewer.java +++ /dev/null @@ -1,135 +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: MsgAppletViewer.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -package stardiv.applet.resources; - -import java.util.ListResourceBundle; - -public class MsgAppletViewer extends ListResourceBundle { - - public Object[][] getContents() { - return contents; - } - - static final Object[][] contents = { - {"textframe.button.dismiss", "Dismiss"}, - {"appletviewer.tool.title", "Applet Viewer: {0}"}, - {"appletviewer.menu.applet", "Applet"}, - {"appletviewer.menuitem.restart", "Restart"}, - {"appletviewer.menuitem.reload", "Reload"}, - {"appletviewer.menuitem.stop", "Stop"}, - {"appletviewer.menuitem.save", "Save..."}, - {"appletviewer.menuitem.start", "Start"}, - {"appletviewer.menuitem.clone", "Clone..."}, - {"appletviewer.menuitem.tag", "Tag..."}, - {"appletviewer.menuitem.info", "Info..."}, - {"appletviewer.menuitem.edit", "Edit"}, - {"appletviewer.menuitem.encoding", "Character Encoding"}, - {"appletviewer.menuitem.print", "Print..."}, - {"appletviewer.menuitem.props", "Properties..."}, - {"appletviewer.menuitem.close", "Close"}, - {"appletviewer.menuitem.quit", "Quit"}, - {"appletviewer.label.hello", "Hello..."}, - {"appletviewer.status.start", "starting applet..."}, - {"appletviewer.appletsave.err1", "serializing an {0} to {1}"}, - {"appletviewer.appletsave.err2", "in appletSave: {0}"}, - {"appletviewer.applettag", "Tag shown"}, - {"appletviewer.applettag.textframe", "Applet HTML Tag"}, - {"appletviewer.appletinfo.applet", "-- no applet info --"}, - {"appletviewer.appletinfo.param", "-- no parameter info --"}, - {"appletviewer.appletinfo.textframe", "Applet Info"}, - {"appletviewer.appletprint.printjob", "Print Applet"}, - {"appletviewer.appletprint.fail", "Printing failed."}, - {"appletviewer.appletprint.finish", "Finished printing."}, - {"appletviewer.appletprint.cancel", "Printing cancelled."}, - {"appletviewer.appletencoding", "Character Encoding: {0}"}, - {"appletviewer.init.err", "[no appletviewer.properties file found!]"}, - {"appletviewer.parse.warning.requiresname", "Warning: <param name=... value=...> tag requires name attribute."}, - {"appletviewer.parse.warning.paramoutside", "Warning: <param> tag outside <applet> ... </applet>."}, - {"appletviewer.parse.warning.requirescode", "Warning: <applet> tag requires code attribute."}, - {"appletviewer.parse.warning.requiresheight", "Warning: <applet> tag requires height attribute."}, - {"appletviewer.parse.warning.requireswidth", "Warning: <applet> tag requires width attribute."}, - {"appletviewer.parse.warning.appnotLongersupported", "Warning: <app> tag no longer supported, use <applet> instead:"}, - {"appletviewer.usage", "usage: appletviewer [-debug] [-J<javaflag>] [-encoding <character encoding type> ] url|file ..."}, - {"appletviewer.main.err.inputfile", "No input files specified."}, - {"appletviewer.main.err.badurl", "Bad URL: {0} ( {1} )"}, - {"appletviewer.main.err.io", "I/O exception while reading: {0}"}, - {"appletviewer.main.err.readablefile", "Make sure that {0} is a file and is readable."}, - {"appletviewer.main.err.correcturl", "Is {0} the correct URL?"}, - {"appletviewer.main.warning", "Warning: No Applets were started. Make sure the input contains an <applet> tag."}, - {"appletpanel.runloader.err", "Either object or code parameter!"}, - {"appletpanel.runloader.exception", "exception while deserializing {0}"}, - {"appletpanel.destroyed", "Applet destroyed."}, - {"appletpanel.loaded", "Applet loaded."}, - {"appletpanel.started", "Applet started."}, - {"appletpanel.inited", "Applet initialized."}, - {"appletpanel.stopped", "Applet stopped."}, - {"appletpanel.disposed", "Applet disposed."}, - {"appletpanel.nocode", "APPLET tag missing CODE parameter."}, - {"appletpanel.notfound", "load: class {0} not found."}, - {"appletpanel.nocreate", "load: {0} can''t be instantiated."}, - {"appletpanel.noconstruct", "load: {0} is not public or has no public constructor."}, - {"appletpanel.death", "killed"}, - {"appletpanel.exception", "exception: {0}."}, - {"appletpanel.exception2", "exception: {0}: {1}."}, - {"appletpanel.error", "error: {0}."}, - {"appletpanel.error2", "error: {0}: {1}."}, - {"appletpanel.notloaded", "Init: applet not loaded."}, - {"appletpanel.notinited", "Start: applet not initialized."}, - {"appletpanel.notstarted", "Stop: applet not started."}, - {"appletpanel.notstopped", "Destroy: applet not stopped."}, - {"appletpanel.notdestroyed", "Dispose: applet not destroyed."}, - {"appletpanel.notdisposed", "Load: applet not disposed."}, - {"appletpanel.bail", "Interrupted: bailing out."}, - {"appletpanel.filenotfound", "File not found when looking for: {0}"}, - {"appletpanel.fileformat", "File format exception when loading: {0}"}, - {"appletpanel.fileioexception", "I/O exception when loading: {0}"}, - {"appletpanel.fileexception", "{0} exception when loading: {1}"}, - {"appletpanel.filedeath", "{0} killed when loading: {1}"}, - {"appletpanel.fileerror", "{0} error when loading: {1}"}, - {"appletillegalargumentexception.objectinputstream", "AppletObjectInputStream requires non-null loader"}, - {"appletprops.title", "AppletViewer Properties"}, - {"appletprops.label.http.server", "Http proxy server:"}, - {"appletprops.label.http.proxy", "Http proxy port:"}, - {"appletprops.label.network", "Network access:"}, - {"appletprops.choice.network.item.none", "None"}, - {"appletprops.choice.network.item.applethost", "Applet Host"}, - {"appletprops.choice.network.item.unrestricted", "Unrestricted"}, - {"appletprops.label.class", "Class access:"}, - {"appletprops.choice.class.item.restricted", "Restricted"}, - {"appletprops.choice.class.item.unrestricted", "Unrestricted"}, - {"appletprops.label.unsignedapplet", "Allow unsigned applets:"}, - {"appletprops.choice.unsignedapplet.no", "No"}, - {"appletprops.choice.unsignedapplet.yes", "Yes"}, - {"appletprops.button.apply", "Apply"}, - {"appletprops.button.cancel", "Cancel"}, - {"appletprops.button.reset", "Reset"}, - {"appletprops.apply.exception", "Failed to save properties: {0}"}, - }; -} diff --git a/sj2/stardiv/applet/resources/makefile.mk b/sj2/stardiv/applet/resources/makefile.mk deleted file mode 100644 index af89ef8a807d..000000000000 --- a/sj2/stardiv/applet/resources/makefile.mk +++ /dev/null @@ -1,54 +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: makefile.mk,v $ -# -# $Revision: 1.3 $ -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/..$/.. - -PRJNAME=sj2 -TARGET=applet_resource - -PACKAGE=stardiv$/applet$/resources - -.INCLUDE : $(PRJ)$/util$/makefile.pmk - -# --- Files -------------------------------------------------------- - -JAVAFILES=\ - MsgAppletViewer.java - -JAVACLASSFILES=\ - $(CLASSDIR)$/$(PACKAGE)$/MsgAppletViewer.class - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - -.INCLUDE : $(PRJ)$/util$/target.pmk - diff --git a/sj2/stardiv/controller/SjSettings.java b/sj2/stardiv/controller/SjSettings.java deleted file mode 100644 index 1dd00613c144..000000000000 --- a/sj2/stardiv/controller/SjSettings.java +++ /dev/null @@ -1,179 +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: SjSettings.java,v $ - * $Revision: 1.8 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package stardiv.controller; - -import java.util.Properties; -import java.util.Hashtable; -import java.util.Enumeration; - -import com.sun.star.lib.sandbox.SandboxSecurity; - -/** - * Ueber diese Klasse werden alle globalen Einstellungen, die fuer das Sj Projekt - * wichtig sind, dokumentiert und modifiziert. - * - * @version $Version: 1.0 $ - * @author Markus Meyer - * - */ -public class SjSettings { - /** - * The following properties are used to setup the environment for - * the stardiv packages.<BR> - * "appletviewer.security.mode"="unrestricted" | "host" | "none": Set the - * security level of the default SecurityManager. The default is "host".<BR> - * "stardiv.security.defaultSecurityManager"="true" | "false": Create and set - * the stardiv.security.AppletSecurity, if the property is "true". This occures - * only in the first call.<BR> - * "stardiv.security.noExit"="true" | "false": no exit is allowed. Use this property - * if you are running more than one java application in the virtual machine. This occures - * only in the first call.<BR> - * "stardiv.security.disableSecurity"="true" | "false": disable security checking. Only usefull - * if a SecurityManager is installed. The default is "false".<BR> - * if you are running more than one java application in the virtual machine. This occures - * only in the first call.<BR> - * "stardiv.js.debugOnError"="true" | "false": Start the javascript ide, if an error - * occures. The default is "false".<BR> - * "stardiv.js.debugImmediate"="true" | "false": Start the javascript ide, if a script - * starts. The default is "false".<BR> - * "stardiv.debug.trace"="messageBox" | "window" | "file" | "none": The trace pipe is - * set to one of the four mediums. The Default is "none".<BR> - * "stardiv.debug.error"="messageBox" | "window" | "file" | "none": The error pipe is - * set to one of the four mediums. The Default is "none".<BR> - * "stardiv.debug.warning"="messageBox" | "window" | "file" | "none": The warning pipe is - * set to one of the four mediums. The Default is "none".<BR> - * If the properties http.proxyHost, http.proxyPort, http.maxConnections, - * http.keepAlive or http.nonProxyHosts are changed, the method - * sun.net.www.http.HttpClient.resetProperties() is called.<BR> - * If the properties ftpProxySet, ftpProxyHost or ftpProxyPort are changed, - * the static variables useFtpProxy, ftpProxyHost and ftpProxyPort in the class - * sun.net.ftp.FtpClient are set.<BR> - * <B>If you are writing your own SecurityManager and ClassLoader, please implement the - * interfaces stardiv.security.ClassLoaderExtension and - * stardiv.security.SecurityManagerExtension. Be shure to set the - * stardiv.security.ClassLoaderFactory, to enable dynamic class loading, otherwise - * the stardiv.security.AppletClassLoader is used. Set the factory with - * SjSettings.setClassLoaderFactory().</B> - */ - static public synchronized void changeProperties( Properties pChangeProps ) - { - SecurityManager pSM = System.getSecurityManager(); - if( pSM != null ) - pSM.checkPropertiesAccess(); - Properties props = new Properties( System.getProperties() ); - boolean bInited = Boolean.getBoolean( "stardiv.controller.SjSettings.inited" ); - - - if( !bInited ) - { - // check the awt.toolkit property: if none is set use com.sun.star.comp.jawt.peer.Toolkit - //if ( props.getProperty("awt.toolkit") == null ) - // props.put("awt.toolkit", "com.sun.star.comp.jawt.peer.Toolkit"); - - // Define a number of standard properties - props.put("acl.read", "+"); - props.put("acl.read.default", ""); - props.put("acl.write", "+"); - props.put("acl.write.default", ""); - - // Standard browser properties - props.put("browser", "stardiv.applet.AppletViewerFrame"); - props.put("browser.version", "4.02"); - props.put("browser.vendor", "Sun Microsystems, Inc."); - props.put("http.agent", "JDK/1.1"); - - // Define which packages can be accessed by applets - props.put("package.restrict.access.sun", "true"); - props.put("package.restrict.access.netscape", "true"); - props.put("package.restrict.access.stardiv", "true"); - - // Define which packages can be extended by applets - props.put("package.restrict.definition.java", "true"); - props.put("package.restrict.definition.sun", "true"); - props.put("package.restrict.definition.netscape", "true"); - props.put("package.restrict.definition.stardiv", "true"); - - // Define which properties can be read by applets. - // A property named by "key" can be read only when its twin - // property "key.applet" is true. The following ten properties - // are open by default. Any other property can be explicitly - // opened up by the browser user setting key.applet=true in - // ~/.hotjava/properties. Or vice versa, any of the following can - // be overridden by the user's properties. - props.put("java.version.applet", "true"); - props.put("java.vendor.applet", "true"); - props.put("java.vendor.url.applet", "true"); - props.put("java.class.version.applet", "true"); - props.put("os.name.applet", "true"); - props.put("os.version.applet", "true"); - props.put("os.arch.applet", "true"); - props.put("file.separator.applet", "true"); - props.put("path.separator.applet", "true"); - props.put("line.separator.applet", "true"); - - } - - // put new and changed properties to the property table - if( pChangeProps != null ) - { - Enumeration aEnum = pChangeProps.propertyNames(); - while( aEnum.hasMoreElements() ) - { - String aKey = (String)aEnum.nextElement(); - props.put( aKey, pChangeProps.getProperty( aKey ) ); - } - } - - // Install a property list. - if( !bInited ) - props.put( "stardiv.controller.SjSettings.inited", "true" ); - System.setProperties(props); - if( !bInited ) - { - // Security Manager setzten - boolean bNoExit = Boolean.getBoolean( "stardiv.security.noExit" ); - //Create and install the security manager - if (System.getSecurityManager() == null) - System.setSecurityManager(new SandboxSecurity(bNoExit)); - -// if( Boolean.getBoolean("stardiv.controller.installConsole") ) -// Console.installConsole(); - } - } - - private static boolean equalsImpl( Object p1, Object p2 ) - { - return p1 == p2 || (p1 != null && p2 != null && p1.equals( p2 ) ); - } -} - - - diff --git a/sj2/stardiv/controller/makefile.mk b/sj2/stardiv/controller/makefile.mk deleted file mode 100644 index 8776f7f7fdac..000000000000 --- a/sj2/stardiv/controller/makefile.mk +++ /dev/null @@ -1,58 +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: makefile.mk,v $ -# -# $Revision: 1.6 $ -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PRJNAME=sj2 -TARGET=controller - -PACKAGE=stardiv$/controller -JARFILES=sandbox.jar tkt.jar - -.INCLUDE : $(PRJ)$/util$/makefile.pmk - -.IF "$(JDK)" == "gcj" -all: - @echo This dir cannot be build with gcj because of com.sun.star.lib.sandbox.ResourceProxy -.ELSE - -# --- Files -------------------------------------------------------- - -JAVACLASSFILES= \ - $(CLASSDIR)$/$(PACKAGE)$/SjSettings.class - -# --- Targets ------------------------------------------------------ -.ENDIF - -.INCLUDE : target.mk - -.INCLUDE : $(PRJ)$/util$/target.pmk - diff --git a/sj2/stardiv/security/resources/MsgAppletViewer.java b/sj2/stardiv/security/resources/MsgAppletViewer.java deleted file mode 100644 index a2f567878c3e..000000000000 --- a/sj2/stardiv/security/resources/MsgAppletViewer.java +++ /dev/null @@ -1,91 +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: MsgAppletViewer.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -package stardiv.security.resources; - -import java.util.ListResourceBundle; - -/* Alle Resourcen aus AppletClassLoader, Applet und AppletSecurityException. -*/ -public class MsgAppletViewer extends ListResourceBundle { - - public Object[][] getContents() { - return contents; - } - - static final Object[][] contents = { - {"appletclassloader.loadcode.verbose", "Opening stream to: {0} to get {1}"}, - {"appletclassloader.filenotfound", "File not found when looking for: {0}"}, - {"appletclassloader.fileformat", "File format exception when loading: {0}"}, - {"appletclassloader.fileioexception", "I/O exception when loading: {0}"}, - {"appletclassloader.fileexception", "{0} exception when loading: {1}"}, - {"appletclassloader.filedeath", "{0} killed when loading: {1}"}, - {"appletclassloader.fileerror", "{0} error when loading: {1}"}, - {"appletclassloader.findclass.verbose.findclass", "{0} find class {1}"}, - {"appletclassloader.findclass.verbose.openstream", "Opening stream to: {0} to get {1}"}, - {"appletclassloader.getresource.verbose.forname", "AppletClassLoader.getResource for name: {0}"}, - {"appletclassloader.getresource.verbose.found", "Found resource: {0} as a system resource"}, - {"appletclassloader.getresourceasstream.verbose", "Found resource: {0} as a system resource"}, - {"appletioexception.loadclass.throw.interrupted", "class loading interrupted: {0}"}, - {"appletioexception.loadclass.throw.notloaded", "class not loaded: {0}"}, - {"appletsecurityexception.checkcreateclassloader", "Security Exception: classloader"}, - {"appletsecurityexception.checkaccess.thread", "Security Exception: thread"}, - {"appletsecurityexception.checkaccess.threadgroup", "Security Exception: threadgroup: {0}"}, - {"appletsecurityexception.checkexit", "Security Exception: exit: {0}"}, - {"appletsecurityexception.checkexec", "Security Exception: exec: {0}"}, - {"appletsecurityexception.checklink", "Security Exception: link: {0}"}, - {"appletsecurityexception.checkpropsaccess", "Security Exception: properties"}, - {"appletsecurityexception.checkpropsaccess.key", "Security Exception: properties access {0}"}, - {"appletsecurityexception.checkread.exception1", "Security Exception: {0}, {1}"}, - {"appletsecurityexception.checkread.exception2", "Security Exception: file.read: {0}"}, - {"appletsecurityexception.checkread", "Security Exception: file.read: {0} == {1}"}, - {"appletsecurityexception.checkwrite.exception", "Security Exception: {0}, {1}"}, - {"appletsecurityexception.checkwrite", "Security Exception: file.write: {0} == {1}"}, - {"appletsecurityexception.checkread.fd", "Security Exception: fd.read"}, - {"appletsecurityexception.checkwrite.fd", "Security Exception: fd.write"}, - {"appletsecurityexception.checklisten", "Security Exception: socket.listen: {0}"}, - {"appletsecurityexception.checkaccept", "Security Exception: socket.accept: {0}:{1}"}, - {"appletsecurityexception.checkconnect.networknone", "Security Exception: socket.connect: {0}->{1}"}, - {"appletsecurityexception.checkconnect.networkhost1", "Security Exception: Couldn''t connect to {0} with origin from {1}."}, - {"appletsecurityexception.checkconnect.networkhost2", "Security Exception: Couldn''t resolve IP for host {0} or for {1}. "}, - {"appletsecurityexception.checkconnect.networkhost3", "Security Exception: Could not resolve IP for host {0}. See the trustProxy property."}, - {"appletsecurityexception.checkconnect", "Security Exception: connect: {0}->{1}"}, - {"appletsecurityexception.checkpackageaccess", "Security Exception: cannot access package: {0}"}, - {"appletsecurityexception.checkpackagedefinition", "Security Exception: cannot define package: {0}"}, - {"appletsecurityexception.cannotsetfactory", "Security Exception: cannot set factory"}, - {"appletsecurityexception.checkmemberaccess", "Security Exception: check member access"}, - {"appletsecurityexception.checkgetprintjob", "Security Exception: getPrintJob"}, - {"appletsecurityexception.checksystemclipboardaccess", "Security Exception: getSystemClipboard"}, - {"appletsecurityexception.checkawteventqueueaccess", "Security Exception: getEventQueue"}, - {"appletsecurityexception.checksecurityaccess", "Security Exception: security operation: {0}"}, - {"appletsecurityexception.getsecuritycontext.unknown", "unknown class loader type. unable to check for getContext"}, - {"appletsecurityexception.checkread.unknown", "unknown class loader type. unable to check for checking read {0}"}, - {"appletsecurityexception.checkconnect.unknown", "unknown class loader type. unable to check for checking connect"}, - }; -} diff --git a/sj2/stardiv/security/resources/makefile.mk b/sj2/stardiv/security/resources/makefile.mk deleted file mode 100644 index f57edbbc4ac9..000000000000 --- a/sj2/stardiv/security/resources/makefile.mk +++ /dev/null @@ -1,54 +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: makefile.mk,v $ -# -# $Revision: 1.3 $ -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/..$/.. - -PRJNAME=sj2 -TARGET=security_resource - -PACKAGE=stardiv$/security$/resources - -.INCLUDE : $(PRJ)$/util$/makefile.pmk - -# --- Files -------------------------------------------------------- - -JAVAFILES=\ - MsgAppletViewer.java - -JAVACLASSFILES=\ - $(CLASSDIR)$/stardiv$/security$/resources$/MsgAppletViewer.class - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - -.INCLUDE : $(PRJ)$/util$/target.pmk - diff --git a/sj2/util/makefile.pmk b/sj2/util/makefile.pmk deleted file mode 100644 index 6976b55b38c7..000000000000 --- a/sj2/util/makefile.pmk +++ /dev/null @@ -1,46 +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: makefile.pmk,v $ -# -# $Revision: 1.5 $ -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -JAVAPREPRO= -.IF "$(JDK_VERSION)" == "110" -JAVAPREPRO=-jdk11 -.ENDIF -.IF "$(PRODUCT)" != "" -JAVAPREPRO=$(JAVAPREPRO) + " -product" -.ENDIF - -ENABLE_EXCEPTIONS=TRUE - -JARFILES=sandbox.jar tkt.jar - -# --- Settings ----------------------------------------------------- -.INCLUDE : settings.mk - diff --git a/sj2/util/target.pmk b/sj2/util/target.pmk deleted file mode 100644 index 56da2446993c..000000000000 --- a/sj2/util/target.pmk +++ /dev/null @@ -1,42 +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: target.pmk,v $ -# -# $Revision: 1.3 $ -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* -.IF "$(depend)" == "" -ONLYZIP: $(SLOFILES) - cd $(PRJ)$/util - nmake debug=t - -TEST: - -DOC: - -PREPRO: - $(JAVAI) $(JAVACPS) $(CLASSPATH) stardiv.app.Javac $(JAVAPREPRO) $(JAVAFILES) -.ENDIF diff --git a/svx/inc/optgenrl.hrc b/svx/inc/optgenrl.hrc index b6f191aaea07..4c519d5ebb70 100644 --- a/svx/inc/optgenrl.hrc +++ b/svx/inc/optgenrl.hrc @@ -63,6 +63,7 @@ #define ED_EMAIL 38 #define GB_ADDRESS 39 #define CB_USEDATA 40 +#define FT_NAME_EASTERN 41 #define STR_US_STATE 10 #define STR_QUERY_REG 11 diff --git a/svx/inc/svx/dialogs.hrc b/svx/inc/svx/dialogs.hrc index 1d78c5e6396e..6e6162ef61f2 100644 --- a/svx/inc/svx/dialogs.hrc +++ b/svx/inc/svx/dialogs.hrc @@ -600,6 +600,7 @@ #define RID_SVXSTR_XMLSEC_SIG_OK_NO_VERIFY (RID_SVX_START + 223) #define RID_SVXSTR_XMLSEC_SIG_NOT_OK (RID_SVX_START + 224) #define RID_SVXSTR_XMLSEC_NO_SIG (RID_SVX_START + 225) +#define RID_SVXSTR_XMLSEC_SIG_CERT_OK_PARTIAL_SIG (RID_SVX_START + 226) // Strings von der Hatch-Tabpage #define RID_SVXSTR_WRITE_DATA_ERROR (RID_SVX_START + 229) @@ -1238,7 +1239,7 @@ #define RID_SVXSTR_MENU_ADDCOMMANDS_DESCRIPTION (RID_SVX_START + 1050) #define RID_SVXSTR_EVENT_STARTAPP (RID_SVX_START + 1051) #define RID_SVXSTR_EVENT_CLOSEAPP (RID_SVX_START + 1052) -#define RID_SVXSTR_EVENT_CREATEDOC (RID_SVX_START + 1053) +#define RID_SVXSTR_EVENT_NEWDOC (RID_SVX_START + 1053) #define RID_SVXSTR_EVENT_CLOSEDOC (RID_SVX_START + 1054) #define RID_SVXSTR_EVENT_PREPARECLOSEDOC (RID_SVX_START + 1055) #define RID_SVXSTR_EVENT_OPENDOC (RID_SVX_START + 1056) @@ -1369,9 +1370,28 @@ #define STR_LINKEDDOC_NO_SYSTEM_FILE (RID_SVX_START + 1169) #define RID_SVXSTR_EVENT_SUBCOMPONENT_OPENED (RID_SVX_START + 1170) #define RID_SVXSTR_EVENT_SUBCOMPONENT_CLOSED (RID_SVX_START + 1171) + +#define RID_SVXSTR_EVENT_CREATEDOC (RID_SVX_START + 1172) +#define RID_SVXSTR_EVENT_LOADDOCFINISHED (RID_SVX_START + 1173) +#define RID_SVXSTR_EVENT_SAVEDOCFAILED (RID_SVX_START + 1174) +#define RID_SVXSTR_EVENT_SAVEASDOCFAILED (RID_SVX_START + 1175) +#define RID_SVXSTR_EVENT_COPYTODOC (RID_SVX_START + 1176) +#define RID_SVXSTR_EVENT_COPYTODOCDONE (RID_SVX_START + 1177) +#define RID_SVXSTR_EVENT_COPYTODOCFAILED (RID_SVX_START + 1178) +#define RID_SVXSTR_EVENT_VIEWCREATED (RID_SVX_START + 1179) +#define RID_SVXSTR_EVENT_PREPARECLOSEVIEW (RID_SVX_START + 1180) +#define RID_SVXSTR_EVENT_CLOSEVIEW (RID_SVX_START + 1181) +#define RID_SVXSTR_EVENT_TITLECHANGED (RID_SVX_START + 1182) +#define RID_SVXSTR_EVENT_MODECHANGED (RID_SVX_START + 1183) +#define RID_SVXSTR_EVENT_VISAREACHANGED (RID_SVX_START + 1184) +#define RID_SVXSTR_EVENT_STORAGECHANGED (RID_SVX_START + 1185) +#define RID_SVXSTR_EVENT_MAILMERGE_END (RID_SVX_START + 1186) +#define RID_SVXSTR_EVENT_FIELDMERGE (RID_SVX_START + 1187) +#define RID_SVXSTR_EVENT_FIELDMERGE_FINISHED (RID_SVX_START + 1188) +#define RID_SVXSTR_EVENT_LAYOUT_FINISHED (RID_SVX_START + 1189) // if you add here, remember to adjust RID_SVXSTR_NEXTFREE -#define RID_SVXSTR_NEXTFREE (RID_SVX_START + 1172) +#define RID_SVXSTR_NEXTFREE (RID_SVX_START + 1190) // ---------------------------------------------------------------------------- // if we have _a_lot_ time, we should group the resource ids by type, instead diff --git a/svx/inc/svx/langbox.hxx b/svx/inc/svx/langbox.hxx index 8aebc88e380e..476d78c53d03 100644 --- a/svx/inc/svx/langbox.hxx +++ b/svx/inc/svx/langbox.hxx @@ -78,6 +78,7 @@ private: SVX_DLLPRIVATE void Init(); SVX_DLLPRIVATE USHORT ImplInsertImgEntry( const String& rEntry, USHORT nPos, bool bChecked ); + SVX_DLLPRIVATE USHORT ImplInsertLanguage(LanguageType, USHORT, sal_Int16 ); public: SvxLanguageBox( Window* pParent, WinBits nWinStyle, BOOL bCheck = FALSE); @@ -89,6 +90,7 @@ public: BOOL bCheckSpellAvail = FALSE ); USHORT InsertLanguage( const LanguageType eLangType, USHORT nPos = LISTBOX_APPEND ); + USHORT InsertDefaultLanguage( sal_Int16 nType, USHORT nPos = LISTBOX_APPEND ); USHORT InsertLanguage( const LanguageType eLangType, BOOL bCheckEntry, USHORT nPos = LISTBOX_APPEND ); void RemoveLanguage( const LanguageType eLangType ); diff --git a/svx/inc/svx/numfmtsh.hxx b/svx/inc/svx/numfmtsh.hxx index 8e2eb238d3bd..5e6fe3737f94 100644 --- a/svx/inc/svx/numfmtsh.hxx +++ b/svx/inc/svx/numfmtsh.hxx @@ -212,8 +212,8 @@ public: short GetListPos4Entry(sal_uInt32 nIdx); short GetListPos4Entry( const String& rFmtString ); - void GetCurrencySymbols(SvStringsDtor& rList,const XubString& rStrEurope,USHORT* pPos); - void GetCurrencySymbols(SvStringsDtor& rList,const XubString& rStrEurope, BOOL bFlag); + void GetCurrencySymbols( SvStringsDtor& rList, USHORT* pPos ); + void GetCurrencySymbols( SvStringsDtor& rList, BOOL bFlag ); USHORT FindCurrencyTableEntry( const String& rFmtString, BOOL &bTestBanking ); BOOL IsInTable(USHORT nPos,BOOL bTmpBanking,const String &rFmtString); diff --git a/svx/inc/svx/sdr/attribute/sdrtextattribute.hxx b/svx/inc/svx/sdr/attribute/sdrtextattribute.hxx index e0dcb51e9460..1759eb18d319 100644 --- a/svx/inc/svx/sdr/attribute/sdrtextattribute.hxx +++ b/svx/inc/svx/sdr/attribute/sdrtextattribute.hxx @@ -35,6 +35,7 @@ #include <sal/types.h> #include <svx/xenum.hxx> #include <svx/outlobj.hxx> +#include <svx/sdtaitm.hxx> ////////////////////////////////////////////////////////////////////////////// // predefines @@ -68,6 +69,10 @@ namespace drawinglayer // #i101556# use versioning from text attributes to detect changes sal_uInt32 maPropertiesVersion; + // text alignments + SdrTextHorzAdjust maSdrTextHorzAdjust; + SdrTextVertAdjust maSdrTextVertAdjust; + // bitfield unsigned mbContour : 1; unsigned mbFitToSize : 1; @@ -75,6 +80,7 @@ namespace drawinglayer unsigned mbBlink : 1; unsigned mbScroll : 1; unsigned mbInEditMode : 1; + unsigned mbFixedCellHeight : 1; public: SdrTextAttribute( @@ -85,12 +91,15 @@ namespace drawinglayer sal_Int32 aTextUpperDistance, sal_Int32 aTextRightDistance, sal_Int32 aTextLowerDistance, + SdrTextHorzAdjust aSdrTextHorzAdjust, + SdrTextVertAdjust aSdrTextVertAdjust, bool bContour, bool bFitToSize, bool bHideContour, bool bBlink, bool bScroll, - bool bInEditMode); + bool bInEditMode, + bool bFixedCellHeight); ~SdrTextAttribute(); // copy constructor and assigment operator @@ -109,12 +118,15 @@ namespace drawinglayer bool isBlink() const { return mbBlink; } bool isScroll() const { return mbScroll; } bool isInEditMode() const { return mbInEditMode; } + bool isFixedCellHeight() const { return mbFixedCellHeight; } const SdrFormTextAttribute* getSdrFormTextAttribute() const { return mpSdrFormTextAttribute; } sal_Int32 getTextLeftDistance() const { return maTextLeftDistance; } sal_Int32 getTextUpperDistance() const { return maTextUpperDistance; } sal_Int32 getTextRightDistance() const { return maTextRightDistance; } sal_Int32 getTextLowerDistance() const { return maTextLowerDistance; } sal_uInt32 getPropertiesVersion() const { return maPropertiesVersion; } + SdrTextHorzAdjust getSdrTextHorzAdjust() const { return maSdrTextHorzAdjust; } + SdrTextVertAdjust getSdrTextVertAdjust() const { return maSdrTextVertAdjust; } // animation timing generation void getBlinkTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList) const; diff --git a/svx/inc/svx/sdr/overlay/overlayanimatedbitmapex.hxx b/svx/inc/svx/sdr/overlay/overlayanimatedbitmapex.hxx index 9acc34c8dcc8..23a720467710 100644 --- a/svx/inc/svx/sdr/overlay/overlayanimatedbitmapex.hxx +++ b/svx/inc/svx/sdr/overlay/overlayanimatedbitmapex.hxx @@ -40,7 +40,7 @@ namespace sdr { namespace overlay { - class OverlayAnimatedBitmapEx : public OverlayObjectWithBasePosition + class SVX_DLLPUBLIC OverlayAnimatedBitmapEx : public OverlayObjectWithBasePosition { protected: // the Bitmaps diff --git a/svx/inc/svx/sdr/overlay/overlayselection.hxx b/svx/inc/svx/sdr/overlay/overlayselection.hxx index fe725a577eec..17f32ee419e9 100644 --- a/svx/inc/svx/sdr/overlay/overlayselection.hxx +++ b/svx/inc/svx/sdr/overlay/overlayselection.hxx @@ -78,7 +78,7 @@ namespace sdr virtual ~OverlaySelection(); // data read access - const OverlayType getOverlayType() const { return meOverlayType; } + OverlayType getOverlayType() const { return meOverlayType; } const std::vector< basegfx::B2DRange >& getRanges() const { return maRanges; } bool getBorder() const { return mbBorder; } diff --git a/svx/inc/svx/sdr/primitive2d/sdrtextprimitive2d.hxx b/svx/inc/svx/sdr/primitive2d/sdrtextprimitive2d.hxx index 6dd60b45d2d5..132a3ecc2538 100644 --- a/svx/inc/svx/sdr/primitive2d/sdrtextprimitive2d.hxx +++ b/svx/inc/svx/sdr/primitive2d/sdrtextprimitive2d.hxx @@ -40,6 +40,7 @@ #include <tools/color.hxx>
#include <svx/sdr/attribute/sdrformtextattribute.hxx> #include <tools/weakbase.hxx> +#include <svx/sdtaitm.hxx> ////////////////////////////////////////////////////////////////////////////// // predefines @@ -82,11 +83,6 @@ namespace drawinglayer Color maLastTextBackgroundColor; // bitfield - // remember if last decomposition was with or without spell checker. In this special - // case the get2DDecomposition implementation has to take care of this aspect. This is - // needed since different views do different text decompositons regarding spell checking. - unsigned mbLastSpellCheck : 1; - // is there a PageNumber, Header, Footer or DateTimeField used? Evaluated at construction unsigned mbContainsPageField : 1; unsigned mbContainsPageCountField : 1; @@ -96,9 +92,6 @@ namespace drawinglayer // support for XTEXT_PAINTSHAPE_BEGIN/XTEXT_PAINTSHAPE_END Metafile comments Primitive2DSequence encapsulateWithTextHierarchyBlockPrimitive2D(const Primitive2DSequence& rCandidate) const; - bool getLastSpellCheck() const { return (bool)mbLastSpellCheck; } - void setLastSpellCheck(bool bNew) { mbLastSpellCheck = bNew; } - public: SdrTextPrimitive2D( const SdrText* pSdrText, @@ -217,7 +210,12 @@ namespace drawinglayer // text range transformation from unit range ([0.0 .. 1.0]) to text range basegfx::B2DHomMatrix maTextRangeTransform; + // text alignments + SdrTextHorzAdjust maSdrTextHorzAdjust; + SdrTextVertAdjust maSdrTextVertAdjust; + // bitfield + unsigned mbFixedCellHeight : 1; unsigned mbUnlimitedPage : 1; // force layout with no text break unsigned mbCellText : 1; // this is a cell text as block text unsigned mbWordWrap : 1; // for CustomShapes text layout @@ -231,12 +229,18 @@ namespace drawinglayer const SdrText* pSdrText, const OutlinerParaObject& rOutlinerParaObjectPtr, const basegfx::B2DHomMatrix& rTextRangeTransform, + SdrTextHorzAdjust aSdrTextHorzAdjust, + SdrTextVertAdjust aSdrTextVertAdjust, + bool bFixedCellHeight, bool bUnlimitedPage, bool bCellText, bool bWordWrap); // get data const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; } + SdrTextHorzAdjust getSdrTextHorzAdjust() const { return maSdrTextHorzAdjust; } + SdrTextVertAdjust getSdrTextVertAdjust() const { return maSdrTextVertAdjust; } + bool isFixedCellHeight() const { return mbFixedCellHeight; } bool getUnlimitedPage() const { return mbUnlimitedPage; } bool getCellText() const { return mbCellText; } bool getWordWrap() const { return mbWordWrap; } @@ -265,6 +269,9 @@ namespace drawinglayer // text range transformation from unit range ([0.0 .. 1.0]) to text range basegfx::B2DHomMatrix maTextRangeTransform; + // bitfield + unsigned mbFixedCellHeight : 1; + protected: // local decomposition. virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; @@ -273,10 +280,12 @@ namespace drawinglayer SdrStretchTextPrimitive2D( const SdrText* pSdrText, const OutlinerParaObject& rOutlinerParaObjectPtr, - const basegfx::B2DHomMatrix& rTextRangeTransform); + const basegfx::B2DHomMatrix& rTextRangeTransform, + bool bFixedCellHeight); // get data const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; } + bool isFixedCellHeight() const { return mbFixedCellHeight; } // compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; diff --git a/svx/inc/svx/svdfppt.hxx b/svx/inc/svx/svdfppt.hxx index 5a73bea5052f..63f196876e93 100644 --- a/svx/inc/svx/svdfppt.hxx +++ b/svx/inc/svx/svdfppt.hxx @@ -1337,6 +1337,8 @@ class PPTConvertOCXControls : public SvxMSConvertOCXControls #define PPT_PST_NewlyAddedAtomByXP11008 11008 #define PPT_PST_NewlyAddedAtomByXP11010 11010 +#define PPT_PST_Comment10 12000 +#define PPT_PST_CommentAtom10 12001 #define PPT_PST_NewlyAddedAtomByXP12004 12004 #define PPT_PST_NewlyAddedAtomByXP12010 12010 #define PPT_PST_NewlyAddedAtomByXP12011 12011 diff --git a/svx/inc/svx/svdhdl.hxx b/svx/inc/svx/svdhdl.hxx index 11d400b85b8a..4960323feeb7 100644 --- a/svx/inc/svx/svdhdl.hxx +++ b/svx/inc/svx/svdhdl.hxx @@ -58,7 +58,6 @@ class SdrHdlList; class SdrMarkView; class SdrObject; class SdrPageView; -class SdrHdlBitmapSet; //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -155,12 +154,6 @@ class SVX_DLLPUBLIC SdrHdl friend class SdrMarkView; // fuer den Zugriff auf nObjHdlNum friend class SdrHdlList; - static SdrHdlBitmapSet* pSimpleSet; - static SdrHdlBitmapSet* pModernSet; - - // #101928# - static SdrHdlBitmapSet* pHighContrastSet; - // #101928# BitmapEx ImpGetBitmapEx(BitmapMarkerKind eKindOfMarker, sal_uInt16 nInd, sal_Bool bFine, sal_Bool bIsHighContrast); diff --git a/svx/inc/svx/svdotext.hxx b/svx/inc/svx/svdotext.hxx index 5298fc2dd79b..6ffa4ab5bd22 100644 --- a/svx/inc/svx/svdotext.hxx +++ b/svx/inc/svx/svdotext.hxx @@ -575,20 +575,19 @@ public: public: ////////////////////////////////////////////////////////////////////////////// // text primitive decomposition helpers - bool impCheckSpellCheckForDecomposeTextPrimitive() const; - bool impDecomposeContourTextPrimitive( + void impDecomposeContourTextPrimitive( drawinglayer::primitive2d::Primitive2DSequence& rTarget, const drawinglayer::primitive2d::SdrContourTextPrimitive2D& rSdrContourTextPrimitive, const drawinglayer::geometry::ViewInformation2D& aViewInformation) const; - bool impDecomposePathTextPrimitive( + void impDecomposePathTextPrimitive( drawinglayer::primitive2d::Primitive2DSequence& rTarget, const drawinglayer::primitive2d::SdrPathTextPrimitive2D& rSdrPathTextPrimitive, const drawinglayer::geometry::ViewInformation2D& aViewInformation) const; - bool impDecomposeBlockTextPrimitive( + void impDecomposeBlockTextPrimitive( drawinglayer::primitive2d::Primitive2DSequence& rTarget, const drawinglayer::primitive2d::SdrBlockTextPrimitive2D& rSdrBlockTextPrimitive, const drawinglayer::geometry::ViewInformation2D& aViewInformation) const; - bool impDecomposeStretchTextPrimitive( + void impDecomposeStretchTextPrimitive( drawinglayer::primitive2d::Primitive2DSequence& rTarget, const drawinglayer::primitive2d::SdrStretchTextPrimitive2D& rSdrStretchTextPrimitive, const drawinglayer::geometry::ViewInformation2D& aViewInformation) const; diff --git a/svx/inc/svx/svxids.hrc b/svx/inc/svx/svxids.hrc index 6019c3590d55..a4b0d8736618 100644 --- a/svx/inc/svx/svxids.hrc +++ b/svx/inc/svx/svxids.hrc @@ -377,7 +377,6 @@ #define SID_FRAME_UP (SID_SC_START + 407) #define SID_FRAME_DOWN (SID_SC_START + 408) #define SID_ENTER_STRING (SID_SC_START + 476) -#define SID_INSERT_POSTIT (SID_SC_START + 276) #define SID_ATTR_SECIALCHAR (SID_SC_START + 581) #define SID_ATTR_SPECIALCHAR (SID_SC_START + 581) @@ -1178,7 +1177,6 @@ #define SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ( SID_SVX_START + 919 ) #define SID_ATTR_CHAR_RELIEF ( SID_SVX_START + 920 ) #define SID_LANGUAGE_OPTIONS ( SID_SVX_START + 921 ) -#define SID_CLIPBOARD_FORMAT_ITEMS ( SID_SVX_START + 922 ) #define SID_GETUNDOSTRINGS ( SID_SVX_START + 923 ) #define SID_GETREDOSTRINGS ( SID_SVX_START + 924 ) #define SID_PARA_VERTALIGN ( SID_SVX_START + 925 ) @@ -1351,9 +1349,19 @@ #define SID_CHAR_DLG_PREVIEW_STRING (SID_SVX_START+1090) #define SID_RECHECK_DOCUMENT (SID_SVX_START+1091) #define SID_ATTR_PARA_OUTLINE_LEVEL (SID_SVX_START+1092) +#define SID_OBJECT_MIRROR (SID_SVX_START+1093) + +#define SID_INSERT_POSTIT (SID_SVX_START+1093) +#define SID_DELETE_POSTIT (SID_SVX_START+1094) +#define SID_NEXT_POSTIT (SID_SVX_START+1095) +#define SID_PREVIOUS_POSTIT (SID_SVX_START+1096) +#define SID_DELETEALL_POSTIT (SID_SVX_START+1097) +#define SID_SHOW_POSTIT (SID_SVX_START+1098) +#define SID_REPLYTO_POSTIT (SID_SVX_START+1099) +#define SID_DELETEALLBYAUTHOR_POSTIT (SID_SVX_START+1100) // IMPORTANT NOTE: adjust SID_SVX_FIRSTFREE, when adding new slot id -#define SID_SVX_FIRSTFREE SID_ATTR_PARA_OUTLINE_LEVEL + 1 +#define SID_SVX_FIRSTFREE SID_DELETEALLBYAUTHOR_POSTIT + 1 // -------------------------------------------------------------------------- // Overflow check for slot IDs diff --git a/svx/sdi/makefile.mk b/svx/sdi/makefile.mk index 60f3cc3fb5c3..2ea64ddedbba 100644 --- a/svx/sdi/makefile.mk +++ b/svx/sdi/makefile.mk @@ -39,6 +39,8 @@ TARGET=svxslots .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" + SDI1NAME=$(TARGET) SDI1EXPORT=svx @@ -53,6 +55,6 @@ SVSDI1DEPEND= \ svxitems.sdi # --- Targets ------------------------------------------------------- - +.ENDIF .INCLUDE : target.mk diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index 3c819229ee4c..28f50ef89b5c 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -1974,34 +1974,6 @@ SfxVoidItem ClearOutline SID_OUTLINE_DELETEALL ] //-------------------------------------------------------------------------- -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; -] - -//-------------------------------------------------------------------------- SvxColorItem Color SID_ATTR_CHAR_COLOR [ @@ -3797,7 +3769,7 @@ SfxObjectItem FmFilterNavigatorController SID_FM_FILTER_NAVIGATOR_CONTROL [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -4806,7 +4778,7 @@ SfxStringListItem GetRedoStrings SID_GETREDOSTRINGS [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = TRUE, HasCoreId = FALSE, HasDialog = FALSE, @@ -4833,7 +4805,7 @@ SfxStringListItem GetUndoStrings SID_GETUNDOSTRINGS [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = TRUE, HasCoreId = FALSE, HasDialog = FALSE, @@ -5982,6 +5954,185 @@ SfxVoidItem InsertAnnotation SID_INSERT_POSTIT ] //-------------------------------------------------------------------------- +SfxBoolItem ShowAnnotation SID_SHOW_POSTIT +() +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_VIEW; +] + +//-------------------------------------------------------------------------- + +SfxVoidItem ReplyToAnnotation SID_REPLYTO_POSTIT +() +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = FALSE, + MenuConfig = FALSE, + StatusBarConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = GID_DOCUMENT; +] + +//-------------------------------------------------------------------------- + +SfxVoidItem DeleteAnnotation SID_DELETE_POSTIT +() +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_DOCUMENT; +] + +//-------------------------------------------------------------------------- + +SfxVoidItem DeleteAllAnnotation SID_DELETEALL_POSTIT +() +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_DOCUMENT; +] + +SfxVoidItem DeleteAllAnnotationByAuthor SID_DELETEALLBYAUTHOR_POSTIT +() +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = FALSE, + MenuConfig = FALSE, + StatusBarConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = GID_DOCUMENT; +] + +//-------------------------------------------------------------------------- + +SfxVoidItem NextAnnotation SID_NEXT_POSTIT +() +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_VIEW; +] + +//-------------------------------------------------------------------------- + +SfxVoidItem PreviousAnnotation SID_PREVIOUS_POSTIT +() +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_VIEW; +] + +//-------------------------------------------------------------------------- SfxVoidItem InsertApplet SID_INSERT_APPLET (SfxStringItem Class FN_PARAM_1, SfxStringItem ClassLocation FN_PARAM_2, @@ -7493,7 +7644,7 @@ SfxVoidItem OutlineBullet SID_OUTLINE_BULLET [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = TRUE, @@ -8475,7 +8626,7 @@ SfxBoolItem ReadOnlyMode SID_READONLY_MODE [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = TRUE, HasCoreId = FALSE, HasDialog = FALSE, @@ -9347,7 +9498,7 @@ SfxVoidItem Select SID_SELECT [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -10951,7 +11102,7 @@ SfxBoolItem TwainSelect SID_TWAIN_SELECT [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = TRUE, @@ -10976,7 +11127,7 @@ SfxVoidItem TwainTransfer SID_TWAIN_TRANSFER [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = TRUE, diff --git a/svx/sdi/svxitems.sdi b/svx/sdi/svxitems.sdi index 795f2aea1177..65a59bccf3b6 100644 --- a/svx/sdi/svxitems.sdi +++ b/svx/sdi/svxitems.sdi @@ -668,7 +668,6 @@ struct SvxCharRotate }; item SvxCharRotate SvxCharRotateItem; -item String SvxClipboardFmtItem; // dummy item String SfxSetItem; // dummy item INT16 SvxRotateModeItem; // enum item INT16 SvxOrientationItem; // enum @@ -700,4 +699,3 @@ struct ZoomSlider INT16 SvxMaxZoom MID_ZOOMSLIDER_MAXZOOM; }; item ZoomSlider SvxZoomSliderItem; - diff --git a/svx/source/accessibility/AccessibleEmptyEditSource.cxx b/svx/source/accessibility/AccessibleEmptyEditSource.cxx index 6420a14c98ae..15da06a17054 100644 --- a/svx/source/accessibility/AccessibleEmptyEditSource.cxx +++ b/svx/source/accessibility/AccessibleEmptyEditSource.cxx @@ -340,6 +340,13 @@ namespace accessibility if( mbEditSourceEmpty ) Switch2ProxyEditSource(); } + else if (pSdrHint && pSdrHint->GetObject()!=NULL) + { + // When the SdrObject just got a para outliner object then + // switch the edit source. + if (pSdrHint->GetObject()->GetOutlinerParaObject() != NULL) + Switch2ProxyEditSource(); + } // forward messages Broadcast( rHint ); diff --git a/svx/source/cui/cuioptgenrl.hxx b/svx/source/cui/cuioptgenrl.hxx index a19b20c16028..22ef5481651f 100644 --- a/svx/source/cui/cuioptgenrl.hxx +++ b/svx/source/cui/cuioptgenrl.hxx @@ -80,6 +80,7 @@ private: SvxUserEdit aCompanyEdit; FixedText aNameLbl; FixedText aNameLblRuss; + FixedText aNameLblEastern; SvxUserEdit aFirstName; SvxUserEdit aFatherName; SvxUserEdit aName; diff --git a/svx/source/cui/macropg.cxx b/svx/source/cui/macropg.cxx index 6eeba1b0e703..0ee76246abe3 100644 --- a/svx/source/cui/macropg.cxx +++ b/svx/source/cui/macropg.cxx @@ -271,22 +271,42 @@ void _SvxMacroTabPage::InitResources() // the event name to UI string mappings for App Events aDisplayNames.push_back( EventDisplayName( "OnStartApp", RID_SVXSTR_EVENT_STARTAPP ) ); aDisplayNames.push_back( EventDisplayName( "OnCloseApp", RID_SVXSTR_EVENT_CLOSEAPP ) ); - aDisplayNames.push_back( EventDisplayName( "OnNew", RID_SVXSTR_EVENT_CREATEDOC ) ); + aDisplayNames.push_back( EventDisplayName( "OnCreate", RID_SVXSTR_EVENT_CREATEDOC ) ); + aDisplayNames.push_back( EventDisplayName( "OnNew", RID_SVXSTR_EVENT_NEWDOC ) ); + aDisplayNames.push_back( EventDisplayName( "OnLoadFinished", RID_SVXSTR_EVENT_LOADDOCFINISHED ) ); aDisplayNames.push_back( EventDisplayName( "OnLoad", RID_SVXSTR_EVENT_OPENDOC ) ); - aDisplayNames.push_back( EventDisplayName( "OnSaveAs", RID_SVXSTR_EVENT_SAVEASDOC ) ); - aDisplayNames.push_back( EventDisplayName( "OnSaveAsDone", RID_SVXSTR_EVENT_SAVEASDOCDONE ) ); - aDisplayNames.push_back( EventDisplayName( "OnSave", RID_SVXSTR_EVENT_SAVEDOC ) ); - aDisplayNames.push_back( EventDisplayName( "OnSaveDone", RID_SVXSTR_EVENT_SAVEDOCDONE ) ); aDisplayNames.push_back( EventDisplayName( "OnPrepareUnload", RID_SVXSTR_EVENT_PREPARECLOSEDOC ) ); aDisplayNames.push_back( EventDisplayName( "OnUnload", RID_SVXSTR_EVENT_CLOSEDOC ) ) ; + aDisplayNames.push_back( EventDisplayName( "OnViewCreated", RID_SVXSTR_EVENT_VIEWCREATED ) ); + aDisplayNames.push_back( EventDisplayName( "OnPrepareViewClosing", RID_SVXSTR_EVENT_PREPARECLOSEVIEW ) ); + aDisplayNames.push_back( EventDisplayName( "OnViewClosed", RID_SVXSTR_EVENT_CLOSEVIEW ) ) ; aDisplayNames.push_back( EventDisplayName( "OnFocus", RID_SVXSTR_EVENT_ACTIVATEDOC ) ); aDisplayNames.push_back( EventDisplayName( "OnUnfocus", RID_SVXSTR_EVENT_DEACTIVATEDOC ) ); + aDisplayNames.push_back( EventDisplayName( "OnSave", RID_SVXSTR_EVENT_SAVEDOC ) ); + aDisplayNames.push_back( EventDisplayName( "OnSaveDone", RID_SVXSTR_EVENT_SAVEDOCDONE ) ); + aDisplayNames.push_back( EventDisplayName( "OnSaveFailed", RID_SVXSTR_EVENT_SAVEDOCFAILED ) ); + aDisplayNames.push_back( EventDisplayName( "OnSaveAs", RID_SVXSTR_EVENT_SAVEASDOC ) ); + aDisplayNames.push_back( EventDisplayName( "OnSaveAsDone", RID_SVXSTR_EVENT_SAVEASDOCDONE ) ); + aDisplayNames.push_back( EventDisplayName( "OnSaveAsFailed", RID_SVXSTR_EVENT_SAVEASDOCFAILED ) ); + aDisplayNames.push_back( EventDisplayName( "OnCopyTo", RID_SVXSTR_EVENT_COPYTODOC ) ); + aDisplayNames.push_back( EventDisplayName( "OnCopyToDone", RID_SVXSTR_EVENT_COPYTODOCDONE ) ); + aDisplayNames.push_back( EventDisplayName( "OnCopyToFailed", RID_SVXSTR_EVENT_COPYTODOCFAILED ) ); aDisplayNames.push_back( EventDisplayName( "OnPrint", RID_SVXSTR_EVENT_PRINTDOC ) ); aDisplayNames.push_back( EventDisplayName( "OnModifyChanged", RID_SVXSTR_EVENT_MODIFYCHANGED ) ); + aDisplayNames.push_back( EventDisplayName( "OnTitleChanged", RID_SVXSTR_EVENT_TITLECHANGED ) ); +// aDisplayNames.push_back( EventDisplayName( "OnModeChanged", RID_SVXSTR_EVENT_MODECHANGED ) ); +// aDisplayNames.push_back( EventDisplayName( "OnVisAreaChanged", RID_SVXSTR_EVENT_VISAREACHANGED ) ); +// aDisplayNames.push_back( EventDisplayName( "OnStorageChanged", RID_SVXSTR_EVENT_STORAGECHANGED ) ); + + // application specific events aDisplayNames.push_back( EventDisplayName( "OnMailMerge", RID_SVXSTR_EVENT_MAILMERGE ) ); + aDisplayNames.push_back( EventDisplayName( "OnMailMergeFinished", RID_SVXSTR_EVENT_MAILMERGE_END ) ); + aDisplayNames.push_back( EventDisplayName( "OnFieldMerge", RID_SVXSTR_EVENT_FIELDMERGE ) ); + aDisplayNames.push_back( EventDisplayName( "OnFieldMergeFinished", RID_SVXSTR_EVENT_FIELDMERGE_FINISHED ) ); aDisplayNames.push_back( EventDisplayName( "OnPageCountChange", RID_SVXSTR_EVENT_PAGECOUNTCHANGE ) ); aDisplayNames.push_back( EventDisplayName( "OnSubComponentOpened", RID_SVXSTR_EVENT_SUBCOMPONENT_OPENED ) ); aDisplayNames.push_back( EventDisplayName( "OnSubComponentClosed", RID_SVXSTR_EVENT_SUBCOMPONENT_CLOSED ) ); +// aDisplayNames.push_back( EventDisplayName( "OnLayoutFinished", RID_SVXSTR_EVENT_LAYOUT_FINISHED ) ); // the event name to UI string mappings for forms & dialogs // @@ -571,9 +591,14 @@ void _SvxMacroTabPage::DisplayAppEvents( bool appEvents) rListBox.Select( _pE ); rListBox.MakeVisible( _pE ); } + pE = rListBox.GetEntry(0); if( pE ) + { rListBox.Select( pE ); + rListBox.MakeVisible( pE ); + } + rListBox.SetUpdateMode( TRUE ); EnableButtons( String() ); } diff --git a/svx/source/cui/macropg.src b/svx/source/cui/macropg.src index e9b6c10d6014..92e1e718ba61 100644 --- a/svx/source/cui/macropg.src +++ b/svx/source/cui/macropg.src @@ -165,9 +165,9 @@ String RID_SVXSTR_EVENT_CLOSEAPP Text [ en-US ] = "Close Application" ; }; -String RID_SVXSTR_EVENT_CREATEDOC +String RID_SVXSTR_EVENT_NEWDOC { - Text [ en-US ] = "Create Document" ; + Text [ en-US ] = "New Document" ; }; String RID_SVXSTR_EVENT_CLOSEDOC @@ -177,7 +177,7 @@ String RID_SVXSTR_EVENT_CLOSEDOC String RID_SVXSTR_EVENT_PREPARECLOSEDOC { - Text [ en-US ] = "Document is closing" ; + Text [ en-US ] = "Document is going to be closed" ; }; String RID_SVXSTR_EVENT_OPENDOC @@ -226,7 +226,19 @@ String RID_SVXSTR_EVENT_MODIFYCHANGED }; String RID_SVXSTR_EVENT_MAILMERGE { - Text [ en-US ] = "Print form letters" ; + Text [ en-US ] = "Printing of form letters started" ; +}; +String RID_SVXSTR_EVENT_MAILMERGE_END +{ + Text [ en-US ] = "Printing of form letters finished" ; +}; +String RID_SVXSTR_EVENT_FIELDMERGE +{ + Text [ en-US ] = "Merging of form fields started" ; +}; +String RID_SVXSTR_EVENT_FIELDMERGE_FINISHED +{ + Text [ en-US ] = "Merging of form fields finished" ; }; String RID_SVXSTR_EVENT_PAGECOUNTCHANGE { @@ -372,3 +384,78 @@ String RID_SVXSTR_EVENT_CHANGED { Text [ en-US ] = "Changed" ; }; + +String RID_SVXSTR_EVENT_CREATEDOC +{ + Text [ en-US ] = "Document created" ; +}; + +String RID_SVXSTR_EVENT_LOADDOCFINISHED +{ + Text [ en-US ] = "Document loading finished" ; +}; + +String RID_SVXSTR_EVENT_SAVEDOCFAILED +{ + Text [ en-US ] = "Saving of document failed" ; +}; + +String RID_SVXSTR_EVENT_SAVEASDOCFAILED +{ + Text [ en-US ] = "'Save as' has failed" ; +}; + +String RID_SVXSTR_EVENT_COPYTODOC +{ + Text [ en-US ] = "Storing or exporting copy of document" ; +}; + +String RID_SVXSTR_EVENT_COPYTODOCDONE +{ + Text [ en-US ] = "Document copy has been created" ; +}; + +String RID_SVXSTR_EVENT_COPYTODOCFAILED +{ + Text [ en-US ] = "Creating of document copy failed" ; +}; + +String RID_SVXSTR_EVENT_VIEWCREATED +{ + Text [ en-US ] = "View created" ; +}; + +String RID_SVXSTR_EVENT_PREPARECLOSEVIEW +{ + Text [ en-US ] = "View is going to be closed" ; +}; + +String RID_SVXSTR_EVENT_CLOSEVIEW +{ + Text [ en-US ] = "View closed" ; +}; + +String RID_SVXSTR_EVENT_TITLECHANGED +{ + Text [ en-US ] = "Document title changed" ; +}; + +String RID_SVXSTR_EVENT_MODECHANGED +{ + Text [ en-US ] = "Document mode changed" ; +}; + +String RID_SVXSTR_EVENT_VISAREACHANGED +{ + Text [ en-US ] = "Visible area changed" ; +}; + +String RID_SVXSTR_EVENT_STORAGECHANGED +{ + Text [ en-US ] = "Document has got a new storage" ; +}; + +String RID_SVXSTR_EVENT_LAYOUT_FINISHED +{ + Text [ en-US ] = "Document layout finished" ; +}; diff --git a/svx/source/cui/numfmt.cxx b/svx/source/cui/numfmt.cxx index a3b426c6110e..d6978ea008b8 100644 --- a/svx/source/cui/numfmt.cxx +++ b/svx/source/cui/numfmt.cxx @@ -292,7 +292,6 @@ SvxNumberFormatTabPage::SvxNumberFormatTabPage( Window* pParent, pNumFmtShell ( NULL ), nInitFormat ( ULONG_MAX ), - aStrEurope ( THIS_SVX_RES( STR_EUROPE) ), sAutomaticEntry ( THIS_SVX_RES( STR_AUTO_ENTRY)), pLastActivWindow( NULL ) { @@ -1887,7 +1886,7 @@ void SvxNumberFormatTabPage::FillCurrencyBox() USHORT nPos=0; USHORT nSelPos=0; - pNumFmtShell->GetCurrencySymbols(aList,aStrEurope,&nSelPos); + pNumFmtShell->GetCurrencySymbols( aList, &nSelPos); for(USHORT i=1;i<aList.Count();i++) { diff --git a/svx/source/cui/numfmt.hrc b/svx/source/cui/numfmt.hrc index 7f63e02b57d5..102c5a212ac6 100644 --- a/svx/source/cui/numfmt.hrc +++ b/svx/source/cui/numfmt.hrc @@ -64,10 +64,9 @@ #define IB_INFO 31 #define IL_ICON 32 #define LB_CURRENCY 33 -#define STR_EUROPE 34 -#define CB_SOURCEFORMAT 35 -#define IL_ICON_HC 36 -#define STR_AUTO_ENTRY 37 +#define CB_SOURCEFORMAT 34 +#define IL_ICON_HC 35 +#define STR_AUTO_ENTRY 36 #define TBX_ADDREMOVE 1 #define IID_ADD 1 diff --git a/svx/source/cui/numfmt.hxx b/svx/source/cui/numfmt.hxx index ff9d0813f6e5..e14f397cf0ba 100644 --- a/svx/source/cui/numfmt.hxx +++ b/svx/source/cui/numfmt.hxx @@ -170,7 +170,6 @@ private: long nCurFormatHeight; long nStdFormatY; long nStdFormatHeight; - LocalizedString aStrEurope; LocalizedString sAutomaticEntry; Window* pLastActivWindow; diff --git a/svx/source/cui/numfmt.src b/svx/source/cui/numfmt.src index ab71ae446998..96269bb9ec09 100644 --- a/svx/source/cui/numfmt.src +++ b/svx/source/cui/numfmt.src @@ -256,10 +256,6 @@ TabPage RID_SVXPAGE_NUMBERFORMAT IdCount = { 3 ; }; }; - String STR_EUROPE - { - Text [ en-US ] = "Europe"; - }; String STR_AUTO_ENTRY { Text [ en-US ] = "Automatic"; diff --git a/svx/source/cui/optgdlg.cxx b/svx/source/cui/optgdlg.cxx index 31fcff220f8a..9a53de6bea72 100644 --- a/svx/source/cui/optgdlg.cxx +++ b/svx/source/cui/optgdlg.cxx @@ -103,6 +103,7 @@ #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/container/XContentEnumerationAccess.hpp> #include <com/sun/star/container/XSet.hpp> +#include <com/sun/star/i18n/ScriptType.hpp> #include <vcl/svapp.hxx> @@ -1277,8 +1278,13 @@ OfaLanguagesTabPage::OfaLanguagesTabPage( Window* pParent, const SfxItemSet& rSe // initialize user interface language selection SvtLanguageTable* pLanguageTable = new SvtLanguageTable; - String aStr( pLanguageTable->GetString( LANGUAGE_SYSTEM ) ); - aUserInterfaceLB.InsertEntry(aStr); + const String aStr( pLanguageTable->GetString( LANGUAGE_SYSTEM ) ); + + String aUILang(aStr); + aUILang += String::CreateFromAscii(" - "); + aUILang += pLanguageTable->GetString( Application::GetSettings().GetUILanguage() ); + + aUserInterfaceLB.InsertEntry(aUILang); aUserInterfaceLB.SetEntryData(0, 0); aUserInterfaceLB.SelectEntryPos(0); try @@ -1340,16 +1346,24 @@ OfaLanguagesTabPage::OfaLanguagesTabPage( Window* pParent, const SfxItemSet& rSe } aWesternLanguageLB.SetLanguageList( LANG_LIST_WESTERN | LANG_LIST_ONLY_KNOWN, TRUE, FALSE, TRUE ); - aAsianLanguageLB .SetLanguageList( LANG_LIST_CJK | LANG_LIST_ONLY_KNOWN, TRUE, FALSE, TRUE ); + aWesternLanguageLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::LATIN ); + aAsianLanguageLB.SetLanguageList( LANG_LIST_CJK | LANG_LIST_ONLY_KNOWN, TRUE, FALSE, TRUE ); + aAsianLanguageLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::ASIAN ); aComplexLanguageLB.SetLanguageList( LANG_LIST_CTL | LANG_LIST_ONLY_KNOWN, TRUE, FALSE, TRUE ); - aLocaleSettingLB .SetLanguageList( LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, FALSE, FALSE, FALSE); - aLocaleSettingLB.InsertLanguage( LANGUAGE_SYSTEM ); + aComplexLanguageLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::COMPLEX ); - // insert SYSTEM entry, no specific currency - aCurrencyLB.InsertEntry( aStr ); + aLocaleSettingLB.SetLanguageList( LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, FALSE, FALSE, FALSE); + aLocaleSettingLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::WEAK ); + + const NfCurrencyTable& rCurrTab = SvNumberFormatter::GetTheCurrencyTable(); + const NfCurrencyEntry& rCurr = SvNumberFormatter::GetCurrencyEntry( LANGUAGE_SYSTEM ); + // insert SYSTEM entry + String aDefaultCurr(aStr); + aDefaultCurr += String::CreateFromAscii(" - "); + aDefaultCurr += rCurr.GetBankSymbol(); + aCurrencyLB.InsertEntry( aDefaultCurr ); // all currencies String aTwoSpace( RTL_CONSTASCII_USTRINGPARAM( " " ) ); - const NfCurrencyTable& rCurrTab = SvNumberFormatter::GetTheCurrencyTable(); USHORT nCurrCount = rCurrTab.Count(); // first entry is SYSTEM, skip it for ( USHORT j=1; j < nCurrCount; ++j ) @@ -1572,7 +1586,7 @@ BOOL OfaLanguagesTabPage::FillItemSet( SfxItemSet& rSet ) if(!bCurrentDocCBChecked) { Any aValue; - Locale aLocale = SvxCreateLocale( eSelectLang ); + Locale aLocale = MsLangId::convertLanguageToLocale( eSelectLang, false ); aValue <<= aLocale; OUString aPropName( C2U("DefaultLocale") ); pLangConfig->aLinguConfig.SetProperty( aPropName, aValue ); @@ -1581,7 +1595,8 @@ BOOL OfaLanguagesTabPage::FillItemSet( SfxItemSet& rSet ) } if(pCurrentDocShell) { - rSet.Put(SvxLanguageItem(eSelectLang, SID_ATTR_LANGUAGE)); + rSet.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::LATIN), + SID_ATTR_LANGUAGE)); bRet = TRUE; } } @@ -1592,7 +1607,7 @@ BOOL OfaLanguagesTabPage::FillItemSet( SfxItemSet& rSet ) if(!bCurrentDocCBChecked) { Any aValue; - Locale aLocale = SvxCreateLocale( eSelectLang ); + Locale aLocale = MsLangId::convertLanguageToLocale( eSelectLang, false ); aValue <<= aLocale; OUString aPropName( C2U("DefaultLocale_CJK") ); pLangConfig->aLinguConfig.SetProperty( aPropName, aValue ); @@ -1601,7 +1616,8 @@ BOOL OfaLanguagesTabPage::FillItemSet( SfxItemSet& rSet ) } if(pCurrentDocShell) { - rSet.Put(SvxLanguageItem(eSelectLang, SID_ATTR_CHAR_CJK_LANGUAGE)); + rSet.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::ASIAN), + SID_ATTR_CHAR_CJK_LANGUAGE)); bRet = TRUE; } } @@ -1612,7 +1628,7 @@ BOOL OfaLanguagesTabPage::FillItemSet( SfxItemSet& rSet ) if(!bCurrentDocCBChecked) { Any aValue; - Locale aLocale = SvxCreateLocale( eSelectLang ); + Locale aLocale = MsLangId::convertLanguageToLocale( eSelectLang, false ); aValue <<= aLocale; OUString aPropName( C2U("DefaultLocale_CTL") ); pLangConfig->aLinguConfig.SetProperty( aPropName, aValue ); @@ -1621,7 +1637,8 @@ BOOL OfaLanguagesTabPage::FillItemSet( SfxItemSet& rSet ) } if(pCurrentDocShell) { - rSet.Put(SvxLanguageItem(eSelectLang, SID_ATTR_CHAR_CTL_LANGUAGE)); + rSet.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::COMPLEX), + SID_ATTR_CHAR_CTL_LANGUAGE)); bRet = TRUE; } } @@ -1721,13 +1738,18 @@ void OfaLanguagesTabPage::Reset( const SfxItemSet& rSet ) aWestLang = pLangConfig->aLinguConfig.GetProperty(C2U("DefaultLocale")); Locale aLocale; aWestLang >>= aLocale; - eCurLang = SvxLocaleToLanguage( aLocale ); + + eCurLang = MsLangId::convertLocaleToLanguage( aLocale ); + aCJKLang = pLangConfig->aLinguConfig.GetProperty(C2U("DefaultLocale_CJK")); + aLocale = Locale(); aCJKLang >>= aLocale; - eCurLangCJK = SvxLocaleToLanguage( aLocale ); + eCurLangCJK = MsLangId::convertLocaleToLanguage( aLocale ); + aCTLLang = pLangConfig->aLinguConfig.GetProperty(C2U("DefaultLocale_CTL")); + aLocale = Locale(); aCTLLang >>= aLocale; - eCurLangCTL = SvxLocaleToLanguage( aLocale ); + eCurLangCTL = MsLangId::convertLocaleToLanguage( aLocale ); } catch(Exception&) { @@ -1739,13 +1761,25 @@ void OfaLanguagesTabPage::Reset( const SfxItemSet& rSet ) aCurrentDocCB.Check(bLanguageCurrentDoc_Impl); const SfxPoolItem* pLang; if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_LANGUAGE, FALSE, &pLang)) - eCurLang = ((const SvxLanguageItem*)pLang)->GetValue(); + { + LanguageType eTempCurLang = ((const SvxLanguageItem*)pLang)->GetValue(); + if (MsLangId::resolveSystemLanguageByScriptType(eCurLang, ::com::sun::star::i18n::ScriptType::LATIN) != eTempCurLang) + eCurLang = eTempCurLang; + } if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_CHAR_CJK_LANGUAGE, FALSE, &pLang)) - eCurLangCJK = ((const SvxLanguageItem*)pLang)->GetValue(); + { + LanguageType eTempCurLang = ((const SvxLanguageItem*)pLang)->GetValue(); + if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCJK, ::com::sun::star::i18n::ScriptType::ASIAN) != eTempCurLang) + eCurLangCJK = eTempCurLang; + } if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_CHAR_CTL_LANGUAGE, FALSE, &pLang)) - eCurLangCTL = ((const SvxLanguageItem*)pLang)->GetValue(); + { + LanguageType eTempCurLang = ((const SvxLanguageItem*)pLang)->GetValue(); + if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCTL, ::com::sun::star::i18n::ScriptType::COMPLEX) != eTempCurLang) + eCurLangCTL = eTempCurLang; + } } if(LANGUAGE_NONE == eCurLang || LANGUAGE_DONTKNOW == eCurLang) aWesternLanguageLB.SelectLanguage(LANGUAGE_NONE); diff --git a/svx/source/cui/optgdlg.src b/svx/source/cui/optgdlg.src index a711be6bf0fc..f663a7ed44ef 100644 --- a/svx/source/cui/optgdlg.src +++ b/svx/source/cui/optgdlg.src @@ -460,13 +460,13 @@ TabPage OFA_TP_LANGUAGES FixedText FT_USERINTERFACE { Pos = MAP_APPFONT ( 12 , 16 ) ; - Size = MAP_APPFONT ( 120 , 8 ) ; + Size = MAP_APPFONT ( 108 , 8 ) ; Text [ en-US ] = "~User interface"; }; ListBox LB_USERINTERFACE { - Pos = MAP_APPFONT ( 135 , 14 ) ; - Size = MAP_APPFONT ( 113 , 60 ) ; + Pos = MAP_APPFONT ( 123 , 14 ) ; + Size = MAP_APPFONT ( 125 , 60 ) ; DropDown = TRUE ; Border = TRUE ; TabStop = TRUE ; @@ -481,13 +481,13 @@ TabPage OFA_TP_LANGUAGES FixedText FT_LOCALESETTING { Pos = MAP_APPFONT ( 12 , 31 ) ; - Size = MAP_APPFONT ( 120 , 8 ) ; + Size = MAP_APPFONT ( 108 , 8 ) ; Text [ en-US ] = "Locale setting"; }; ListBox LB_LOCALESETTING { - Pos = MAP_APPFONT ( 135 , 30 ) ; - Size = MAP_APPFONT ( 113 , 60 ) ; + Pos = MAP_APPFONT ( 123 , 30 ) ; + Size = MAP_APPFONT ( 125 , 60 ) ; DropDown = TRUE ; Border = TRUE ; TabStop = TRUE ; @@ -496,13 +496,13 @@ TabPage OFA_TP_LANGUAGES FixedText FT_DECIMALSEPARATOR { Pos = MAP_APPFONT ( 12 , 46 ) ; - Size = MAP_APPFONT ( 120 , 8 ) ; + Size = MAP_APPFONT ( 108 , 8 ) ; Text [ en-US ] = "Decimal separator key"; }; CheckBox CB_DECIMALSEPARATOR { - Pos = MAP_APPFONT ( 135 , 46) ; - Size = MAP_APPFONT ( 119 , RSC_CD_CHECKBOX_HEIGHT ) ; + Pos = MAP_APPFONT ( 123 , 46) ; + Size = MAP_APPFONT ( 125 , RSC_CD_CHECKBOX_HEIGHT ) ; Text [ en-US ] = "~Same as locale setting ( %1 )"; }; FixedImage FI_CURRENCY @@ -514,13 +514,13 @@ TabPage OFA_TP_LANGUAGES FixedText FT_CURRENCY { Pos = MAP_APPFONT ( 12 , 61 ) ; - Size = MAP_APPFONT ( 120 , 8 ) ; + Size = MAP_APPFONT ( 108 , 8 ) ; Text [ en-US ] = "~Default currency"; }; ListBox LB_CURRENCY { - Pos = MAP_APPFONT ( 135 , 59 ) ; - Size = MAP_APPFONT ( 113 , 60 ) ; + Pos = MAP_APPFONT ( 123 , 59 ) ; + Size = MAP_APPFONT ( 125 , 60 ) ; DropDown = TRUE ; Border = TRUE ; TabStop = TRUE ; @@ -541,14 +541,14 @@ TabPage OFA_TP_LANGUAGES FixedText FT_WEST_LANG { Pos = MAP_APPFONT ( 12 , 90 ) ; - Size = MAP_APPFONT ( 120 , 8 ) ; + Size = MAP_APPFONT ( 108 , 8 ) ; Text [ en-US ] = "Western"; }; ListBox LB_WEST_LANG { - Pos = MAP_APPFONT ( 135 , 88 ) ; - Size = MAP_APPFONT ( 113 , 60 ) ; + Pos = MAP_APPFONT ( 123 , 88 ) ; + Size = MAP_APPFONT ( 125 , 60 ) ; DropDown = TRUE ; Border = TRUE ; TabStop = TRUE ; @@ -563,13 +563,13 @@ TabPage OFA_TP_LANGUAGES FixedText FT_ASIAN_LANG { Pos = MAP_APPFONT ( 12 , 106 ) ; - Size = MAP_APPFONT ( 120 , 8 ) ; + Size = MAP_APPFONT ( 108 , 8 ) ; Text [ en-US ] = "Asian"; }; ListBox LB_ASIAN_LANG { - Pos = MAP_APPFONT ( 135 , 104 ) ; - Size = MAP_APPFONT ( 113 , 60 ) ; + Pos = MAP_APPFONT ( 123 , 104 ) ; + Size = MAP_APPFONT ( 125 , 60 ) ; DropDown = TRUE ; Border = TRUE ; TabStop = TRUE ; @@ -584,13 +584,13 @@ TabPage OFA_TP_LANGUAGES FixedText FT_COMPLEX_LANG { Pos = MAP_APPFONT ( 12 , 122 ) ; - Size = MAP_APPFONT ( 120 , 8 ) ; + Size = MAP_APPFONT ( 108 , 8 ) ; Text [ en-US ] = "C~TL"; }; ListBox LB_COMPLEX_LANG { - Pos = MAP_APPFONT ( 135 , 120 ) ; - Size = MAP_APPFONT ( 113 , 60 ) ; + Pos = MAP_APPFONT ( 123 , 120 ) ; + Size = MAP_APPFONT ( 125 , 60 ) ; DropDown = TRUE ; Border = TRUE ; TabStop = TRUE ; @@ -598,8 +598,8 @@ TabPage OFA_TP_LANGUAGES }; CheckBox CB_CURRENT_DOC { - Pos = MAP_APPFONT ( 135 , 135 ) ; - Size = MAP_APPFONT ( 113 , RSC_CD_CHECKBOX_HEIGHT ) ; + Pos = MAP_APPFONT ( 123 , 135 ) ; + Size = MAP_APPFONT ( 125 , RSC_CD_CHECKBOX_HEIGHT ) ; Text [ en-US ] = "For the current document only"; }; FixedLine FL_ENHANCED diff --git a/svx/source/cui/optgenrl.cxx b/svx/source/cui/optgenrl.cxx index 1766dd58de72..7159cfdd7e61 100644 --- a/svx/source/cui/optgenrl.cxx +++ b/svx/source/cui/optgenrl.cxx @@ -103,6 +103,7 @@ SvxGeneralTabPage::SvxGeneralTabPage( Window* pParent, const SfxItemSet& rCoreSe aCompanyEdit ( this, SVX_RES( ED_COMPANY ), INDEX_NOTSET, &aCompanyLbl ), aNameLbl ( this, SVX_RES( FT_NAME ), true ), aNameLblRuss ( this, SVX_RES( FT_NAME_RUSS ), true ), + aNameLblEastern ( this, SVX_RES( FT_NAME_EASTERN ), true ), aFirstName ( this, SVX_RES( ED_FIRSTNAME ), 0, &aNameLbl ), aFatherName ( this, SVX_RES( ED_FATHERNAME ) ), aName ( this, SVX_RES( ED_NAME ), 1, &aNameLbl ), @@ -189,6 +190,23 @@ SvxGeneralTabPage::SvxGeneralTabPage( Window* pParent, const SfxItemSet& rCoreSe aFirstName.SetZOrder( &aName, WINDOW_ZORDER_BEHIND ); aFatherName.SetZOrder( &aFirstName, WINDOW_ZORDER_BEHIND ); } + else if ( LANGUAGE_JAPANESE == eLang || + LANGUAGE_KOREAN == eLang || + LANGUAGE_CHINESE_TRADITIONAL == eLang || + LANGUAGE_CHINESE_SIMPLIFIED == eLang) + { + aUsCityEdit.Hide(); + aUsStateEdit.Hide(); + aUsZipEdit.Hide(); + aNameLbl.Hide(); + aNameLblEastern.Show(); + + // swap "first name" field and "last name" field + Point aPosTmp = aFirstName.GetPosPixel(); + aFirstName.SetPosPixel( aName.GetPosPixel() ); + aName.SetPosPixel( aPosTmp ); + aFirstName.SetZOrder( &aName, WINDOW_ZORDER_BEHIND ); + } else { aUsCityEdit.Hide(); diff --git a/svx/source/cui/optsave.cxx b/svx/source/cui/optsave.cxx index ca8871837e58..f8407a2a6be4 100644 --- a/svx/source/cui/optsave.cxx +++ b/svx/source/cui/optsave.cxx @@ -245,38 +245,57 @@ SfxSaveTabPage::SfxSaveTabPage( Window* pParent, const SfxItemSet& rCoreSet ) : SvtModuleOptions aModuleOpt; if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) ) + { aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_MATH )); + aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_MATH )); + } else { pImpl->aDefaultArr[APP_MATH] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_MATH); pImpl->aDefaultReadonlyArr[APP_MATH] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_MATH); } + if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) ) + { aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_DRAW )); + aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_DRAW )); + } else { pImpl->aDefaultArr[APP_DRAW] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_DRAW); pImpl->aDefaultReadonlyArr[APP_DRAW] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_DRAW); } + if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) ) + { aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_IMPRESS )); + aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_IMPRESS )); + } else { pImpl->aDefaultArr[APP_IMPRESS] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_IMPRESS); pImpl->aDefaultReadonlyArr[APP_IMPRESS] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_IMPRESS); } + if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) ) + { aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_CALC )); + aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_CALC )); + } else { pImpl->aDefaultArr[APP_CALC] = aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::E_CALC); pImpl->aDefaultReadonlyArr[APP_CALC] = aModuleOpt.IsDefaultFilterReadonly(SvtModuleOptions::E_CALC); } + if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) ) { aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_WRITER )); aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_WRITER_WEB )); aSaveAsLB.RemoveEntry(aSaveAsLB.GetEntryPos( (void*) APP_WRITER_GLOBAL )); + aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_WRITER )); + aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_WRITER_WEB )); + aDocTypeLB.RemoveEntry(aDocTypeLB.GetEntryPos( (void*) APP_WRITER_GLOBAL )); } else { @@ -726,18 +745,23 @@ OUString lcl_ExtracUIName(const Sequence<PropertyValue> rProperties) ---------------------------------------------------------------------------*/ IMPL_LINK( SfxSaveTabPage, FilterHdl_Impl, ListBox *, pBox ) { - if(&aDocTypeLB == pBox) + USHORT nCurPos = aDocTypeLB.GetSelectEntryPos(); + + long nData = -1; + if(nCurPos < APP_COUNT) + nData = (long) aDocTypeLB.GetEntryData(nCurPos); + + if ( nData >= 0 && nData < APP_COUNT ) { - USHORT nAppPos = pBox->GetSelectEntryPos(); - if ( nAppPos < APP_COUNT ) + if(&aDocTypeLB == pBox) { aSaveAsLB.Clear(); - const OUString* pFilters = pImpl->aFilterArr[nAppPos].getConstArray(); - if(!pImpl->aUIFilterArr[nAppPos].getLength()) + const OUString* pFilters = pImpl->aFilterArr[nData].getConstArray(); + if(!pImpl->aUIFilterArr[nData].getLength()) { - pImpl->aUIFilterArr[nAppPos].realloc(pImpl->aFilterArr[nAppPos].getLength()); - OUString* pUIFilters = pImpl->aUIFilterArr[nAppPos].getArray(); - for(int nFilter = 0; nFilter < pImpl->aFilterArr[nAppPos].getLength(); nFilter++) + pImpl->aUIFilterArr[nData].realloc(pImpl->aFilterArr[nData].getLength()); + OUString* pUIFilters = pImpl->aUIFilterArr[nData].getArray(); + for(int nFilter = 0; nFilter < pImpl->aFilterArr[nData].getLength(); nFilter++) { Any aProps = pImpl->xFact->getByName(pFilters[nFilter]); Sequence<PropertyValue> aProperties; @@ -745,37 +769,36 @@ IMPL_LINK( SfxSaveTabPage, FilterHdl_Impl, ListBox *, pBox ) pUIFilters[nFilter] = lcl_ExtracUIName(aProperties); } } - const OUString* pUIFilters = pImpl->aUIFilterArr[nAppPos].getConstArray(); + const OUString* pUIFilters = pImpl->aUIFilterArr[nData].getConstArray(); OUString sSelect; - for(int i = 0; i < pImpl->aUIFilterArr[nAppPos].getLength(); i++) + for(int i = 0; i < pImpl->aUIFilterArr[nData].getLength(); i++) { USHORT nEntryPos = aSaveAsLB.InsertEntry(pUIFilters[i]); - if ( pImpl->aODFArr[nAppPos][i] ) + if ( pImpl->aODFArr[nData][i] ) aSaveAsLB.SetEntryData( nEntryPos, (void*)pImpl ); - if(pFilters[i] == pImpl->aDefaultArr[nAppPos]) + if(pFilters[i] == pImpl->aDefaultArr[nData]) sSelect = pUIFilters[i]; } if(sSelect.getLength()) aSaveAsLB.SelectEntry(sSelect); - aSaveAsFI.Show(pImpl->aDefaultReadonlyArr[nAppPos]); - aSaveAsFT.Enable(!pImpl->aDefaultReadonlyArr[nAppPos]); - aSaveAsLB.Enable(!pImpl->aDefaultReadonlyArr[nAppPos]); + aSaveAsFI.Show(pImpl->aDefaultReadonlyArr[nData]); + aSaveAsFT.Enable(!pImpl->aDefaultReadonlyArr[nData]); + aSaveAsLB.Enable(!pImpl->aDefaultReadonlyArr[nData]); } - } - else - { - OUString sSelect = pBox->GetSelectEntry(); - USHORT nPos = aDocTypeLB.GetSelectEntryPos(); - const OUString* pFilters = pImpl->aFilterArr[nPos].getConstArray(); - OUString* pUIFilters = pImpl->aUIFilterArr[nPos].getArray(); - for(int i = 0; i < pImpl->aUIFilterArr[nPos].getLength(); i++) - if(pUIFilters[i] == sSelect) - { - sSelect = pFilters[i]; - break; - } + else + { + OUString sSelect = pBox->GetSelectEntry(); + const OUString* pFilters = pImpl->aFilterArr[nData].getConstArray(); + OUString* pUIFilters = pImpl->aUIFilterArr[nData].getArray(); + for(int i = 0; i < pImpl->aUIFilterArr[nData].getLength(); i++) + if(pUIFilters[i] == sSelect) + { + sSelect = pFilters[i]; + break; + } - pImpl->aDefaultArr[nPos] = sSelect; + pImpl->aDefaultArr[nData] = sSelect; + } } ODFVersionHdl_Impl( &aSaveAsLB ); @@ -785,7 +808,7 @@ IMPL_LINK( SfxSaveTabPage, FilterHdl_Impl, ListBox *, pBox ) IMPL_LINK( SfxSaveTabPage, ODFVersionHdl_Impl, ListBox *, EMPTYARG ) { long nVersion = long( aODFVersionLB.GetEntryData( aODFVersionLB.GetSelectEntryPos() ) ); - bool bShown = SvtSaveOptions::ODFDefaultVersion( nVersion ) == SvtSaveOptions::ODFVER_012; + bool bShown = SvtSaveOptions::ODFDefaultVersion( nVersion ) != SvtSaveOptions::ODFVER_LATEST; if ( bShown ) { bool bHasODFFormat = false; @@ -803,8 +826,8 @@ IMPL_LINK( SfxSaveTabPage, ODFVersionHdl_Impl, ListBox *, EMPTYARG ) || ( aSaveAsLB.GetEntryData( aSaveAsLB.GetSelectEntryPos() ) != NULL ); } - aODFWarningFI.Show( !bShown ); - aODFWarningFT.Show( !bShown ); + aODFWarningFI.Show( bShown ); + aODFWarningFT.Show( bShown ); return 0; } diff --git a/svx/source/cui/webconninfo.cxx b/svx/source/cui/webconninfo.cxx index 0298a8fc7e93..997c246abf1e 100644 --- a/svx/source/cui/webconninfo.cxx +++ b/svx/source/cui/webconninfo.cxx @@ -44,6 +44,7 @@ #include <com/sun/star/task/UrlRecord.hpp> #include <com/sun/star/task/XPasswordContainer.hpp> #include <com/sun/star/task/XMasterPasswordHandling.hpp> +#include "com/sun/star/task/XUrlContainer.hpp" #include <comphelper/processfactory.hxx> #include <comphelper/docpasswordrequest.hxx> @@ -116,7 +117,7 @@ WebConnectionInfoDialog::WebConnectionInfoDialog( Window* pParent ) : ,m_aButtonsFL ( this, SVX_RES( FL_BUTTONS ) ) ,m_aCloseBtn ( this, SVX_RES( PB_CLOSE ) ) ,m_aHelpBtn ( this, SVX_RES( PB_HELP ) ) - + ,m_nPos ( -1 ) { static long aStaticTabs[]= { 3, 0, 150, 250 }; m_aPasswordsLB.SetTabs( aStaticTabs ); @@ -211,6 +212,7 @@ void WebConnectionInfoDialog::FillPasswordList() uno::Sequence< task::UrlRecord > aURLEntries = xPasswdContainer->getAllPersistent( xInteractionHandler ); sal_Int32 nCount = 0; for ( sal_Int32 nURLInd = 0; nURLInd < aURLEntries.getLength(); nURLInd++ ) + { for ( sal_Int32 nUserInd = 0; nUserInd < aURLEntries[nURLInd].UserList.getLength(); nUserInd++ ) { ::rtl::OUString aUIEntry( aURLEntries[nURLInd].Url ); @@ -219,6 +221,25 @@ void WebConnectionInfoDialog::FillPasswordList() SvLBoxEntry* pEntry = m_aPasswordsLB.InsertEntry( aUIEntry ); pEntry->SetUserData( (void*)(nCount++) ); } + } + + // remember pos of first url container entry. + m_nPos = nCount; + + uno::Reference< task::XUrlContainer > xUrlContainer( + xPasswdContainer, uno::UNO_QUERY_THROW ); + + uno::Sequence< rtl::OUString > aUrls + = xUrlContainer->getUrls( sal_True /* OnlyPersistent */ ); + + for ( sal_Int32 nURLIdx = 0; nURLIdx < aUrls.getLength(); nURLIdx++ ) + { + ::rtl::OUString aUIEntry( aUrls[ nURLIdx ] ); + aUIEntry += ::rtl::OUString::valueOf( (sal_Unicode)'\t' ); + aUIEntry += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*" ) ); + SvLBoxEntry* pEntry = m_aPasswordsLB.InsertEntry( aUIEntry ); + pEntry->SetUserData( (void*)(nCount++) ); + } } } catch( uno::Exception& ) @@ -230,22 +251,29 @@ IMPL_LINK( WebConnectionInfoDialog, RemovePasswordHdl, PushButton*, EMPTYARG ) { try { - uno::Reference< task::XPasswordContainer > xPasswdContainer( - comphelper::getProcessServiceFactory()->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ), - uno::UNO_QUERY_THROW ); - - uno::Reference< task::XInteractionHandler > xInteractionHandler( - comphelper::getProcessServiceFactory()->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.InteractionHandler" ) ) ), - uno::UNO_QUERY_THROW ); - SvLBoxEntry* pEntry = m_aPasswordsLB.GetCurEntry(); if ( pEntry ) { ::rtl::OUString aURL = m_aPasswordsLB.GetEntryText( pEntry, 0 ); ::rtl::OUString aUserName = m_aPasswordsLB.GetEntryText( pEntry, 1 ); - xPasswdContainer->removePersistent( aURL, aUserName ); + + uno::Reference< task::XPasswordContainer > xPasswdContainer( + comphelper::getProcessServiceFactory()->createInstance( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.task.PasswordContainer" ) ) ), + uno::UNO_QUERY_THROW ); + + sal_Int32 nPos = (sal_Int32)(sal_IntPtr)pEntry->GetUserData(); + if ( nPos < m_nPos ) + { + xPasswdContainer->removePersistent( aURL, aUserName ); + } + else + { + uno::Reference< task::XUrlContainer > xUrlContainer( + xPasswdContainer, uno::UNO_QUERY_THROW ); + xUrlContainer->removeUrl( aURL ); + } m_aPasswordsLB.RemoveEntry( pEntry ); } } @@ -262,11 +290,20 @@ IMPL_LINK( WebConnectionInfoDialog, RemoveAllPasswordsHdl, PushButton*, EMPTYARG { uno::Reference< task::XPasswordContainer > xPasswdContainer( comphelper::getProcessServiceFactory()->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.task.PasswordContainer" ) ) ), uno::UNO_QUERY_THROW ); // should the master password be requested before? xPasswdContainer->removeAllPersistent(); + + uno::Reference< task::XUrlContainer > xUrlContainer( + xPasswdContainer, uno::UNO_QUERY_THROW ); + uno::Sequence< rtl::OUString > aUrls + = xUrlContainer->getUrls( sal_True /* OnlyPersistent */ ); + for ( sal_Int32 nURLIdx = 0; nURLIdx < aUrls.getLength(); nURLIdx++ ) + xUrlContainer->removeUrl( aUrls[ nURLIdx ] ); + m_aPasswordsLB.Clear(); } catch( uno::Exception& ) @@ -280,34 +317,38 @@ IMPL_LINK( WebConnectionInfoDialog, ChangePasswordHdl, PushButton*, EMPTYARG ) { try { - uno::Reference< task::XPasswordContainer > xPasswdContainer( - comphelper::getProcessServiceFactory()->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.PasswordContainer" ) ) ), - uno::UNO_QUERY_THROW ); - - uno::Reference< task::XInteractionHandler > xInteractionHandler( - comphelper::getProcessServiceFactory()->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.task.InteractionHandler" ) ) ), - uno::UNO_QUERY_THROW ); - - SvLBoxEntry* pEntry = m_aPasswordsLB.GetCurEntry(); if ( pEntry ) { ::rtl::OUString aURL = m_aPasswordsLB.GetEntryText( pEntry, 0 ); ::rtl::OUString aUserName = m_aPasswordsLB.GetEntryText( pEntry, 1 ); - ::comphelper::DocPasswordRequest* pPasswordRequest = new ::comphelper::DocPasswordRequest( - ::comphelper::DocPasswordRequestType_STANDARD, task::PasswordRequestMode_PASSWORD_CREATE, aURL ); - + ::comphelper::DocPasswordRequest* pPasswordRequest + = new ::comphelper::DocPasswordRequest( + ::comphelper::DocPasswordRequestType_STANDARD, + task::PasswordRequestMode_PASSWORD_CREATE, aURL ); uno::Reference< task::XInteractionRequest > rRequest( pPasswordRequest ); + + uno::Reference< task::XInteractionHandler > xInteractionHandler( + comphelper::getProcessServiceFactory()->createInstance( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.task.InteractionHandler" ) ) ), + uno::UNO_QUERY_THROW ); xInteractionHandler->handle( rRequest ); + if ( pPasswordRequest->isPassword() ) { String aNewPass = pPasswordRequest->getPassword(); uno::Sequence< ::rtl::OUString > aPasswd( 1 ); aPasswd[0] = aNewPass; - xPasswdContainer->addPersistent( aURL, aUserName, aPasswd, xInteractionHandler ); + + uno::Reference< task::XPasswordContainer > xPasswdContainer( + comphelper::getProcessServiceFactory()->createInstance( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.task.PasswordContainer" ) ) ), + uno::UNO_QUERY_THROW ); + xPasswdContainer->addPersistent( + aURL, aUserName, aPasswd, xInteractionHandler ); } } } @@ -329,7 +370,11 @@ IMPL_LINK( WebConnectionInfoDialog, EntrySelectedHdl, void*, EMPTYARG ) else { m_aRemoveBtn.Enable( TRUE ); - m_aChangeBtn.Enable( TRUE ); + + // url container entries (-> use system credentials) have + // no password + sal_Int32 nPos = (sal_Int32)(sal_IntPtr)pEntry->GetUserData(); + m_aChangeBtn.Enable( nPos < m_nPos ); } return 0; diff --git a/svx/source/cui/webconninfo.hxx b/svx/source/cui/webconninfo.hxx index 775d5072393c..f24b9f0dd4c8 100644 --- a/svx/source/cui/webconninfo.hxx +++ b/svx/source/cui/webconninfo.hxx @@ -65,6 +65,7 @@ namespace svx FixedLine m_aButtonsFL; CancelButton m_aCloseBtn; HelpButton m_aHelpBtn; + sal_Int32 m_nPos; DECL_LINK( HeaderBarClickedHdl, SvxSimpleTable* ); DECL_LINK( RemovePasswordHdl, PushButton* ); diff --git a/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx b/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx index 8f447de5b51c..022b7505cb44 100644 --- a/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx @@ -44,7 +44,7 @@ #include <typeinfo> #define BOOST_SPIRIT_DEBUG #endif -#include <boost/spirit/core.hpp> +#include <boost/spirit/include/classic_core.hpp> #if (OSL_DEBUG_LEVEL > 0) #include <iostream> diff --git a/svx/source/customshapes/makefile.mk b/svx/source/customshapes/makefile.mk index 9940a9bb21bc..edd6f7d33ed0 100644 --- a/svx/source/customshapes/makefile.mk +++ b/svx/source/customshapes/makefile.mk @@ -49,6 +49,8 @@ ENABLE_EXCEPTIONS=TRUE NOOPTFILES= $(SLO)$/EnhancedCustomShapeFunctionParser.obj .ENDIF +ENVCFLAGS += -DBOOST_SPIRIT_USE_OLD_NAMESPACE + # --- Files ------------------------------------- LIB1TARGET= $(SLB)$/$(TARGET)-core.lib diff --git a/svx/source/dialog/langbox.cxx b/svx/source/dialog/langbox.cxx index 16e04efeefbe..c196178a4d16 100644 --- a/svx/source/dialog/langbox.cxx +++ b/svx/source/dialog/langbox.cxx @@ -37,8 +37,9 @@ #include <com/sun/star/linguistic2/XLinguServiceManager.hdl> #endif #include <com/sun/star/linguistic2/XAvailableLocales.hpp> +#include <com/sun/star/i18n/ScriptType.hpp> #include <linguistic/misc.hxx> -#include<rtl/ustring.hxx> +#include <rtl/ustring.hxx> #include <unotools/localedatawrapper.hxx> #include <svtools/langtab.hxx> @@ -315,6 +316,13 @@ void SvxLanguageBox::SetLanguageList( INT16 nLangList, USHORT SvxLanguageBox::InsertLanguage( const LanguageType nLangType, USHORT nPos ) { + return ImplInsertLanguage( nLangType, nPos, ::com::sun::star::i18n::ScriptType::WEAK ); +} + +//------------------------------------------------------------------------ + +USHORT SvxLanguageBox::ImplInsertLanguage( const LanguageType nLangType, USHORT nPos, sal_Int16 nType ) +{ LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( nLangType); // For obsolete and to be replaced languages check whether an entry of the // replacement already exists and if so don't add an entry with identical @@ -329,6 +337,15 @@ USHORT SvxLanguageBox::InsertLanguage( const LanguageType nLangType, USHORT nPos String aStrEntry = m_pLangTable->GetString( nLang ); if (LANGUAGE_NONE == nLang && m_bHasLangNone && m_bLangNoneIsLangAll) aStrEntry = m_aAllString; + + LanguageType nRealLang = nLang; + if (nRealLang == LANGUAGE_SYSTEM) + { + nRealLang = MsLangId::resolveSystemLanguageByScriptType(nRealLang, nType); + aStrEntry.AppendAscii(" - "); + aStrEntry.Append(m_pLangTable->GetString( nRealLang )); + } + aStrEntry = ApplyLreOrRleEmbedding( aStrEntry ); USHORT nAt = 0; @@ -343,7 +360,7 @@ USHORT SvxLanguageBox::InsertLanguage( const LanguageType nLangType, USHORT nPos m_pSpellUsedLang = new Sequence< INT16 >( xSpell->getLanguages() ); } bFound = m_pSpellUsedLang ? - lcl_SeqHasLang( *m_pSpellUsedLang, nLang ) : FALSE; + lcl_SeqHasLang( *m_pSpellUsedLang, nRealLang ) : FALSE; nAt = ImplInsertImgEntry( aStrEntry, nPos, bFound ); } @@ -356,6 +373,13 @@ USHORT SvxLanguageBox::InsertLanguage( const LanguageType nLangType, USHORT nPos //------------------------------------------------------------------------ +USHORT SvxLanguageBox::InsertDefaultLanguage( sal_Int16 nType, USHORT nPos ) +{ + return ImplInsertLanguage( LANGUAGE_SYSTEM, nPos, nType ); +} + +//------------------------------------------------------------------------ + USHORT SvxLanguageBox::InsertLanguage( const LanguageType nLangType, BOOL bCheckEntry, USHORT nPos ) { diff --git a/svx/source/intro/intro_tmpl.hrc b/svx/source/intro/intro_tmpl.hrc index 0f1b36e0c9f6..ad3a628213be 100644 --- a/svx/source/intro/intro_tmpl.hrc +++ b/svx/source/intro/intro_tmpl.hrc @@ -269,9 +269,9 @@ ItemList = \ < "Darin Fisher" ; > ; \ < "Nicole M. Follet-Dunn" ; > ; \ < "Kenneth Foskey" ; > ; \ - < "Peter Frandsen" ; > ; \ < "Duncan Foster" ; > ; \ < "Tim Foster" ; > ; \ + < "Peter Frandsen" ; > ; \ < "Gary Frederick" ; > ; \ < "Nils Fuhrmann" ; > ; \ < "Jan Funken" ; > ; \ diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx index d4dd02f74a3b..ca6333753769 100644 --- a/svx/source/items/numfmtsh.cxx +++ b/svx/source/items/numfmtsh.cxx @@ -45,6 +45,7 @@ #include <svtools/langtab.hxx> #include <vcl/svapp.hxx> +#include <comphelper/processfactory.hxx> #include <svx/numfmtsh.hxx> // class SvxNumberFormatShell -------------------------------------------- @@ -1523,22 +1524,22 @@ String SvxNumberFormatShell::GetStandardName() const return pFormatter->GetStandardName( eCurLanguage); } -void SvxNumberFormatShell::GetCurrencySymbols(SvStringsDtor& rList,const XubString& rStrEurope, sal_uInt16* pPos) +void SvxNumberFormatShell::GetCurrencySymbols( SvStringsDtor& rList, sal_uInt16* pPos ) { const NfCurrencyEntry* pTmpCurrencyEntry=SvNumberFormatter::MatchSystemCurrency(); sal_Bool bFlag=(pTmpCurrencyEntry==NULL); - GetCurrencySymbols(rList,rStrEurope, bFlag); + GetCurrencySymbols( rList, bFlag); if(pPos!=NULL) { const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable(); - sal_uInt16 nCount=rCurrencyTable.Count(); + sal_uInt16 nTableCount=rCurrencyTable.Count(); *pPos=0; - nCount=aCurCurrencyList.Count(); + sal_uInt16 nCount=aCurCurrencyList.Count(); if(bFlag) { @@ -1549,8 +1550,9 @@ void SvxNumberFormatShell::GetCurrencySymbols(SvStringsDtor& rList,const XubStri { for(sal_uInt16 i=1;i<nCount;i++) { - if(aCurCurrencyList[i]!=(sal_uInt16)-1 && - pTmpCurrencyEntry==rCurrencyTable[aCurCurrencyList[i]]) + const sal_uInt16 j = aCurCurrencyList[i]; + if (j != (sal_uInt16)-1 && j < nTableCount && + pTmpCurrencyEntry == rCurrencyTable[j]) { *pPos=i; nCurCurrencyEntryPos=i; @@ -1562,7 +1564,7 @@ void SvxNumberFormatShell::GetCurrencySymbols(SvStringsDtor& rList,const XubStri } -void SvxNumberFormatShell::GetCurrencySymbols(SvStringsDtor& rList,const XubString& /*rStrEurope*/, sal_Bool bFlag) +void SvxNumberFormatShell::GetCurrencySymbols( SvStringsDtor& rList, sal_Bool bFlag ) { aCurCurrencyList.Remove(0,aCurCurrencyList.Count()); @@ -1574,9 +1576,9 @@ void SvxNumberFormatShell::GetCurrencySymbols(SvStringsDtor& rList,const XubStri sal_uInt16 nStart=1; sal_uInt16 i,j; - XubString aString(rCurrencyTable[0]->GetSymbol()); + XubString aString( ApplyLreOrRleEmbedding( rCurrencyTable[0]->GetSymbol())); aString += sal_Unicode(' '); - aString += pLanguageTable->GetString(rCurrencyTable[0]->GetLanguage()); + aString += ApplyLreOrRleEmbedding( pLanguageTable->GetString( rCurrencyTable[0]->GetLanguage())); WSStringPtr pStr = new XubString(aString); rList.Insert( pStr,rList.Count()); @@ -1591,41 +1593,54 @@ void SvxNumberFormatShell::GetCurrencySymbols(SvStringsDtor& rList,const XubStri ++nStart; } - for(i=1;i<nCount;i++) - { - XubString _aString(rCurrencyTable[i]->GetSymbol()); - _aString += sal_Unicode(' '); - _aString += pLanguageTable->GetString(rCurrencyTable[i]->GetLanguage()); + CollatorWrapper aCollator( ::comphelper::getProcessServiceFactory()); + aCollator.loadDefaultCollator( Application::GetSettings().GetLocale(), 0); - pStr = new XubString(_aString); + const String aTwoSpace( RTL_CONSTASCII_USTRINGPARAM( " ")); + for(i=1;i<nCount;i++) + { + XubString aStr( ApplyLreOrRleEmbedding( rCurrencyTable[i]->GetBankSymbol())); + aStr += aTwoSpace; + aStr += ApplyLreOrRleEmbedding( rCurrencyTable[i]->GetSymbol()); + aStr += aTwoSpace; + aStr += ApplyLreOrRleEmbedding( pLanguageTable->GetString( rCurrencyTable[i]->GetLanguage())); + + pStr = new XubString(aStr); +#if 0 + fprintf( stderr, "currency entry: %s\n", ByteString( *pStr, RTL_TEXTENCODING_UTF8).GetBuffer()); +#endif for(j=nStart;j<rList.Count();j++) { const StringPtr pTestStr=rList[j]; - - if(*pTestStr>aString) break; + if (aCollator.compareString( *pStr, *pTestStr) < 0) + break; // insert before first greater than } rList.Insert( pStr,j); aCurCurrencyList.Insert(i,j); } + // Append ISO codes to symbol list. + // XXX If this is to be changed, various other places would had to be + // adapted that assume this order! sal_uInt16 nCont = rList.Count(); for(i=1;i<nCount;i++) { - sal_Bool bTest=sal_True; - pStr = new XubString(rCurrencyTable[i]->GetBankSymbol()); + bool bInsert = true; + pStr = new XubString( ApplyLreOrRleEmbedding( rCurrencyTable[i]->GetBankSymbol())); - for(j=nCont;j<rList.Count();j++) + for (j = nCont; j < rList.Count() && bInsert; ++j) { const StringPtr pTestStr=rList[j]; if(*pTestStr==*pStr) - bTest=sal_False; + bInsert = false; else - if(*pTestStr>*pStr) break; + if (aCollator.compareString( *pStr, *pTestStr) < 0) + break; // insert before first greater than } - if(bTest) + if(bInsert) { rList.Insert( pStr,j); aCurCurrencyList.Insert(i,j); diff --git a/svx/source/mnuctrls/clipboardctl.cxx b/svx/source/mnuctrls/clipboardctl.cxx index 82dc919bb729..3cd538e4c079 100644 --- a/svx/source/mnuctrls/clipboardctl.cxx +++ b/svx/source/mnuctrls/clipboardctl.cxx @@ -143,16 +143,6 @@ void SvxClipBoardControl::StateChanged( USHORT nSID, SfxItemState eState, const GetToolBox().SetItemBits( GetId(), GetToolBox().GetItemBits( GetId() ) & ~TIB_DROPDOWN ); GetToolBox().Invalidate( GetToolBox().GetItemRect( GetId() ) ); } - #ifdef UNIX - // #b6673979# enable some slots hardly, because UNIX clipboard does not notify all changes - // Can be removed if follow up task will be fixed directly within applications. - else - if ( SID_PASTE == nSID ) - { - bDisabled = false; - GetToolBox().EnableItem( GetId(), true ); - } - #endif else { // enable the item as a whole diff --git a/svx/source/options/optgenrl.src b/svx/source/options/optgenrl.src index 52e031f1099f..cff6f8d4216c 100644 --- a/svx/source/options/optgenrl.src +++ b/svx/source/options/optgenrl.src @@ -74,6 +74,14 @@ TabPage RID_SFXPAGE_GENERAL Hide = TRUE; Text [ en-US ] = "Last Name/First name/Father's name/Initials"; }; + FixedText FT_NAME_EASTERN + { + Pos = MAP_APPFONT ( LEFT , FLINE ( 1 ) ) ; + Size = MAP_APPFONT ( MID-LEFT-2 , FLINEH ) ; + LeftLabel = TRUE ; + Hide = TRUE; + Text [ en-US ] = "Last/First ~name/Initials" ; + }; Edit ED_FATHERNAME { Border = TRUE ; diff --git a/svx/source/options/optsave.src b/svx/source/options/optsave.src index afa1c4b6d0c8..374f53ef618f 100644 --- a/svx/source/options/optsave.src +++ b/svx/source/options/optsave.src @@ -149,8 +149,9 @@ TabPage RID_SFXPAGE_SAVE DropDown = TRUE; StringList [ en-US ] = { - < "1.0/1.1 (OpenOffice.org 2.x)" ; 2 ; > ; - < "1.2 (recommended)" ; 3 ; > ; + < "1.0/1.1" ; 2 ; > ; + < "1.2" ; 4 ; > ; + < "1.2 Extended (recommended)"; 0x7fffffff ; > ; }; }; CheckBox BTN_NOPRETTYPRINTING @@ -219,7 +220,8 @@ TabPage RID_SFXPAGE_SAVE Pos = MAP_APPFONT ( 23 , 169 ) ; Size = MAP_APPFONT ( 239 , 8 ) ; Hide = TRUE; - Text [ en-US ] = "Not using ODF 1.2 may cause infomation to be lost."; + Text [ en-US ] = "Not using ODF 1.2 Extended may cause infomation to be lost."; + Text [ x-comment ] = "EN-US, the term 'extended' must not be translated."; }; Image IMG_ODF_WARNING { diff --git a/svx/source/sdr/attribute/sdrtextattribute.cxx b/svx/source/sdr/attribute/sdrtextattribute.cxx index 33c958fa6268..ae6204d15bef 100644 --- a/svx/source/sdr/attribute/sdrtextattribute.cxx +++ b/svx/source/sdr/attribute/sdrtextattribute.cxx @@ -57,12 +57,15 @@ namespace drawinglayer sal_Int32 aTextUpperDistance, sal_Int32 aTextRightDistance, sal_Int32 aTextLowerDistance, + SdrTextHorzAdjust aSdrTextHorzAdjust, + SdrTextVertAdjust aSdrTextVertAdjust, bool bContour, bool bFitToSize, bool bHideContour, bool bBlink, bool bScroll, - bool bInEditMode) + bool bInEditMode, + bool bFixedCellHeight) : mpSdrText(&rSdrText), maOutlinerParaObject(rOutlinerParaObject), mpSdrFormTextAttribute(0), @@ -71,12 +74,15 @@ namespace drawinglayer maTextRightDistance(aTextRightDistance), maTextLowerDistance(aTextLowerDistance), maPropertiesVersion(0), + maSdrTextHorzAdjust(aSdrTextHorzAdjust), + maSdrTextVertAdjust(aSdrTextVertAdjust), mbContour(bContour), mbFitToSize(bFitToSize), mbHideContour(bHideContour), mbBlink(bBlink), mbScroll(bScroll), - mbInEditMode(bInEditMode) + mbInEditMode(bInEditMode), + mbFixedCellHeight(bFixedCellHeight) { if(XFT_NONE != eFormTextStyle) { @@ -108,12 +114,16 @@ namespace drawinglayer maTextUpperDistance(rCandidate.getTextUpperDistance()), maTextRightDistance(rCandidate.getTextRightDistance()), maTextLowerDistance(rCandidate.getTextLowerDistance()), + maPropertiesVersion(rCandidate.getPropertiesVersion()), + maSdrTextHorzAdjust(rCandidate.getSdrTextHorzAdjust()), + maSdrTextVertAdjust(rCandidate.getSdrTextVertAdjust()), mbContour(rCandidate.isContour()), mbFitToSize(rCandidate.isFitToSize()), mbHideContour(rCandidate.isHideContour()), mbBlink(rCandidate.isBlink()), mbScroll(rCandidate.isScroll()), - mbInEditMode(rCandidate.isInEditMode()) + mbInEditMode(rCandidate.isInEditMode()), + mbFixedCellHeight(rCandidate.isFixedCellHeight()) { if(rCandidate.getSdrFormTextAttribute()) { @@ -142,36 +152,52 @@ namespace drawinglayer maTextUpperDistance = rCandidate.getTextUpperDistance(); maTextRightDistance = rCandidate.getTextRightDistance(); maTextLowerDistance = rCandidate.getTextLowerDistance(); + maPropertiesVersion = rCandidate.getPropertiesVersion(); + + maSdrTextHorzAdjust = rCandidate.getSdrTextHorzAdjust(); + maSdrTextVertAdjust = rCandidate.getSdrTextVertAdjust(); + mbContour = rCandidate.isContour(); mbFitToSize = rCandidate.isFitToSize(); mbHideContour = rCandidate.isHideContour(); mbBlink = rCandidate.isBlink(); mbScroll = rCandidate.isScroll(); mbInEditMode = rCandidate.isInEditMode(); + mbFixedCellHeight = rCandidate.isFixedCellHeight(); return *this; } bool SdrTextAttribute::operator==(const SdrTextAttribute& rCandidate) const { - return (getOutlinerParaObject() == rCandidate.getOutlinerParaObject() + return ( + // compares OPO and it's contents, but traditionally not the RedLining + // which is not seen as model, but as temporary information + getOutlinerParaObject() == rCandidate.getOutlinerParaObject() + // #i102062# for primitive visualisation, the WrongList (SpellChecking) // is important, too, so use isWrongListEqual since there is no WrongList // comparison in the regular OutlinerParaObject compare (since it's // not-persistent data) && getOutlinerParaObject().isWrongListEqual(rCandidate.getOutlinerParaObject()) + && pointerOrContentEqual(getSdrFormTextAttribute(), rCandidate.getSdrFormTextAttribute()) && getTextLeftDistance() == rCandidate.getTextLeftDistance() && getTextUpperDistance() == rCandidate.getTextUpperDistance() && getTextRightDistance() == rCandidate.getTextRightDistance() && getTextLowerDistance() == rCandidate.getTextLowerDistance() && getPropertiesVersion() == rCandidate.getPropertiesVersion() + + && getSdrTextHorzAdjust() == rCandidate.getSdrTextHorzAdjust() + && getSdrTextVertAdjust() == rCandidate.getSdrTextVertAdjust() + && isContour() == rCandidate.isContour() && isFitToSize() == rCandidate.isFitToSize() && isHideContour() == rCandidate.isHideContour() && isBlink() == rCandidate.isBlink() && isScroll() == rCandidate.isScroll() - && isInEditMode() == rCandidate.isInEditMode()); + && isInEditMode() == rCandidate.isInEditMode() + && isFixedCellHeight() == rCandidate.isFixedCellHeight()); } void SdrTextAttribute::getBlinkTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList) const diff --git a/svx/source/sdr/contact/viewcontactofgraphic.cxx b/svx/source/sdr/contact/viewcontactofgraphic.cxx index b083a1014299..6a92cb27ff8c 100644 --- a/svx/source/sdr/contact/viewcontactofgraphic.cxx +++ b/svx/source/sdr/contact/viewcontactofgraphic.cxx @@ -305,6 +305,9 @@ namespace sdr pSdrText, *pOPO, aTextRangeTransform, + SDRTEXTHORZADJUST_LEFT, + SDRTEXTVERTADJUST_TOP, + false, false, false, false); diff --git a/svx/source/sdr/overlay/overlaymanagerbuffered.cxx b/svx/source/sdr/overlay/overlaymanagerbuffered.cxx index 2b664e816d42..3fedc40f37cf 100644 --- a/svx/source/sdr/overlay/overlaymanagerbuffered.cxx +++ b/svx/source/sdr/overlay/overlaymanagerbuffered.cxx @@ -39,6 +39,7 @@ #include <vcl/bitmap.hxx> #include <tools/stream.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> +#include <vcl/cursor.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -255,15 +256,21 @@ namespace sdr maBufferRememberedRangePixel.getMaxX(), maBufferRememberedRangePixel.getMaxY()); aBufferRememberedRangeLogic.transform(getOutputDevice().GetInverseViewTransformation()); + // prepare cursor handling const bool bTargetIsWindow(OUTDEV_WINDOW == rmOutputDevice.GetOutDevType()); - Cursor* pCursor = 0; + bool bCursorWasEnabled(false); - // #i75172# switch off VCL cursor during overlay refresh + // #i80730# switch off VCL cursor during overlay refresh if(bTargetIsWindow) { Window& rWindow = static_cast< Window& >(rmOutputDevice); - pCursor = rWindow.GetCursor(); - rWindow.SetCursor(0); + Cursor* pCursor = rWindow.GetCursor(); + + if(pCursor && pCursor->IsVisible()) + { + pCursor->Hide(); + bCursorWasEnabled = true; + } } if(DoRefreshWithPreRendering()) @@ -363,49 +370,19 @@ namespace sdr OverlayManager::ImpDrawMembers(aBufferRememberedRangeLogic, getOutputDevice()); } - // VCL hack for transparent child windows - // Problem is e.g. a radiobuttion form control in life mode. The used window - // is a transparence vcl childwindow. This flag only allows the parent window to - // paint into the child windows area, but there is no mechanism which takes - // care for a repaint of the child window. A transparent child window is NOT - // a window which always keeps it's content consistent over the parent, but it's - // more like just a paint flag for the parent. - // To get the update, the windows in question are updated manulally here. - if(bTargetIsWindow) + // #i80730# restore visibility of VCL cursor + if(bCursorWasEnabled) { Window& rWindow = static_cast< Window& >(rmOutputDevice); + Cursor* pCursor = rWindow.GetCursor(); - if(rWindow.IsChildTransparentModeEnabled() && rWindow.GetChildCount()) + if(pCursor) { - const Rectangle aRegionRectanglePixel( - maBufferRememberedRangePixel.getMinX(), maBufferRememberedRangePixel.getMinY(), - maBufferRememberedRangePixel.getMaxX(), maBufferRememberedRangePixel.getMaxY()); - - for(sal_uInt16 a(0); a < rWindow.GetChildCount(); a++) - { - Window* pCandidate = rWindow.GetChild(a); - - if(pCandidate && pCandidate->IsPaintTransparent()) - { - const Rectangle aCandidatePosSizePixel(pCandidate->GetPosPixel(), pCandidate->GetSizePixel()); - - if(aCandidatePosSizePixel.IsOver(aRegionRectanglePixel)) - { - pCandidate->Invalidate(INVALIDATE_NOTRANSPARENT|INVALIDATE_CHILDREN); - pCandidate->Update(); - } - } - } + // check if cursor still exists. It may have been deleted from someone + pCursor->Show(); } } - // #i75172# restore VCL cursor - if(bTargetIsWindow) - { - Window& rWindow = static_cast< Window& >(rmOutputDevice); - rWindow.SetCursor(pCursor); - } - // forget remembered Region maBufferRememberedRangePixel.reset(); } diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx index 277ee70f82ca..4e57166b4723 100644 --- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx +++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx @@ -76,6 +76,7 @@ #include <drawinglayer/attribute/sdrattribute3d.hxx> #include <drawinglayer/attribute/sdrallattribute3d.hxx> #include <svx/rectenum.hxx> +#include <svx/sdtfchim.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -519,7 +520,7 @@ namespace drawinglayer } } - const SdrFitToSizeType eFit = rTextObj.GetFitToSize(); + const SdrFitToSizeType eFit(rTextObj.GetFitToSize()); const SdrTextAniKind eAniKind(rTextObj.GetTextAniKind()); pRetval = new attribute::SdrTextAttribute( @@ -530,12 +531,15 @@ namespace drawinglayer pUpper ? *pUpper : rTextObj.GetTextUpperDistance(), pRight ? *pRight : rTextObj.GetTextRightDistance(), pLower ? *pLower : rTextObj.GetTextLowerDistance(), + rTextObj.GetTextHorizontalAdjust(rSet), + rTextObj.GetTextVerticalAdjust(rSet), ((const SdrTextContourFrameItem&)rSet.Get(SDRATTR_TEXT_CONTOURFRAME)).GetValue(), (SDRTEXTFIT_PROPORTIONAL == eFit || SDRTEXTFIT_ALLLINES == eFit), ((const XFormTextHideFormItem&)rSet.Get(XATTR_FORMTXTHIDEFORM)).GetValue(), SDRTEXTANI_BLINK == eAniKind, SDRTEXTANI_SCROLL == eAniKind || SDRTEXTANI_ALTERNATE == eAniKind || SDRTEXTANI_SLIDE == eAniKind, - bInEditMode); + bInEditMode, + ((const SdrTextFixedCellHeightItem&)rSet.Get(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue()); } return pRetval; diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx index 9666bd2c1ac1..09769a2a013e 100644 --- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx +++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx @@ -282,7 +282,8 @@ namespace drawinglayer pNew = new SdrStretchTextPrimitive2D( &rText.getSdrText(), rText.getOutlinerParaObject(), - aAnchorTransform); + aAnchorTransform, + rText.isFixedCellHeight()); } else // text in range { @@ -291,6 +292,9 @@ namespace drawinglayer &rText.getSdrText(), rText.getOutlinerParaObject(), aAnchorTransform, + rText.getSdrTextHorzAdjust(), + rText.getSdrTextVertAdjust(), + rText.isFixedCellHeight(), rText.isScroll(), bCellText, bWordWrap); diff --git a/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx index f515b9b6a5e9..94e59f79c3de 100644 --- a/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx @@ -129,8 +129,11 @@ namespace drawinglayer &pTextAttribute->getSdrText(), pTextAttribute->getOutlinerParaObject(), aTextMatrix, + SDRTEXTHORZADJUST_CENTER, + SDRTEXTVERTADJUST_CENTER, pTextAttribute->isScroll(), false, + false, false); aTextRange = pBlockText->getB2DRange(aViewInformation); } diff --git a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx index 6c665cbef4c9..25b39ebb07d5 100644 --- a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx +++ b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx @@ -37,6 +37,7 @@ #include <basegfx/polygon/b2dpolygontools.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> #include <drawinglayer/primitive2d/hittestprimitive2d.hxx> +#include <vcl/lazydelete.hxx> ////////////////////////////////////////////////////////////////////////////// // helper methods @@ -47,11 +48,11 @@ namespace drawinglayer { BitmapEx createDefaultCross_3x3(const basegfx::BColor& rBColor) { - static BitmapEx* pRetVal = NULL; + static vcl::DeleteOnDeinit< BitmapEx > aRetVal(0); static basegfx::BColor aColor; ::osl::Mutex m_mutex; - if(pRetVal == NULL || rBColor != aColor) + if(!aRetVal.get() || rBColor != aColor) { // copy values aColor = rBColor; @@ -81,23 +82,21 @@ namespace drawinglayer aContent.ReleaseAccess(pWContent); aMask.ReleaseAccess(pWMask); - if( pRetVal ) - delete pRetVal; - - pRetVal = new BitmapEx(aContent, aMask); + // create and exchange at aRetVal + delete aRetVal.set(new BitmapEx(aContent, aMask)); } - return *pRetVal; + return aRetVal.get() ? *aRetVal.get() : BitmapEx(); } BitmapEx createDefaultGluepoint_7x7(const basegfx::BColor& rBColorA, const basegfx::BColor& rBColorB) { - static BitmapEx* pRetVal = NULL; + static vcl::DeleteOnDeinit< BitmapEx > aRetVal(0); static basegfx::BColor aColorA; static basegfx::BColor aColorB; ::osl::Mutex m_mutex; - if(pRetVal == NULL || rBColorA != aColorA || rBColorB != aColorB) + if(!aRetVal.get() || rBColorA != aColorA || rBColorB != aColorB) { // copy values aColorA = rBColorA; @@ -171,13 +170,11 @@ namespace drawinglayer aContent.ReleaseAccess(pWContent); aMask.ReleaseAccess(pWMask); - if( pRetVal ) - delete pRetVal; - - pRetVal = new BitmapEx(aContent, aMask); + // create and exchange at aRetVal + delete aRetVal.set(new BitmapEx(aContent, aMask)); } - return *pRetVal; + return aRetVal.get() ? *aRetVal.get() : BitmapEx(); } // #i99123# diff --git a/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx index 0cad266f69d1..748270c36977 100644 --- a/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx @@ -116,7 +116,6 @@ namespace drawinglayer mnLastPageNumber(0), mnLastPageCount(0), maLastTextBackgroundColor(), - mbLastSpellCheck(false), mbContainsPageField(false), mbContainsPageCountField(false), mbContainsOtherFields(false) @@ -137,7 +136,13 @@ namespace drawinglayer { const SdrTextPrimitive2D& rCompare = (SdrTextPrimitive2D&)rPrimitive; - return (getOutlinerParaObject() == rCompare.getOutlinerParaObject()); + return ( + + // compare OPO and content, but not WrongList + getOutlinerParaObject() == rCompare.getOutlinerParaObject() + + // also compare WrongList (not-persistent data, but visualized) + && getOutlinerParaObject().isWrongListEqual(rCompare.getOutlinerParaObject())); } return false; @@ -145,9 +150,6 @@ namespace drawinglayer Primitive2DSequence SdrTextPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { - const bool bCurrentSpellCheck(getSdrText() - ? getSdrText()->GetObject().impCheckSpellCheckForDecomposeTextPrimitive() - : false); uno::Reference< drawing::XDrawPage > xCurrentlyVisualizingPage; bool bCurrentlyVisualizingPageIsSet(false); Color aNewTextBackgroundColor; @@ -157,10 +159,10 @@ namespace drawinglayer if(getLocalDecomposition().hasElements()) { - bool bDoDelete(getLastSpellCheck() != bCurrentSpellCheck); + bool bDoDelete(false); // check visualized page - if(!bDoDelete && (mbContainsPageField || mbContainsPageCountField || mbContainsOtherFields)) + if(mbContainsPageField || mbContainsPageCountField || mbContainsOtherFields) { // get visualized page and remember xCurrentlyVisualizingPage = rViewInformation.getVisualizedPage(); @@ -236,7 +238,6 @@ namespace drawinglayer aNewTextBackgroundColor = rDrawOutliner.GetBackgroundColor(); } - const_cast< SdrTextPrimitive2D* >(this)->setLastSpellCheck(bCurrentSpellCheck); const_cast< SdrTextPrimitive2D* >(this)->mxLastVisualizingPage = xCurrentlyVisualizingPage; const_cast< SdrTextPrimitive2D* >(this)->mnLastPageNumber = nCurrentlyValidPageNumber; const_cast< SdrTextPrimitive2D* >(this)->mnLastPageCount = nCurrentlyValidPageCount; @@ -258,15 +259,7 @@ namespace drawinglayer Primitive2DSequence SdrContourTextPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const { Primitive2DSequence aRetval; - const bool bCurrentSpellCheck(getSdrText() - ? getSdrText()->GetObject().impDecomposeContourTextPrimitive(aRetval, *this, aViewInformation) - : false); - - if(getLastSpellCheck() != bCurrentSpellCheck) - { - // remember last spell check state; this is part of the decomposition source data definition - const_cast< SdrContourTextPrimitive2D* >(this)->setLastSpellCheck(bCurrentSpellCheck); - } + getSdrText()->GetObject().impDecomposeContourTextPrimitive(aRetval, *this, aViewInformation); return encapsulateWithTextHierarchyBlockPrimitive2D(aRetval); } @@ -319,15 +312,7 @@ namespace drawinglayer Primitive2DSequence SdrPathTextPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const { Primitive2DSequence aRetval; - const bool bCurrentSpellCheck(getSdrText() - ? getSdrText()->GetObject().impDecomposePathTextPrimitive(aRetval, *this, aViewInformation) - : false); - - if(getLastSpellCheck() != bCurrentSpellCheck) - { - // remember last spell check state; this is part of the decomposition source data definition - const_cast< SdrPathTextPrimitive2D* >(this)->setLastSpellCheck(bCurrentSpellCheck); - } + getSdrText()->GetObject().impDecomposePathTextPrimitive(aRetval, *this, aViewInformation); return encapsulateWithTextHierarchyBlockPrimitive2D(aRetval); } @@ -383,15 +368,7 @@ namespace drawinglayer Primitive2DSequence SdrBlockTextPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const { Primitive2DSequence aRetval; - const bool bCurrentSpellCheck(getSdrText() - ? getSdrText()->GetObject().impDecomposeBlockTextPrimitive(aRetval, *this, aViewInformation) - : false); - - if(getLastSpellCheck() != bCurrentSpellCheck) - { - // remember last spell check state; this is part of the decomposition source data definition - const_cast< SdrBlockTextPrimitive2D* >(this)->setLastSpellCheck(bCurrentSpellCheck); - } + getSdrText()->GetObject().impDecomposeBlockTextPrimitive(aRetval, *this, aViewInformation); return encapsulateWithTextHierarchyBlockPrimitive2D(aRetval); } @@ -400,11 +377,17 @@ namespace drawinglayer const SdrText* pSdrText, const OutlinerParaObject& rOutlinerParaObject, const basegfx::B2DHomMatrix& rTextRangeTransform, + SdrTextHorzAdjust aSdrTextHorzAdjust, + SdrTextVertAdjust aSdrTextVertAdjust, + bool bFixedCellHeight, bool bUnlimitedPage, bool bCellText, bool bWordWrap) : SdrTextPrimitive2D(pSdrText, rOutlinerParaObject), maTextRangeTransform(rTextRangeTransform), + maSdrTextHorzAdjust(aSdrTextHorzAdjust), + maSdrTextVertAdjust(aSdrTextVertAdjust), + mbFixedCellHeight(bFixedCellHeight), mbUnlimitedPage(bUnlimitedPage), mbCellText(bCellText), mbWordWrap(bWordWrap) @@ -418,6 +401,9 @@ namespace drawinglayer const SdrBlockTextPrimitive2D& rCompare = (SdrBlockTextPrimitive2D&)rPrimitive; return (getTextRangeTransform() == rCompare.getTextRangeTransform() + && getSdrTextHorzAdjust() == rCompare.getSdrTextHorzAdjust() + && getSdrTextVertAdjust() == rCompare.getSdrTextVertAdjust() + && isFixedCellHeight() == rCompare.isFixedCellHeight() && getUnlimitedPage() == rCompare.getUnlimitedPage() && getCellText() == rCompare.getCellText() && getWordWrap() == rCompare.getWordWrap()); @@ -432,6 +418,9 @@ namespace drawinglayer getSdrText(), getOutlinerParaObject(), rTransform * getTextRangeTransform(), + getSdrTextHorzAdjust(), + getSdrTextVertAdjust(), + isFixedCellHeight(), getUnlimitedPage(), getCellText(), getWordWrap()); @@ -452,15 +441,7 @@ namespace drawinglayer Primitive2DSequence SdrStretchTextPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const { Primitive2DSequence aRetval; - const bool bCurrentSpellCheck(getSdrText() - ? getSdrText()->GetObject().impDecomposeStretchTextPrimitive(aRetval, *this, aViewInformation) - : false); - - if(getLastSpellCheck() != bCurrentSpellCheck) - { - // remember last spell check state; this is part of the decomposition source data definition - const_cast< SdrStretchTextPrimitive2D* >(this)->setLastSpellCheck(bCurrentSpellCheck); - } + getSdrText()->GetObject().impDecomposeStretchTextPrimitive(aRetval, *this, aViewInformation); return encapsulateWithTextHierarchyBlockPrimitive2D(aRetval); } @@ -468,9 +449,11 @@ namespace drawinglayer SdrStretchTextPrimitive2D::SdrStretchTextPrimitive2D( const SdrText* pSdrText, const OutlinerParaObject& rOutlinerParaObject, - const basegfx::B2DHomMatrix& rTextRangeTransform) + const basegfx::B2DHomMatrix& rTextRangeTransform, + bool bFixedCellHeight) : SdrTextPrimitive2D(pSdrText, rOutlinerParaObject), - maTextRangeTransform(rTextRangeTransform) + maTextRangeTransform(rTextRangeTransform), + mbFixedCellHeight(bFixedCellHeight) { } @@ -480,7 +463,8 @@ namespace drawinglayer { const SdrStretchTextPrimitive2D& rCompare = (SdrStretchTextPrimitive2D&)rPrimitive; - return (getTextRangeTransform() == rCompare.getTextRangeTransform()); + return (getTextRangeTransform() == rCompare.getTextRangeTransform() + && isFixedCellHeight() == rCompare.isFixedCellHeight()); } return false; @@ -491,7 +475,8 @@ namespace drawinglayer return new SdrStretchTextPrimitive2D( getSdrText(), getOutlinerParaObject(), - rTransform * getTextRangeTransform()); + rTransform * getTextRangeTransform(), + isFixedCellHeight()); } // provide unique ID diff --git a/svx/source/stbctrls/stbctrls.src b/svx/source/stbctrls/stbctrls.src index 2d9b875d6c2a..74c7c78bc897 100644 --- a/svx/source/stbctrls/stbctrls.src +++ b/svx/source/stbctrls/stbctrls.src @@ -1,4 +1,4 @@ -/************************************************************************* +/************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -87,6 +87,11 @@ String RID_SVXSTR_XMLSEC_NO_SIG Text [ en-US ] = "Digital Signature: The document is not signed."; }; +String RID_SVXSTR_XMLSEC_SIG_CERT_OK_PARTIAL_SIG +{ + Text [ en-US ] = "Digital Signature: The document signature and the certificate are OK, but not all parts of the document are signed."; +}; + // PopupMenu ------------------------------------------------------------- Menu RID_SVXMNU_ZOOM { diff --git a/svx/source/stbctrls/xmlsecctrl.cxx b/svx/source/stbctrls/xmlsecctrl.cxx index a994df0900a6..890cde02e428 100644 --- a/svx/source/stbctrls/xmlsecctrl.cxx +++ b/svx/source/stbctrls/xmlsecctrl.cxx @@ -143,6 +143,9 @@ void XmlSecStatusBarControl::StateChanged( USHORT nSID, SfxItemState eState, con nResId = RID_SVXSTR_XMLSEC_SIG_NOT_OK; else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED ) nResId = RID_SVXSTR_XMLSEC_SIG_OK_NO_VERIFY; + else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK ) + nResId = RID_SVXSTR_XMLSEC_SIG_CERT_OK_PARTIAL_SIG; + GetStatusBar().SetQuickHelpText( GetId(), SVX_RESSTR( nResId ) ); } @@ -192,7 +195,8 @@ void XmlSecStatusBarControl::Paint( const UserDrawEvent& rUsrEvt ) ++aRect.Top(); pDev->DrawImage( aRect.TopLeft(), mpImpl->maImageBroken ); } - else if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED ) + else if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED + || mpImpl->mnState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK) { ++aRect.Top(); pDev->DrawImage( aRect.TopLeft(), mpImpl->maImageNotValidated ); diff --git a/svx/source/svdraw/svdcrtv.cxx b/svx/source/svdraw/svdcrtv.cxx index 341ce6dd90c0..6773b8edf6f5 100644 --- a/svx/source/svdraw/svdcrtv.cxx +++ b/svx/source/svdraw/svdcrtv.cxx @@ -831,7 +831,11 @@ void SdrCreateView::ShowCreateObj(/*OutputDevice* pOut, BOOL bFull*/) if(pCircObj && OBJ_CIRC != pCircObj->GetObjIdentifier()) { - bUseSolidDragging = false; + // #i103058# Allow SolidDragging with four points + if(aDragStat.GetPointAnz() < 4) + { + bUseSolidDragging = false; + } } } diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index e427e42d80ab..eb6412b20259 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -1135,11 +1135,20 @@ void SdrDragObjOwn::createSdrDragEntries() void SdrDragObjOwn::TakeSdrDragComment(XubString& rStr) const { - const SdrObject* pObj = GetDragObj(); - - if(pObj) + // #i103058# get info string from the clone preferred, the original will + // not be changed. For security, use original as fallback + if(mpClone) { - rStr = pObj->getSpecialDragComment(DragStat()); + rStr = mpClone->getSpecialDragComment(DragStat()); + } + else + { + const SdrObject* pObj = GetDragObj(); + + if(pObj) + { + rStr = pObj->getSpecialDragComment(DragStat()); + } } } diff --git a/svx/source/svdraw/svddrgv.cxx b/svx/source/svdraw/svddrgv.cxx index 69459b1bff35..8236ca1f19ac 100644 --- a/svx/source/svdraw/svddrgv.cxx +++ b/svx/source/svdraw/svddrgv.cxx @@ -282,7 +282,11 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl // #103894# Expand test for HDL_ANCHOR_TR BOOL bNotDraggable = (HDL_ANCHOR == eDragHdl || HDL_ANCHOR_TR == eDragHdl); - if(bDragHdl) + if(pHdl && (pHdl->GetKind() == HDL_SMARTTAG) && pForcedMeth ) + { + // just use the forced method for smart tags + } + else if(bDragHdl) { mpCurrentSdrDragMethod = new SdrDragMovHdl(*this); } diff --git a/svx/source/svdraw/svdfppt.cxx b/svx/source/svdraw/svdfppt.cxx index 35101eb2f418..d0b01f6a820f 100644 --- a/svx/source/svdraw/svdfppt.cxx +++ b/svx/source/svdraw/svdfppt.cxx @@ -39,6 +39,11 @@ #include <sot/storinfo.hxx> #include <sot/stg.hxx> #include <com/sun/star/embed/Aspects.hpp> +#include <com/sun/star/office/XAnnotation.hpp> +#include <com/sun/star/office/XAnnotationAccess.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/geometry/RealPoint2D.hpp> +#include <com/sun/star/util/DateTime.hpp> #include <unotools/streamwrap.hxx> @@ -2563,9 +2568,11 @@ sal_Bool SdrPowerPointImport::SeekToContentOfProgTag( sal_Int32 nVersion, SvStre sal_uInt32 nOldPos = rSt.Tell(); DffRecordHeader aProgTagsHd, aProgTagBinaryDataHd; - rSourceHd.SeekToContent( rSt ); - if ( SeekToRec( rSt, PPT_PST_ProgTags, rSourceHd.GetRecEndFilePos(), &aProgTagsHd ) ) + sal_Bool bFound = rSourceHd.nRecType == PPT_PST_ProgTags; + if ( !bFound ) + bFound = SeekToRec( rSt, PPT_PST_ProgTags, rSourceHd.GetRecEndFilePos(), &aProgTagsHd ); + if ( bFound ) { while( SeekToRec( rSt, PPT_PST_ProgBinaryTag, aProgTagsHd.GetRecEndFilePos(), &aProgTagBinaryDataHd ) ) { @@ -2860,6 +2867,75 @@ SdrPage* SdrPowerPointImport::MakeBlancPage( sal_Bool bMaster ) const return pRet; } +void ImportComment10( SvxMSDffManager& rMan, SvStream& rStCtrl, SdrPage* pPage, DffRecordHeader& rComment10Hd ) +{ + rtl::OUString sAuthor; + rtl::OUString sText; + rtl::OUString sInitials; + + sal_Int32 nIndex = 0; + util::DateTime aDateTime; + sal_Int32 nPosX = 0; + sal_Int32 nPosY = 0; + + while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < rComment10Hd.GetRecEndFilePos() ) ) + { + DffRecordHeader aCommentHd; + rStCtrl >> aCommentHd; + switch( aCommentHd.nRecType ) + { + case PPT_PST_CString : + { + String aString; + SvxMSDffManager::MSDFFReadZString( rStCtrl, aString, aCommentHd.nRecLen, TRUE ); + switch ( aCommentHd.nRecInstance ) + { + case 0 : sAuthor = aString; break; + case 1 : sText = aString; break; + case 2 : sInitials = aString; break; + } + } + break; + + case PPT_PST_CommentAtom10 : + { + rStCtrl >> nIndex + >> aDateTime.Year + >> aDateTime.Month + >> aDateTime.Day // DayOfWeek + >> aDateTime.Day + >> aDateTime.Hours + >> aDateTime.Minutes + >> aDateTime.Seconds + >> aDateTime.HundredthSeconds + >> nPosX + >> nPosY; + + aDateTime.HundredthSeconds /= 10; + } + break; + } + aCommentHd.SeekToEndOfRecord( rStCtrl ); + } + Point aPosition( nPosX, nPosY ); + rMan.Scale( aPosition ); + + try + { + uno::Reference< office::XAnnotationAccess > xAnnotationAccess( pPage->getUnoPage(), UNO_QUERY_THROW ); + uno::Reference< office::XAnnotation > xAnnotation( xAnnotationAccess->createAndInsertAnnotation() ); + xAnnotation->setPosition( geometry::RealPoint2D( aPosition.X() / 100.0, aPosition.Y() / 100.0 ) ); + xAnnotation->setAuthor( sAuthor ); + xAnnotation->setDateTime( aDateTime ); + uno::Reference< text::XText > xText( xAnnotation->getTextRange() ); + xText->setString( sText ); + } + catch( uno::Exception& ) + { + + } +} + // be sure not to import masterpages with this method // be sure not to import masterpages with this method @@ -2896,6 +2972,21 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry* } break; + case PPT_PST_ProgTags : + { + DffRecordHeader aContentDataHd; + if ( SeekToContentOfProgTag( 10, rStCtrl, aHd, aContentDataHd ) ) + { + DffRecordHeader aComment10Hd; + while( ( rStCtrl.GetError() == 0 ) && SeekToRec( rStCtrl, PPT_PST_Comment10, aContentDataHd.GetRecEndFilePos(), &aComment10Hd ) ) + { + ImportComment10( *this, rStCtrl, pRet, aComment10Hd ); + aComment10Hd.SeekToEndOfRecord( rStCtrl ); + } + } + } + break; + case PPT_PST_PPDrawing : { DffRecordHeader aPPDrawHd; diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx index 727e7f0bafcc..936c073f6e84 100644 --- a/svx/source/svdraw/svdhdl.cxx +++ b/svx/source/svdraw/svdhdl.cxx @@ -68,6 +68,7 @@ #include <sdrpaintwindow.hxx> #include <vcl/svapp.hxx> #include <svx/sdr/overlay/overlaypolypolygon.hxx> +#include <vcl/lazydelete.hxx> //////////////////////////////////////////////////////////////////////////////////////////////////// // #i15222# @@ -275,9 +276,23 @@ const BitmapEx& SdrHdlBitmapSet::GetBitmapEx(BitmapMarkerKind eKindOfMarker, UIN //////////////////////////////////////////////////////////////////////////////////////////////////// -SdrHdlBitmapSet* SdrHdl::pSimpleSet = NULL; -SdrHdlBitmapSet* SdrHdl::pModernSet = NULL; -SdrHdlBitmapSet* SdrHdl::pHighContrastSet = NULL; +SdrHdlBitmapSet& getSimpleSet() +{ + static vcl::DeleteOnDeinit< SdrHdlBitmapSet > aSimpleSet(new SdrHdlBitmapSet(SIP_SA_MARKERS)); + return *aSimpleSet.get(); +} + +SdrHdlBitmapSet& getModernSet() +{ + static vcl::DeleteOnDeinit< SdrHdlBitmapSet > aModernSet(new SdrHdlBitmapSet(SIP_SA_MARKERS)); + return *aModernSet.get(); +} + +SdrHdlBitmapSet& getHighContrastSet() +{ + static vcl::DeleteOnDeinit< SdrHdlBitmapSet > aHighContrastSet(new SdrHdlBitmapSet(SIP_SA_MARKERS)); + return *aHighContrastSet.get(); +} //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -296,18 +311,6 @@ SdrHdl::SdrHdl(): bPlusHdl(FALSE), mbMoveOutside(false) { - if(!pSimpleSet) - pSimpleSet = new SdrHdlBitmapSet(SIP_SA_MARKERS); - DBG_ASSERT(pSimpleSet, "Could not construct SdrHdlBitmapSet()!"); - - if(!pModernSet) - pModernSet = new SdrHdlBitmapSet(SIP_SA_FINE_MARKERS); - DBG_ASSERT(pModernSet, "Could not construct SdrHdlBitmapSet()!"); - - // #101928# - if(!pHighContrastSet) - pHighContrastSet = new SdrHdlBitmapSet(SIP_SA_ACCESSIBILITY_MARKERS); - DBG_ASSERT(pHighContrastSet, "Could not construct SdrHdlBitmapSet()!"); } SdrHdl::SdrHdl(const Point& rPnt, SdrHdlKind eNewKind): @@ -326,18 +329,6 @@ SdrHdl::SdrHdl(const Point& rPnt, SdrHdlKind eNewKind): bPlusHdl(FALSE), mbMoveOutside(false) { - if(!pSimpleSet) - pSimpleSet = new SdrHdlBitmapSet(SIP_SA_MARKERS); - DBG_ASSERT(pSimpleSet, "Could not construct SdrHdlBitmapSet()!"); - - if(!pModernSet) - pModernSet = new SdrHdlBitmapSet(SIP_SA_FINE_MARKERS); - DBG_ASSERT(pModernSet, "Could not construct SdrHdlBitmapSet()!"); - - // #101928# - if(!pHighContrastSet) - pHighContrastSet = new SdrHdlBitmapSet(SIP_SA_ACCESSIBILITY_MARKERS); - DBG_ASSERT(pHighContrastSet, "Could not construct SdrHdlBitmapSet()!"); } SdrHdl::~SdrHdl() @@ -670,17 +661,17 @@ BitmapEx SdrHdl::ImpGetBitmapEx(BitmapMarkerKind eKindOfMarker, sal_uInt16 nInd, { if(bIsHighContrast) { - return pHighContrastSet->GetBitmapEx(eKindOfMarker, nInd); + return getHighContrastSet().GetBitmapEx(eKindOfMarker, nInd); } else { if(bFine) { - return pModernSet->GetBitmapEx(eKindOfMarker, nInd); + return getModernSet().GetBitmapEx(eKindOfMarker, nInd); } else { - return pSimpleSet->GetBitmapEx(eKindOfMarker, nInd); + return getSimpleSet().GetBitmapEx(eKindOfMarker, nInd); } } } diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx index 7d41191c99a9..102b5b1eb824 100644 --- a/svx/source/svdraw/svdocapt.cxx +++ b/svx/source/svdraw/svdocapt.cxx @@ -401,26 +401,35 @@ bool SdrCaptionObj::applySpecialDrag(SdrDragStat& rDrag) String SdrCaptionObj::getSpecialDragComment(const SdrDragStat& rDrag) const { - const SdrHdl* pHdl = rDrag.GetHdl(); + const bool bCreateComment(rDrag.GetView() && this == rDrag.GetView()->GetCreateObj()); - if(pHdl && 0 == pHdl->GetPolyNum()) + if(bCreateComment) { - return SdrRectObj::getSpecialDragComment(rDrag); + return String(); } else { - XubString aStr; + const SdrHdl* pHdl = rDrag.GetHdl(); - if(!pHdl) + if(pHdl && 0 == pHdl->GetPolyNum()) { - ImpTakeDescriptionStr(STR_DragCaptFram, aStr); + return SdrRectObj::getSpecialDragComment(rDrag); } else { - ImpTakeDescriptionStr(STR_DragCaptTail, aStr); - } + XubString aStr; + + if(!pHdl) + { + ImpTakeDescriptionStr(STR_DragCaptFram, aStr); + } + else + { + ImpTakeDescriptionStr(STR_DragCaptTail, aStr); + } - return aStr; + return aStr; + } } } diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx index 6af31224ee45..b3175566d561 100644 --- a/svx/source/svdraw/svdocirc.cxx +++ b/svx/source/svdraw/svdocirc.cxx @@ -589,23 +589,56 @@ bool SdrCircObj::applySpecialDrag(SdrDragStat& rDrag) String SdrCircObj::getSpecialDragComment(const SdrDragStat& rDrag) const { - const bool bWink(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); + const bool bCreateComment(rDrag.GetView() && this == rDrag.GetView()->GetCreateObj()); - if(bWink) + if(bCreateComment) { XubString aStr; - const sal_Int32 nWink(1 == rDrag.GetHdl()->GetPointNum() ? nStartWink : nEndWink); + ImpTakeDescriptionStr(STR_ViewCreateObj, aStr); + const sal_uInt32 nPntAnz(rDrag.GetPointAnz()); + + if(OBJ_CIRC != meCircleKind && nPntAnz > 2) + { + ImpCircUser* pU = (ImpCircUser*)rDrag.GetUser(); + sal_Int32 nWink; + + aStr.AppendAscii(" ("); + + if(3 == nPntAnz) + { + nWink = pU->nStart; + } + else + { + nWink = pU->nEnd; + } - ImpTakeDescriptionStr(STR_DragCircAngle, aStr); - aStr.AppendAscii(" ("); - aStr += GetWinkStr(nWink,FALSE); - aStr += sal_Unicode(')'); + aStr += GetWinkStr(nWink,FALSE); + aStr += sal_Unicode(')'); + } return aStr; } else { - return SdrTextObj::getSpecialDragComment(rDrag); + const bool bWink(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); + + if(bWink) + { + XubString aStr; + const sal_Int32 nWink(1 == rDrag.GetHdl()->GetPointNum() ? nStartWink : nEndWink); + + ImpTakeDescriptionStr(STR_DragCircAngle, aStr); + aStr.AppendAscii(" ("); + aStr += GetWinkStr(nWink,FALSE); + aStr += sal_Unicode(')'); + + return aStr; + } + else + { + return SdrTextObj::getSpecialDragComment(rDrag); + } } } @@ -698,6 +731,14 @@ FASTBOOL SdrCircObj::MovCreate(SdrDragStat& rStat) SetBoundRectDirty(); bSnapRectDirty=TRUE; SetXPolyDirty(); + + // #i103058# push current angle settings to ItemSet to + // allow FullDrag visualisation + if(rStat.GetPointAnz() >= 4) + { + ImpSetCircInfoToAttr(); + } + return TRUE; } diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx index abadbf094981..e55eeaae42b7 100644 --- a/svx/source/svdraw/svdoedge.cxx +++ b/svx/source/svdraw/svdoedge.cxx @@ -1920,11 +1920,21 @@ bool SdrEdgeObj::applySpecialDrag(SdrDragStat& rDragStat) return true; } -String SdrEdgeObj::getSpecialDragComment(const SdrDragStat& /*rDrag*/) const +String SdrEdgeObj::getSpecialDragComment(const SdrDragStat& rDrag) const { - XubString aStr; - ImpTakeDescriptionStr(STR_DragEdgeTail,aStr); - return aStr; + const bool bCreateComment(rDrag.GetView() && this == rDrag.GetView()->GetCreateObj()); + + if(bCreateComment) + { + return String(); + } + else + { + XubString aStr; + ImpTakeDescriptionStr(STR_DragEdgeTail, aStr); + + return aStr; + } } //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index 1e9c9b57c52d..f44efe3c5dfa 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -951,32 +951,86 @@ bool ImpPathForDragAndCreate::endPathDrag(SdrDragStat& rDrag) String ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag) const { - ImpSdrPathDragData* pDragData = mpSdrPathDragData; + XubString aStr; + const SdrHdl* pHdl = rDrag.GetHdl(); + const bool bCreateComment(rDrag.GetView() && &mrSdrPathObject == rDrag.GetView()->GetCreateObj()); - if(!pDragData) + if(bCreateComment && rDrag.GetUser()) { - // getSpecialDragComment is also used from create, so fallback to GetUser() - // when mpSdrPathDragData is not set - pDragData = (ImpSdrPathDragData*)rDrag.GetUser(); - } + // #i103058# re-add old creation comment mode + ImpPathCreateUser* pU = (ImpPathCreateUser*)rDrag.GetUser(); + const SdrObjKind eKindMerk(meObjectKind); + mrSdrPathObject.meKind = pU->eAktKind; + mrSdrPathObject.ImpTakeDescriptionStr(STR_ViewCreateObj, aStr); + mrSdrPathObject.meKind = eKindMerk; - if(!pDragData) - { - DBG_ERROR("ImpPathForDragAndCreate::MovDrag(): ImpSdrPathDragData ist ungueltig"); - return String(); - } + Point aPrev(rDrag.GetPrev()); + Point aNow(rDrag.GetNow()); - // Hier auch mal pDragData verwenden !!! - XubString aStr; + if(pU->bLine) + aNow = pU->aLineEnd; - const SdrHdl* pHdl = rDrag.GetHdl(); + aNow -= aPrev; + aStr.AppendAscii(" ("); - if(!mrSdrPathObject.GetModel() || !pHdl) + XubString aMetr; + + if(pU->bCircle) + { + mrSdrPathObject.GetModel()->TakeWinkStr(Abs(pU->nCircRelWink), aMetr); + aStr += aMetr; + aStr.AppendAscii(" r="); + mrSdrPathObject.GetModel()->TakeMetricStr(pU->nCircRadius, aMetr, TRUE); + aStr += aMetr; + } + + aStr.AppendAscii("dx="); + mrSdrPathObject.GetModel()->TakeMetricStr(aNow.X(), aMetr, TRUE); + aStr += aMetr; + + aStr.AppendAscii(" dy="); + mrSdrPathObject.GetModel()->TakeMetricStr(aNow.Y(), aMetr, TRUE); + aStr += aMetr; + + if(!IsFreeHand(meObjectKind)) + { + INT32 nLen(GetLen(aNow)); + aStr.AppendAscii(" l="); + mrSdrPathObject.GetModel()->TakeMetricStr(nLen, aMetr, TRUE); + aStr += aMetr; + + INT32 nWink(GetAngle(aNow)); + aStr += sal_Unicode(' '); + mrSdrPathObject.GetModel()->TakeWinkStr(nWink, aMetr); + aStr += aMetr; + } + + aStr += sal_Unicode(')'); + } + else if(!mrSdrPathObject.GetModel() || !pHdl) { + // #i103058# fallback when no model and/or Handle, both needed + // for else-path mrSdrPathObject.ImpTakeDescriptionStr(STR_DragPathObj, aStr); } else { + // #i103058# standard for modification; model and handle needed + ImpSdrPathDragData* pDragData = mpSdrPathDragData; + + if(!pDragData) + { + // getSpecialDragComment is also used from create, so fallback to GetUser() + // when mpSdrPathDragData is not set + pDragData = (ImpSdrPathDragData*)rDrag.GetUser(); + } + + if(!pDragData) + { + DBG_ERROR("ImpPathForDragAndCreate::MovDrag(): ImpSdrPathDragData ist ungueltig"); + return String(); + } + if(!pDragData->IsMultiPointDrag() && pDragData->bEliminate) { // Punkt von ... @@ -2150,12 +2204,26 @@ bool SdrPathObj::applySpecialDrag(SdrDragStat& rDrag) String SdrPathObj::getSpecialDragComment(const SdrDragStat& rDrag) const { String aRetval; - ImpPathForDragAndCreate aDragAndCreate(*((SdrPathObj*)this)); - bool bDidWork(aDragAndCreate.beginPathDrag((SdrDragStat&)rDrag)); - if(bDidWork) + if(mpDAC) { - aRetval = aDragAndCreate.getSpecialDragComment(rDrag); + // #i103058# also get a comment when in creation + const bool bCreateComment(rDrag.GetView() && this == rDrag.GetView()->GetCreateObj()); + + if(bCreateComment) + { + aRetval = mpDAC->getSpecialDragComment(rDrag); + } + } + else + { + ImpPathForDragAndCreate aDragAndCreate(*((SdrPathObj*)this)); + bool bDidWork(aDragAndCreate.beginPathDrag((SdrDragStat&)rDrag)); + + if(bDidWork) + { + aRetval = aDragAndCreate.getSpecialDragComment(rDrag); + } } return aRetval; diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx index 837b75bcf849..7d69955ec441 100644 --- a/svx/source/svdraw/svdorect.cxx +++ b/svx/source/svdraw/svdorect.cxx @@ -419,33 +419,42 @@ bool SdrRectObj::applySpecialDrag(SdrDragStat& rDrag) String SdrRectObj::getSpecialDragComment(const SdrDragStat& rDrag) const { - const bool bRad(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); + const bool bCreateComment(rDrag.GetView() && this == rDrag.GetView()->GetCreateObj()); - if(bRad) + if(bCreateComment) { - Point aPt(rDrag.GetNow()); + return String(); + } + else + { + const bool bRad(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); - // -sin fuer Umkehrung - if(aGeo.nDrehWink) - RotatePoint(aPt, aRect.TopLeft(), -aGeo.nSin, aGeo.nCos); + if(bRad) + { + Point aPt(rDrag.GetNow()); - sal_Int32 nRad(aPt.X() - aRect.Left()); + // -sin fuer Umkehrung + if(aGeo.nDrehWink) + RotatePoint(aPt, aRect.TopLeft(), -aGeo.nSin, aGeo.nCos); - if(nRad < 0) - nRad = 0; + sal_Int32 nRad(aPt.X() - aRect.Left()); - XubString aStr; + if(nRad < 0) + nRad = 0; - ImpTakeDescriptionStr(STR_DragRectEckRad, aStr); - aStr.AppendAscii(" ("); - aStr += GetMetrStr(nRad); - aStr += sal_Unicode(')'); + XubString aStr; - return aStr; - } - else - { - return SdrTextObj::getSpecialDragComment(rDrag); + ImpTakeDescriptionStr(STR_DragRectEckRad, aStr); + aStr.AppendAscii(" ("); + aStr += GetMetrStr(nRad); + aStr += sal_Unicode(')'); + + return aStr; + } + else + { + return SdrTextObj::getSpecialDragComment(rDrag); + } } } diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index 8ce4390ad6ac..93d3651e3f01 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -215,30 +215,23 @@ namespace { if(rInfo.mrText.Len() && rInfo.mnTextLen) { - basegfx::B2DVector aSize; - drawinglayer::primitive2d::FontAttributes aFontAttributes(drawinglayer::primitive2d::getFontAttributesFromVclFont( - aSize, - rInfo.mrFont, - rInfo.IsRTL(), - false)); + basegfx::B2DVector aFontScaling; + drawinglayer::primitive2d::FontAttributes aFontAttributes( + drawinglayer::primitive2d::getFontAttributesFromVclFont( + aFontScaling, + rInfo.mrFont, + rInfo.IsRTL(), + false)); basegfx::B2DHomMatrix aNewTransform; - // #i100489# need extra scale factor for DXArray which collects all scalings - // which are needed to get the DXArray to unit coordinates - double fDXArrayScaleFactor(aSize.getX()); - // add font scale to new transform - aNewTransform.scale(aSize.getX(), aSize.getY()); + aNewTransform.scale(aFontScaling.getX(), aFontScaling.getY()); // look for proportional font scaling, evtl scale accordingly if(100 != rInfo.mrFont.GetPropr()) { const double fFactor(rInfo.mrFont.GetPropr() / 100.0); aNewTransform.scale(fFactor, fFactor); - - // #i100489# proportional font scaling influences the DXArray, - // add to factor - fDXArrayScaleFactor *= fFactor; } // apply font rotate @@ -271,7 +264,7 @@ namespace } const double fEscapement(nEsc / -100.0); - aNewTransform.translate(0.0, fEscapement * aSize.getY()); + aNewTransform.translate(0.0, fEscapement * aFontScaling.getY()); } // apply transformA @@ -290,13 +283,11 @@ namespace if(!bDisableTextArray && rInfo.mpDXArray && rInfo.mnTextLen) { - // #i100489# use fDXArrayScaleFactor here - const double fScaleFactor(basegfx::fTools::equalZero(fDXArrayScaleFactor) ? 1.0 : 1.0 / fDXArrayScaleFactor); aDXArray.reserve(rInfo.mnTextLen); for(xub_StrLen a(0); a < rInfo.mnTextLen; a++) { - aDXArray.push_back((double)rInfo.mpDXArray[a] * fScaleFactor); + aDXArray.push_back((double)rInfo.mpDXArray[a]); } } @@ -472,6 +463,17 @@ namespace fEnd = fTextWidth - fEnd; } + // need to take FontScaling out of values; it's already part of + // aNewTransform and would be double applied + const double fFontScaleX(aFontScaling.getX()); + + if(!basegfx::fTools::equal(fFontScaleX, 1.0) + && !basegfx::fTools::equalZero(fFontScaleX)) + { + fStart /= fFontScaleX; + fEnd /= fFontScaleX; + } + maTextPortionPrimitives.push_back(new drawinglayer::primitive2d::WrongSpellPrimitive2D( aNewTransform, fStart, @@ -709,16 +711,7 @@ namespace ////////////////////////////////////////////////////////////////////////////// // primitive decompositions -bool SdrTextObj::impCheckSpellCheckForDecomposeTextPrimitive() const -{ - // #i102062# asked TL who killed this feature (CWS tl56). Obviously, there - // is no more support for EE_CNTRL_NOREDLINES anymore; redlining is always - // on nowadays. Unfortunately, not false, but true should be returned then. - // Trying if this is all... - return true; -} - -bool SdrTextObj::impDecomposeContourTextPrimitive( +void SdrTextObj::impDecomposeContourTextPrimitive( drawinglayer::primitive2d::Primitive2DSequence& rTarget, const drawinglayer::primitive2d::SdrContourTextPrimitive2D& rSdrContourTextPrimitive, const drawinglayer::geometry::ViewInformation2D& aViewInformation) const @@ -770,10 +763,9 @@ bool SdrTextObj::impDecomposeContourTextPrimitive( rOutliner.setVisualizedPage(0); rTarget = aConverter.getPrimitive2DSequence(); - return false; } -bool SdrTextObj::impDecomposeBlockTextPrimitive( +void SdrTextObj::impDecomposeBlockTextPrimitive( drawinglayer::primitive2d::Primitive2DSequence& rTarget, const drawinglayer::primitive2d::SdrBlockTextPrimitive2D& rSdrBlockTextPrimitive, const drawinglayer::geometry::ViewInformation2D& aViewInformation) const @@ -789,19 +781,15 @@ bool SdrTextObj::impDecomposeBlockTextPrimitive( // prepare outliner const bool bIsCell(rSdrBlockTextPrimitive.getCellText()); - const SfxItemSet& rTextItemSet = rSdrBlockTextPrimitive.getSdrText() - ? rSdrBlockTextPrimitive.getSdrText()->GetItemSet() - : GetObjectItemSet(); SdrOutliner& rOutliner = ImpGetDrawOutliner(); - SdrTextVertAdjust eVAdj = GetTextVerticalAdjust(rTextItemSet); - SdrTextHorzAdjust eHAdj = GetTextHorizontalAdjust(rTextItemSet); + SdrTextHorzAdjust eHAdj = rSdrBlockTextPrimitive.getSdrTextHorzAdjust(); + SdrTextVertAdjust eVAdj = rSdrBlockTextPrimitive.getSdrTextVertAdjust(); const sal_uInt32 nOriginalControlWord(rOutliner.GetControlWord()); const Size aNullSize; // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage())); - - rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)rTextItemSet.Get(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue()); + rOutliner.SetFixedCellHeight(rSdrBlockTextPrimitive.isFixedCellHeight()); rOutliner.SetControlWord(nOriginalControlWord|EE_CNTRL_AUTOPAGESIZE); rOutliner.SetMinAutoPaperSize(aNullSize); rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000)); @@ -975,10 +963,9 @@ bool SdrTextObj::impDecomposeBlockTextPrimitive( rOutliner.setVisualizedPage(0); rTarget = aConverter.getPrimitive2DSequence(); - return false; } -bool SdrTextObj::impDecomposeStretchTextPrimitive( +void SdrTextObj::impDecomposeStretchTextPrimitive( drawinglayer::primitive2d::Primitive2DSequence& rTarget, const drawinglayer::primitive2d::SdrStretchTextPrimitive2D& rSdrStretchTextPrimitive, const drawinglayer::geometry::ViewInformation2D& aViewInformation) const @@ -995,13 +982,10 @@ bool SdrTextObj::impDecomposeStretchTextPrimitive( // prepare outliner SdrOutliner& rOutliner = ImpGetDrawOutliner(); const sal_uInt32 nOriginalControlWord(rOutliner.GetControlWord()); - const SfxItemSet& rTextItemSet = rSdrStretchTextPrimitive.getSdrText() - ? rSdrStretchTextPrimitive.getSdrText()->GetItemSet() - : GetObjectItemSet(); const Size aNullSize; rOutliner.SetControlWord(nOriginalControlWord|EE_CNTRL_STRETCHING|EE_CNTRL_AUTOPAGESIZE); - rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)rTextItemSet.Get(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue()); + rOutliner.SetFixedCellHeight(rSdrStretchTextPrimitive.isFixedCellHeight()); rOutliner.SetMinAutoPaperSize(aNullSize); rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000)); rOutliner.SetPaperSize(aNullSize); @@ -1059,7 +1043,6 @@ bool SdrTextObj::impDecomposeStretchTextPrimitive( rOutliner.setVisualizedPage(0); rTarget = aConverter.getPrimitive2DSequence(); - return false; } ////////////////////////////////////////////////////////////////////////////// diff --git a/svx/source/svdraw/svdotextpathdecomposition.cxx b/svx/source/svdraw/svdotextpathdecomposition.cxx index f3bdeeb4811c..f6a30d40b3d5 100644 --- a/svx/source/svdraw/svdotextpathdecomposition.cxx +++ b/svx/source/svdraw/svdotextpathdecomposition.cxx @@ -365,12 +365,13 @@ namespace for(sal_uInt32 a(0L); a < rTextPortions.size() && fPolyStart < fPolyEnd; a++) { const impPathTextPortion* pCandidate = rTextPortions[a]; - basegfx::B2DVector aSize; - const drawinglayer::primitive2d::FontAttributes aCandidateFontAttributes(drawinglayer::primitive2d::getFontAttributesFromVclFont( - aSize, - pCandidate->getFont(), - pCandidate->isRTL(), - false)); + basegfx::B2DVector aFontScaling; + const drawinglayer::primitive2d::FontAttributes aCandidateFontAttributes( + drawinglayer::primitive2d::getFontAttributesFromVclFont( + aFontScaling, + pCandidate->getFont(), + pCandidate->isRTL(), + false)); if(pCandidate && pCandidate->getTextLength()) { @@ -397,7 +398,7 @@ namespace basegfx::B2DPoint aEndPos(aStartPos); // add font scaling - aNewTransformA.scale(aSize.getX(), aSize.getY()); + aNewTransformA.scale(aFontScaling.getX(), aFontScaling.getY()); // prepare scaling of text primitive if(XFT_AUTOSIZE == mrSdrFormTextAttribute.getFormTextAdjust()) @@ -512,15 +513,16 @@ namespace pCandidate->getDoubleDXArray().begin() + nPortionIndex, pCandidate->getDoubleDXArray().begin() + nPortionIndex + nNextGlyphLen); - drawinglayer::primitive2d::TextSimplePortionPrimitive2D* pNew = new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( - aNewTransformB * aNewShadowTransform * aNewTransformA, - pCandidate->getText(), - nPortionIndex, - nNextGlyphLen, - aNewDXArray, - aCandidateFontAttributes, - pCandidate->getLocale(), - aRGBShadowColor); + drawinglayer::primitive2d::TextSimplePortionPrimitive2D* pNew = + new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( + aNewTransformB * aNewShadowTransform * aNewTransformA, + pCandidate->getText(), + nPortionIndex, + nNextGlyphLen, + aNewDXArray, + aCandidateFontAttributes, + pCandidate->getLocale(), + aRGBShadowColor); mrShadowDecomposition.push_back(pNew); } @@ -536,15 +538,16 @@ namespace pCandidate->getDoubleDXArray().begin() + nPortionIndex, pCandidate->getDoubleDXArray().begin() + nPortionIndex + nNextGlyphLen); - drawinglayer::primitive2d::TextSimplePortionPrimitive2D* pNew = new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( - aNewTransformB * aNewTransformA, - pCandidate->getText(), - nPortionIndex, - nNextGlyphLen, - aNewDXArray, - aCandidateFontAttributes, - pCandidate->getLocale(), - aRGBColor); + drawinglayer::primitive2d::TextSimplePortionPrimitive2D* pNew = + new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( + aNewTransformB * aNewTransformA, + pCandidate->getText(), + nPortionIndex, + nNextGlyphLen, + aNewDXArray, + aCandidateFontAttributes, + pCandidate->getLocale(), + aRGBColor); mrDecomposition.push_back(pNew); } @@ -671,7 +674,7 @@ namespace ////////////////////////////////////////////////////////////////////////////// // primitive decomposition -bool SdrTextObj::impDecomposePathTextPrimitive( +void SdrTextObj::impDecomposePathTextPrimitive( drawinglayer::primitive2d::Primitive2DSequence& rTarget, const drawinglayer::primitive2d::SdrPathTextPrimitive2D& rSdrPathTextPrimitive, const drawinglayer::geometry::ViewInformation2D& aViewInformation) const @@ -789,8 +792,6 @@ bool SdrTextObj::impDecomposePathTextPrimitive( // concatenate all results drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aRetvalA); drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aRetvalB); - - return false; } ////////////////////////////////////////////////////////////////////////////// diff --git a/svx/source/svxlink/fileobj.cxx b/svx/source/svxlink/fileobj.cxx index f2628f181d31..d159c7f78abe 100644 --- a/svx/source/svxlink/fileobj.cxx +++ b/svx/source/svxlink/fileobj.cxx @@ -121,37 +121,6 @@ BOOL SvFileObject::GetData( ::com::sun::star::uno::Any & rData, // relativen Datei Links aufzuloesen!!!! Wird ueber den // LinkManager und damit von dessen Storage erledigt. rData <<= rtl::OUString( sFileNm ); - -/* -=========================================================================== -JP 28.02.96: noch eine Baustelle: - Idee: hier das Medium und die DocShell anlegen, Doc laden - und ueber OLE-SS (GetObj(...)) den Bereich als - PseudoObject erfragen. Dieses mit den Daten oder - dessen Daten verschicken. - -=========================================================================== - - SfxMedium aMed( aFileNm.GetFull(), STREAM_READ, TRUE ); - aMed.DownLoad(); // nur mal das Medium anfassen (DownLoaden) - - if( aMed.IsStorage() ) - pSvData->SetData( SvStorageRef( aMed.GetStorage() ), - TRANSFER_COPY ); - else - { - SvStream* pStream = aMed.GetInStream(); - if( !pStream ) - return FALSE; - - UINT32 nLen = pStream->Seek( STREAM_SEEK_TO_END ); - pStream->Seek( STREAM_SEEK_TO_BEGIN ); - - void* pData = SvMemAlloc( nLen ); - pStream->Read( pData, nLen ); - pSvData->SetData( pData, nLen, TRANSFER_MOVE ); - } -*/ } break; diff --git a/svx/source/unoedit/unoforou.cxx b/svx/source/unoedit/unoforou.cxx index 9c6cb07440d7..c54f76d5f4dc 100644 --- a/svx/source/unoedit/unoforou.cxx +++ b/svx/source/unoedit/unoforou.cxx @@ -490,7 +490,7 @@ sal_Bool SvxOutlinerForwarder::SetDepth( USHORT nPara, sal_Int16 nNewDepth ) { rOutliner.SetDepth( pPara, nNewDepth ); - const bool bOutlinerText = (pSdrObject->GetObjInventor() == SdrInventor) && (pSdrObject->GetObjIdentifier() == OBJ_OUTLINETEXT); + const bool bOutlinerText = pSdrObject && (pSdrObject->GetObjInventor() == SdrInventor) && (pSdrObject->GetObjIdentifier() == OBJ_OUTLINETEXT); if( bOutlinerText ) rOutliner.SetLevelDependendStyleSheet( nPara ); diff --git a/svx/source/xml/xmlxtimp.cxx b/svx/source/xml/xmlxtimp.cxx index e211c98f6834..70e8af36c838 100644 --- a/svx/source/xml/xmlxtimp.cxx +++ b/svx/source/xml/xmlxtimp.cxx @@ -394,7 +394,7 @@ sal_Bool SvxXMLXTableImport::load( const OUString& rUrl, const uno::Reference< X if( aMedium.IsStorage() ) { - uno::Reference < embed::XStorage > xStorage( aMedium.GetStorage(), uno::UNO_QUERY_THROW ); + uno::Reference < embed::XStorage > xStorage( aMedium.GetStorage( sal_False ), uno::UNO_QUERY_THROW ); const String aContentStmName( RTL_CONSTASCII_USTRINGPARAM( "Content.xml" ) ); xIStm.set( xStorage->openStreamElement( aContentStmName, embed::ElementModes::READ ), uno::UNO_QUERY_THROW ); diff --git a/svx/util/hidother.src b/svx/util/hidother.src index 86c0edea64d3..6ef00e2640a2 100644 --- a/svx/util/hidother.src +++ b/svx/util/hidother.src @@ -392,4 +392,5 @@ hidspecial HID_MACRO_HEADERTABLISTBOX { HelpID = HID_MACRO_HEADERTABLI hidspecial HID_PASTE_DLG { HelpId = HID_PASTE_DLG; }; hidspecial HID_LINKDLG_TABLB { HelpId = HID_LINKDLG_TABLB; }; +hidspecial HID_OPTIONS_JAVA_LIST { HelpId = HID_OPTIONS_JAVA_LIST; }; diff --git a/ucb/inc/makefile.mk b/ucb/inc/makefile.mk index 90c4f96a1f68..c98dc5fe07e2 100644 --- a/ucb/inc/makefile.mk +++ b/ucb/inc/makefile.mk @@ -41,6 +41,7 @@ TARGET=inc # --- Targets ------------------------------------------------------- .INCLUDE : target.mk +.IF "$(L10N_framework)"=="" .IF "$(ENABLE_PCH)"!="" ALLTAR : \ @@ -48,4 +49,4 @@ ALLTAR : \ $(SLO)$/precompiled_ex.pch .ENDIF # "$(ENABLE_PCH)"!="" - +.ENDIF # L10N_framework diff --git a/ucb/source/cacher/makefile.mk b/ucb/source/cacher/makefile.mk index dd4d9b398229..09717b3f0f7e 100644 --- a/ucb/source/cacher/makefile.mk +++ b/ucb/source/cacher/makefile.mk @@ -39,6 +39,7 @@ NO_BSYMBOLIC=TRUE UCB_MAJOR=1 .INCLUDE: settings.mk +.IF "$(L10N_framework)"=="" SLOFILES=\ $(SLO)$/contentresultsetwrapper.obj \ @@ -65,6 +66,7 @@ SHL1IMPLIB=i$(TARGET) SHL1VERSIONMAP=exports.map DEF1NAME=$(SHL1TARGET) +.ENDIF # L10N_framework .INCLUDE: target.mk diff --git a/ucb/source/core/makefile.mk b/ucb/source/core/makefile.mk index 963aa038dab0..e70b5ca879ef 100644 --- a/ucb/source/core/makefile.mk +++ b/ucb/source/core/makefile.mk @@ -39,6 +39,7 @@ NO_BSYMBOLIC=TRUE UCB_MAJOR=1 .INCLUDE: settings.mk +.IF "$(L10N_framework)"=="" SLOFILES=\ $(SLO)$/identify.obj \ @@ -72,5 +73,7 @@ SHL1VERSIONMAP=exports.map DEF1NAME=$(SHL1TARGET) +.ENDIF # L10N_framework + .INCLUDE: target.mk diff --git a/ucb/source/regexp/makefile.mk b/ucb/source/regexp/makefile.mk index 898a4d5adbdb..8d0b938402e8 100644 --- a/ucb/source/regexp/makefile.mk +++ b/ucb/source/regexp/makefile.mk @@ -36,8 +36,10 @@ AUTOSEG=true ENABLE_EXCEPTIONS=true .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" SLOFILES=\ $(SLO)$/regexp.obj +.ENDIF # L10N_framework .INCLUDE : target.mk diff --git a/ucb/source/sorter/makefile.mk b/ucb/source/sorter/makefile.mk index cbe4e360ee29..bcd3b644476a 100644 --- a/ucb/source/sorter/makefile.mk +++ b/ucb/source/sorter/makefile.mk @@ -38,6 +38,7 @@ ENABLE_EXCEPTIONS=TRUE UCB_MAJOR=1 .INCLUDE: settings.mk +.IF "$(L10N_framework)"=="" SLOFILES=\ $(SLO)$/sortdynres.obj \ @@ -60,6 +61,7 @@ SHL1IMPLIB=i$(TARGET) SHL1VERSIONMAP=exports.map DEF1NAME=$(SHL1TARGET) +.ENDIF # L10N_framework .INCLUDE: target.mk diff --git a/ucb/source/ucp/expand/makefile.mk b/ucb/source/ucp/expand/makefile.mk index 03e0e5a638ee..6b4ffc8581be 100644 --- a/ucb/source/ucp/expand/makefile.mk +++ b/ucb/source/ucp/expand/makefile.mk @@ -39,6 +39,8 @@ NO_BSYMBOLIC = TRUE .INCLUDE : settings.mk DLLPRE = +.IF "$(L10N_framework)"=="" + SLOFILES= \ $(SLO)$/ucpexpand.obj @@ -58,4 +60,6 @@ SHL1DEF = $(MISC)$/$(SHL1TARGET).def DEF1NAME = $(SHL1TARGET) +.ENDIF # L10N_framework + .INCLUDE : target.mk diff --git a/ucb/source/ucp/file/makefile.mk b/ucb/source/ucp/file/makefile.mk index 31fbaf8f1eba..d03983bca000 100644 --- a/ucb/source/ucp/file/makefile.mk +++ b/ucb/source/ucp/file/makefile.mk @@ -39,6 +39,7 @@ NO_BSYMBOLIC=TRUE UCPFILE_MAJOR=1 .INCLUDE: settings.mk +.IF "$(L10N_framework)"=="" SLOFILES=\ $(SLO)$/prov.obj \ @@ -77,6 +78,7 @@ DEF1EXPORTFILE=exports2.dxp .ENDIF DEF1NAME=$(SHL1TARGET) +.ENDIF # L10N_framework .INCLUDE: target.mk diff --git a/ucb/source/ucp/ftp/ftpcontent.cxx b/ucb/source/ucp/ftp/ftpcontent.cxx index c90afa97bf3c..e4533d872275 100644 --- a/ucb/source/ucp/ftp/ftpcontent.cxx +++ b/ucb/source/ucp/ftp/ftpcontent.cxx @@ -322,6 +322,7 @@ Any SAL_CALL FTPContent::execute( aAccount); rtl::Reference<ucbhelper::SimpleAuthenticationRequest> p( new ucbhelper::SimpleAuthenticationRequest( + m_aFTPURL.ident(false, false), m_aFTPURL.host(), // ServerName ucbhelper::SimpleAuthenticationRequest::ENTITY_NA, aRealm, diff --git a/ucb/source/ucp/ftp/makefile.mk b/ucb/source/ucp/ftp/makefile.mk index 05254484eb0d..75f5512c728c 100644 --- a/ucb/source/ucp/ftp/makefile.mk +++ b/ucb/source/ucp/ftp/makefile.mk @@ -45,7 +45,7 @@ UCPFTP_MAJOR=1 .INCLUDE: settings.mk # --- General ----------------------------------------------------- - +.IF "$(L10N_framework)"=="" # first target ( shared library ) SLOFILES1=\ @@ -93,6 +93,7 @@ SHL1LIBS= \ DEF1NAME=$(SHL1TARGET) +.ENDIF # L10N_framework .INCLUDE: target.mk diff --git a/ucb/source/ucp/gio/gio_mount.cxx b/ucb/source/ucp/gio/gio_mount.cxx index b3f562e503fc..2756262ce91d 100644 --- a/ucb/source/ucp/gio/gio_mount.cxx +++ b/ucb/source/ucp/gio/gio_mount.cxx @@ -123,7 +123,7 @@ static void ooo_mount_operation_ask_password (GMountOperation *op, aDomain = rtl::OUString(default_domain, strlen(default_domain), RTL_TEXTENCODING_UTF8); uno::Reference< ucbhelper::SimpleAuthenticationRequest > xRequest - = new ucbhelper::SimpleAuthenticationRequest (aHostName, eDomain, aDomain, eUserName, aUserName, ePassword, aPassword); + = new ucbhelper::SimpleAuthenticationRequest (rtl::OUString() /* FIXME: provide URL here */, aHostName, eDomain, aDomain, eUserName, aUserName, ePassword, aPassword); xIH->handle( xRequest.get() ); diff --git a/ucb/source/ucp/gio/makefile.mk b/ucb/source/ucp/gio/makefile.mk index a0f33f8dbb6d..2e7009e52ab2 100644 --- a/ucb/source/ucp/gio/makefile.mk +++ b/ucb/source/ucp/gio/makefile.mk @@ -39,6 +39,7 @@ USE_DEFFILE=TRUE NO_BSYMBOLIC=TRUE .INCLUDE: settings.mk +.IF "$(L10N_framework)"=="" UNIXTEXT=$(MISC)/$(TARGET)-ucd.txt @@ -79,5 +80,6 @@ SHL1STDLIBS+=$(PKGCONFIG_LIBS) SHL1VERSIONMAP= exports.map .ENDIF # "$(ENABLE_GIO)"!="" +.ENDIF # L10N_framework .INCLUDE: target.mk diff --git a/ucb/source/ucp/gvfs/content.cxx b/ucb/source/ucp/gvfs/content.cxx index ab00cec0907e..743043c09fc7 100644 --- a/ucb/source/ucp/gvfs/content.cxx +++ b/ucb/source/ucp/gvfs/content.cxx @@ -1609,7 +1609,8 @@ extern "C" { } rtl::Reference< ucbhelper::SimpleAuthenticationRequest > xRequest - = new ucbhelper::SimpleAuthenticationRequest (aHostName, eDomain, aDomain, + = new ucbhelper::SimpleAuthenticationRequest (GnomeToOUString(in->uri), + aHostName, eDomain, aDomain, eUserName, aUserName, ePassword, aPassword); diff --git a/ucb/source/ucp/gvfs/makefile.mk b/ucb/source/ucp/gvfs/makefile.mk index 0f7ae15db9d8..889e3ffd415d 100644 --- a/ucb/source/ucp/gvfs/makefile.mk +++ b/ucb/source/ucp/gvfs/makefile.mk @@ -39,6 +39,7 @@ USE_DEFFILE=TRUE NO_BSYMBOLIC=TRUE .INCLUDE: settings.mk +.IF "$(L10N_framework)"=="" UNIXTEXT=$(MISC)/$(TARGET)-ucd.txt @@ -83,6 +84,7 @@ SHL1STDLIBS+=$(PKGCONFIG_LIBS) SHL1VERSIONMAP= exports.map .ENDIF # "$(ENABLE_GNOMEVFS)"!="" +.ENDIF # L10N_framework .INCLUDE: target.mk diff --git a/ucb/source/ucp/hierarchy/makefile.mk b/ucb/source/ucp/hierarchy/makefile.mk index 9500b024829d..b71ee7fa1817 100644 --- a/ucb/source/ucp/hierarchy/makefile.mk +++ b/ucb/source/ucp/hierarchy/makefile.mk @@ -44,6 +44,7 @@ UCPHIER_MAJOR=1 .INCLUDE: settings.mk # --- General ----------------------------------------------------- +.IF "$(L10N_framework)"=="" SLOFILES=\ $(SLO)$/hierarchyservices.obj \ @@ -82,5 +83,6 @@ DEF1NAME=$(SHL1TARGET) # --- Targets ---------------------------------------------------------- +.ENDIF # L10N_framework .INCLUDE: target.mk diff --git a/ucb/source/ucp/package/makefile.mk b/ucb/source/ucp/package/makefile.mk index 64e76da3ea24..4b4f066ac1cf 100644 --- a/ucb/source/ucp/package/makefile.mk +++ b/ucb/source/ucp/package/makefile.mk @@ -50,6 +50,7 @@ NO_BSYMBOLIC=TRUE .INCLUDE: settings.mk # --- General ----------------------------------------------------- +.IF "$(L10N_framework)"=="" SLOFILES=\ $(SLO)$/pkgservices.obj \ @@ -86,5 +87,6 @@ DEF1NAME=$(SHL1TARGET) # --- Targets ---------------------------------------------------------- +.ENDIF # L10N_framework .INCLUDE: target.mk diff --git a/ucb/source/ucp/tdoc/makefile.mk b/ucb/source/ucp/tdoc/makefile.mk index 78b3123fa220..1c2c44b124de 100644 --- a/ucb/source/ucp/tdoc/makefile.mk +++ b/ucb/source/ucp/tdoc/makefile.mk @@ -43,6 +43,7 @@ NO_BSYMBOLIC=TRUE .INCLUDE: settings.mk # --- General ----------------------------------------------------- +.IF "$(L10N_framework)"=="" # no "lib" prefix DLLPRE = @@ -89,6 +90,8 @@ SYMBOLPREFIX=$(TARGET) DEF1NAME=$(SHL1TARGET) +.ENDIF # L10N_framework + # --- Targets ---------------------------------------------------------- .INCLUDE: target.mk diff --git a/ucb/source/ucp/webdav/DAVAuthListener.hxx b/ucb/source/ucp/webdav/DAVAuthListener.hxx index 4744b06f9649..548a4a0a97fa 100644 --- a/ucb/source/ucp/webdav/DAVAuthListener.hxx +++ b/ucb/source/ucp/webdav/DAVAuthListener.hxx @@ -49,7 +49,8 @@ class DAVAuthListener : public salhelper::SimpleReferenceObject const ::rtl::OUString & inHostName, ::rtl::OUString & inoutUserName, ::rtl::OUString & outPassWord, - const sal_Bool & bAllowPersistentStoring) = 0; + sal_Bool bAllowPersistentStoring, + sal_Bool bCanUseSystemCredentials ) = 0; }; } // namespace webdav_ucp diff --git a/ucb/source/ucp/webdav/DAVAuthListenerImpl.hxx b/ucb/source/ucp/webdav/DAVAuthListenerImpl.hxx index e697773eb198..db06b24b22bc 100644 --- a/ucb/source/ucp/webdav/DAVAuthListenerImpl.hxx +++ b/ucb/source/ucp/webdav/DAVAuthListenerImpl.hxx @@ -54,9 +54,9 @@ namespace webdav_ucp DAVAuthListener_Impl( const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment>& xEnv ) - : m_xEnv( xEnv - ) + com::sun::star::ucb::XCommandEnvironment>& xEnv, + const ::rtl::OUString & inURL ) + : m_xEnv( xEnv ), m_aURL( inURL ) { } @@ -64,11 +64,14 @@ namespace webdav_ucp const ::rtl::OUString & inHostName, ::rtl::OUString & inoutUserName, ::rtl::OUString & outPassWord, - const sal_Bool & bAllowPersistentStoring); + sal_Bool bAllowPersistentStoring, + sal_Bool bCanUseSystemCredentials ); private: - com::sun::star::uno::Reference< + const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xEnv; + const rtl::OUString m_aURL; + rtl::OUString m_aPrevPassword; rtl::OUString m_aPrevUsername; }; diff --git a/ucb/source/ucp/webdav/DAVResourceAccess.cxx b/ucb/source/ucp/webdav/DAVResourceAccess.cxx index 0def59082476..67f8e5a386f0 100644 --- a/ucb/source/ucp/webdav/DAVResourceAccess.cxx +++ b/ucb/source/ucp/webdav/DAVResourceAccess.cxx @@ -60,7 +60,8 @@ int DAVAuthListener_Impl::authenticate( const ::rtl::OUString & inHostName, ::rtl::OUString & inoutUserName, ::rtl::OUString & outPassWord, - const sal_Bool & bAllowPersistentStoring) + sal_Bool bAllowPersistentStoring, + sal_Bool bCanUseSystemCredentials ) { if ( m_xEnv.is() ) { @@ -77,12 +78,14 @@ int DAVAuthListener_Impl::authenticate( outPassWord = m_aPrevPassword; rtl::Reference< ucbhelper::SimpleAuthenticationRequest > xRequest - = new ucbhelper::SimpleAuthenticationRequest( inHostName, + = new ucbhelper::SimpleAuthenticationRequest( m_aURL, + inHostName, inRealm, inoutUserName, outPassWord, ::rtl::OUString(), - bAllowPersistentStoring); + bAllowPersistentStoring, + bCanUseSystemCredentials ); xIH->handle( xRequest.get() ); rtl::Reference< ucbhelper::InteractionContinuation > xSelection @@ -99,8 +102,23 @@ int DAVAuthListener_Impl::authenticate( ucbhelper::InteractionSupplyAuthentication > & xSupp = xRequest->getAuthenticationSupplier(); - inoutUserName = xSupp->getUserName(); - outPassWord = xSupp->getPassword(); + sal_Bool bUseSystemCredentials = sal_False; + + if ( bCanUseSystemCredentials ) + bUseSystemCredentials = xSupp->getUseSystemCredentials(); + + if ( bUseSystemCredentials ) + { + // This is the (strange) way to tell neon to use + // system credentials. + inoutUserName = rtl::OUString(); + outPassWord = rtl::OUString(); + } + else + { + inoutUserName = xSupp->getUserName(); + outPassWord = xSupp->getPassword(); + } // #102871# - Remember username and password. m_aPrevUsername = inoutUserName; @@ -186,7 +204,7 @@ void DAVResourceAccess::OPTIONS( rCapabilities, DAVRequestEnvironment( getRequestURI(), - new DAVAuthListener_Impl( xEnv ), + new DAVAuthListener_Impl( xEnv, m_aURL ), aHeaders, xEnv) ); } catch ( DAVException & e ) @@ -231,7 +249,7 @@ void DAVResourceAccess::PROPFIND( rResources, DAVRequestEnvironment( getRequestURI(), - new DAVAuthListener_Impl( xEnv ), + new DAVAuthListener_Impl( xEnv, m_aURL ), aHeaders, xEnv ) ); } catch ( DAVException & e ) @@ -273,7 +291,7 @@ void DAVResourceAccess::PROPFIND( rResInfo, DAVRequestEnvironment( getRequestURI(), - new DAVAuthListener_Impl( xEnv ), + new DAVAuthListener_Impl( xEnv, m_aURL ), aHeaders, xEnv ) ) ; } catch ( DAVException & e ) @@ -313,7 +331,7 @@ void DAVResourceAccess::PROPPATCH( rValues, DAVRequestEnvironment( getRequestURI(), - new DAVAuthListener_Impl( xEnv ), + new DAVAuthListener_Impl( xEnv, m_aURL ), aHeaders, xEnv ) ); } catch ( DAVException & e ) @@ -353,7 +371,7 @@ void DAVResourceAccess::HEAD( rResource, DAVRequestEnvironment( getRequestURI(), - new DAVAuthListener_Impl( xEnv ), + new DAVAuthListener_Impl( xEnv, m_aURL ), aHeaders, xEnv ) ); } catch ( DAVException & e ) @@ -391,7 +409,7 @@ uno::Reference< io::XInputStream > DAVResourceAccess::GET( xStream = m_xSession->GET( getRequestURI(), DAVRequestEnvironment( getRequestURI(), - new DAVAuthListener_Impl( xEnv ), + new DAVAuthListener_Impl( xEnv, m_aURL ), aHeaders, xEnv ) ); } catch ( DAVException & e ) @@ -432,7 +450,7 @@ void DAVResourceAccess::GET( rStream, DAVRequestEnvironment( getRequestURI(), - new DAVAuthListener_Impl( xEnv ), + new DAVAuthListener_Impl( xEnv, m_aURL ), aHeaders, xEnv ) ); } catch ( DAVException & e ) @@ -474,7 +492,7 @@ uno::Reference< io::XInputStream > DAVResourceAccess::GET( rResource, DAVRequestEnvironment( getRequestURI(), - new DAVAuthListener_Impl( xEnv ), + new DAVAuthListener_Impl( xEnv, m_aURL ), aHeaders, xEnv ) ); } catch ( DAVException & e ) @@ -519,7 +537,7 @@ void DAVResourceAccess::GET( rResource, DAVRequestEnvironment( getRequestURI(), - new DAVAuthListener_Impl( xEnv ), + new DAVAuthListener_Impl( xEnv, m_aURL ), aHeaders, xEnv ) ); } catch ( DAVException & e ) @@ -601,7 +619,7 @@ void DAVResourceAccess::PUT( xSeekableStream, DAVRequestEnvironment( getRequestURI(), - new DAVAuthListener_Impl( xEnv ), + new DAVAuthListener_Impl( xEnv, m_aURL ), aHeaders, xEnv ) ); } catch ( DAVException & e ) @@ -655,7 +673,7 @@ uno::Reference< io::XInputStream > DAVResourceAccess::POST( xSeekableStream, DAVRequestEnvironment( getRequestURI(), - new DAVAuthListener_Impl( xEnv ), + new DAVAuthListener_Impl( xEnv, m_aURL ), aHeaders, xEnv ) ); } catch ( DAVException & e ) @@ -719,7 +737,7 @@ void DAVResourceAccess::POST( rOutputStream, DAVRequestEnvironment( getRequestURI(), - new DAVAuthListener_Impl( xEnv ), + new DAVAuthListener_Impl( xEnv, m_aURL ), aHeaders, xEnv ) ); } catch ( DAVException & e ) @@ -762,7 +780,7 @@ void DAVResourceAccess::MKCOL( m_xSession->MKCOL( getRequestURI(), DAVRequestEnvironment( getRequestURI(), - new DAVAuthListener_Impl( xEnv ), + new DAVAuthListener_Impl( xEnv, m_aURL ), aHeaders, xEnv ) ); } catch ( DAVException & e ) @@ -802,7 +820,7 @@ void DAVResourceAccess::COPY( rDestinationURI, DAVRequestEnvironment( getRequestURI(), - new DAVAuthListener_Impl( xEnv ), + new DAVAuthListener_Impl( xEnv, m_aURL ), aHeaders, xEnv ), bOverwrite ); } @@ -843,7 +861,7 @@ void DAVResourceAccess::MOVE( rDestinationURI, DAVRequestEnvironment( getRequestURI(), - new DAVAuthListener_Impl( xEnv ), + new DAVAuthListener_Impl( xEnv, m_aURL ), aHeaders, xEnv ), bOverwrite ); } @@ -882,7 +900,7 @@ void DAVResourceAccess::DESTROY( m_xSession->DESTROY( getRequestURI(), DAVRequestEnvironment( getRequestURI(), - new DAVAuthListener_Impl( xEnv ), + new DAVAuthListener_Impl( xEnv, m_aURL ), aHeaders, xEnv ) ); } catch ( DAVException & e ) diff --git a/ucb/source/ucp/webdav/NeonSession.cxx b/ucb/source/ucp/webdav/NeonSession.cxx index f1028f0dc535..b455ffebbb9b 100644 --- a/ucb/source/ucp/webdav/NeonSession.cxx +++ b/ucb/source/ucp/webdav/NeonSession.cxx @@ -41,8 +41,9 @@ #include <ne_locks.h> #include <ne_ssl.h> #include "libxml/parser.h" -#include <rtl/ustrbuf.hxx> +#include "rtl/ustrbuf.hxx" #include "comphelper/sequence.hxx" +#include "ucbhelper/simplecertificatevalidationrequest.hxx" #include "DAVAuthListener.hxx" #include "NeonTypes.hxx" @@ -51,12 +52,9 @@ #include "NeonPropFindRequest.hxx" #include "NeonHeadRequest.hxx" #include "NeonUri.hxx" -#ifndef _LINKSEQUENCE_HXX_ #include "LinkSequence.hxx" -#endif - -#include <com/sun/star/xml/crypto/XSEInitializer.hpp> #include "UCBDeadPropertyValue.hxx" + #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp> #include <com/sun/star/security/XCertificate.hpp> #include <com/sun/star/security/CertificateValidity.hpp> @@ -64,18 +62,10 @@ #include <com/sun/star/security/CertificateContainer.hpp> #include <com/sun/star/security/XCertificateContainer.hpp> #include <com/sun/star/task/XMasterPasswordHandling.hpp> - - -#ifndef _SIMPLECERTIFICATIONVALIDATIONREQUEST_HXX_ -#include "ucbhelper/simplecertificatevalidationrequest.hxx" -#endif - -#include <cppuhelper/bootstrap.hxx> - +#include <com/sun/star/xml/crypto/XSEInitializer.hpp> using namespace com::sun::star; using namespace webdav_ucp; -using namespace com::sun::star::security; #define SEINITIALIZER_COMPONENT "com.sun.star.xml.crypto.SEInitializer" @@ -258,6 +248,9 @@ extern "C" void NeonSession_ResponseBlockWriter( void * inUserData, // ------------------------------------------------------------------- extern "C" int NeonSession_NeonAuth( void * inUserData, +#ifdef NE_FEATURE_SSPI + const char * inAuthProtocol, +#endif const char * inRealm, int attempt, char * inoutUserName, @@ -274,8 +267,6 @@ extern "C" int NeonSession_NeonAuth( void * inUserData, * cancel the request. (if non-zero, username and password are * ignored.) */ - - #if 0 // Give'em only a limited mumber of retries.. if ( attempt > 9 ) @@ -333,18 +324,41 @@ extern "C" int NeonSession_NeonAuth( void * inUserData, //thePassWord = rtl::OUString::createFromAscii( inoutPassWord ); } - //i97003 (tkr): Ask XMasterPasswordHandling if we should store the credentials persistently and give this information to the SimpleAuthenticationRequest - uno::Reference< ::com::sun::star::task::XMasterPasswordHandling > xMasterPasswordHandling = - uno::Reference< ::com::sun::star::task::XMasterPasswordHandling >( - theSession->getMSF().get()->createInstance( rtl::OUString::createFromAscii( "com.sun.star.task.PasswordContainer" )), uno::UNO_QUERY ); - // - + bool bCanUseSystemCreds = false; + +#ifdef NE_FEATURE_SSPI + bCanUseSystemCreds = (attempt == 0) && // avoid endless loops + ne_has_support( NE_FEATURE_SSPI ) && // Windows-only feature. + ( ne_strcasecmp( inAuthProtocol, "NTLM" ) == 0 ) || + ( ne_strcasecmp( inAuthProtocol, "Negotiate" ) == 0 ); +#endif + + // #i97003# (tkr): Ask XMasterPasswordHandling if we should store the + // credentials persistently and give this information to the auth listener + uno::Reference< task::XMasterPasswordHandling > xMasterPasswordHandling; + try + { + xMasterPasswordHandling = + uno::Reference< task::XMasterPasswordHandling >( + theSession->getMSF()->createInstance( + rtl::OUString::createFromAscii( + "com.sun.star.task.PasswordContainer" )), + uno::UNO_QUERY ); + } + catch ( uno::Exception const & ) + { + } int theRetVal = pListener->authenticate( rtl::OUString::createFromAscii( inRealm ), theSession->getHostName(), theUserName, thePassWord, - xMasterPasswordHandling.is() ? xMasterPasswordHandling->isPersistentStoringAllowed() : sal_False); + xMasterPasswordHandling.is() + ? xMasterPasswordHandling-> + isPersistentStoringAllowed() + : sal_False, + bCanUseSystemCreds); rtl::OString aUser( rtl::OUStringToOString( theUserName, RTL_TEXTENCODING_UTF8 ) ); @@ -371,7 +385,6 @@ extern "C" int NeonSession_NeonAuth( void * inUserData, rtl::OUStringToOString( thePassWord, RTL_TEXTENCODING_UTF8 ) ); return theRetVal; - } // ------------------------------------------------------------------- @@ -381,128 +394,144 @@ namespace { // Helper function ::rtl::OUString GetHostnamePart( const ::rtl::OUString& _rRawString ) { - ::rtl::OUString sPart; - ::rtl::OUString sPartId = ::rtl::OUString::createFromAscii( "CN=" ); - sal_Int32 nContStart = _rRawString.indexOf( sPartId ); - if ( nContStart != -1 ) - { - nContStart = nContStart + sPartId.getLength(); - sal_Int32 nContEnd = _rRawString.indexOf( sal_Unicode( ',' ), nContStart ); - sPart = _rRawString.copy( nContStart, nContEnd - nContStart ); - } - return sPart; + ::rtl::OUString sPart; + ::rtl::OUString sPartId = ::rtl::OUString::createFromAscii( "CN=" ); + sal_Int32 nContStart = _rRawString.indexOf( sPartId ); + if ( nContStart != -1 ) + { + nContStart = nContStart + sPartId.getLength(); + sal_Int32 nContEnd + = _rRawString.indexOf( sal_Unicode( ',' ), nContStart ); + sPart = _rRawString.copy( nContStart, nContEnd - nContStart ); + } + return sPart; } } + // ------------------------------------------------------------------- extern "C" int NeonSession_CertificationNotify( void *userdata, int failures, const ne_ssl_certificate *cert ) { - OSL_ASSERT(cert); - NeonSession * pSession = static_cast< NeonSession * >( userdata ); - uno::Reference< ::com::sun::star::xml::crypto::XSecurityEnvironment > xSecurityEnv; - uno::Reference< ::com::sun::star::security::XCertificateContainer > xCertificateContainer; - + OSL_ASSERT( cert ); - xCertificateContainer = uno::Reference< ::com::sun::star::security::XCertificateContainer >( - pSession->getMSF().get()->createInstance( rtl::OUString::createFromAscii( "com.sun.star.security.CertificateContainer" )), uno::UNO_QUERY ); + NeonSession * pSession = static_cast< NeonSession * >( userdata ); + uno::Reference< security::XCertificateContainer > xCertificateContainer; + try + { + xCertificateContainer + = uno::Reference< security::XCertificateContainer >( + pSession->getMSF()->createInstance( + rtl::OUString::createFromAscii( + "com.sun.star.security.CertificateContainer" ) ), + uno::UNO_QUERY ); + } + catch ( uno::Exception const & ) + { + } - // YD if xmlsecurity is not built (os2), we cannot continue. - if (!xCertificateContainer.is()) + if ( !xCertificateContainer.is() ) return 1; - char * dn; - failures = 0; - dn = ne_ssl_readable_dname( ne_ssl_cert_subject( cert ) ); - + char * dn = ne_ssl_readable_dname( ne_ssl_cert_subject( cert ) ); rtl::OUString cert_subject( dn, strlen( dn ), RTL_TEXTENCODING_UTF8, 0 ); free( dn ); - CertificateContainerStatus certificateContainer; - certificateContainer = xCertificateContainer.get()->hasCertificate( pSession->getHostName(), cert_subject ); + security::CertificateContainerStatus certificateContainer( + xCertificateContainer->hasCertificate( + pSession->getHostName(), cert_subject ) ); + + if ( certificateContainer != security::CertificateContainerStatus_NOCERT ) + return + certificateContainer == security::CertificateContainerStatus_TRUSTED + ? 0 + : 1; - if( certificateContainer != CertificateContainerStatus_NOCERT ) + uno::Reference< xml::crypto::XSEInitializer > xSEInitializer; + try + { + xSEInitializer = uno::Reference< xml::crypto::XSEInitializer >( + pSession->getMSF()->createInstance( + rtl::OUString::createFromAscii( SEINITIALIZER_COMPONENT ) ), + uno::UNO_QUERY ); + } + catch ( uno::Exception const & ) { - if( certificateContainer == CertificateContainerStatus_TRUSTED ) - return 0; - else - return 1; } - rtl::OUString sSEInitializer; - ::com::sun::star::uno::Reference< com::sun::star::xml::crypto::XSEInitializer > mxSEInitializer; - ::com::sun::star::uno::Reference< com::sun::star::xml::crypto::XXMLSecurityContext > mxSecurityContext; - - sSEInitializer = rtl::OUString::createFromAscii( SEINITIALIZER_COMPONENT ); - mxSEInitializer = uno::Reference< com::sun::star::xml::crypto::XSEInitializer > ( - pSession->getMSF().get()->createInstance( sSEInitializer ), uno::UNO_QUERY ); - - if ( mxSEInitializer.is() ) - mxSecurityContext = mxSEInitializer->createSecurityContext( rtl::OUString::createFromAscii( "" ) ); + if ( !xSEInitializer.is() ) + return 1; - xSecurityEnv = mxSecurityContext->getSecurityEnvironment(); + uno::Reference< xml::crypto::XXMLSecurityContext > xSecurityContext( + xSEInitializer->createSecurityContext( rtl::OUString() ) ); + uno::Reference< xml::crypto::XSecurityEnvironment > xSecurityEnv( + xSecurityContext->getSecurityEnvironment() ); //The end entity certificate char * eeCertB64 = ne_ssl_cert_export( cert ); - ::rtl::OString sEECertB64( eeCertB64 ); + rtl::OString sEECertB64( eeCertB64 ); - uno::Reference< com::sun::star::security::XCertificate> xEECert = + uno::Reference< com::sun::star::security::XCertificate > xEECert( xSecurityEnv->createCertificateFromAscii( - ::rtl::OStringToOUString( sEECertB64, RTL_TEXTENCODING_ASCII_US ) ); + rtl::OStringToOUString( sEECertB64, RTL_TEXTENCODING_ASCII_US ) ) ); - free(eeCertB64); - eeCertB64 = NULL; + ne_free( eeCertB64 ); + eeCertB64 = 0; - std::vector<uno::Reference<com::sun::star::security::XCertificate> > vecCerts; + std::vector< uno::Reference< security::XCertificate > > vecCerts; const ne_ssl_certificate * issuerCert = cert; do { //get the intermediate certificate //the returned value is const ! Therfore it does not need to be freed //with ne_ssl_cert_free, which takes a non-const argument - issuerCert = ne_ssl_cert_signedby(issuerCert); - if (NULL == issuerCert) + issuerCert = ne_ssl_cert_signedby( issuerCert ); + if ( NULL == issuerCert ) break; - char * imCertB64 = ne_ssl_cert_export(issuerCert); - ::rtl::OString sInterMediateCertB64(imCertB64); - free(imCertB64); - uno::Reference< com::sun::star::security::XCertificate> xImCert = + char * imCertB64 = ne_ssl_cert_export( issuerCert ); + rtl::OString sInterMediateCertB64( imCertB64 ); + ne_free( imCertB64 ); + + uno::Reference< security::XCertificate> xImCert( xSecurityEnv->createCertificateFromAscii( - ::rtl::OStringToOUString( sInterMediateCertB64, RTL_TEXTENCODING_ASCII_US ) ); - if (xImCert.is()) - vecCerts.push_back(xImCert); - }while (1); + rtl::OStringToOUString( + sInterMediateCertB64, RTL_TEXTENCODING_ASCII_US ) ) ); + if ( xImCert.is() ) + vecCerts.push_back( xImCert ); + } + while ( 1 ); sal_Int64 certValidity = xSecurityEnv->verifyCertificate( xEECert, - ::comphelper::containerToSequence(vecCerts) ); + ::comphelper::containerToSequence( vecCerts ) ); - - if ( pSession->isDomainMatch( GetHostnamePart( xEECert.get()->getSubjectName())) ) + if ( pSession->isDomainMatch( + GetHostnamePart( xEECert.get()->getSubjectName() ) ) ) { - //if host name matched with certificate then look if the certificate was ok - if( certValidity == ::security::CertificateValidity::VALID ) + // if host name matched with certificate then look if the + // certificate was ok + if( certValidity == security::CertificateValidity::VALID ) return 0; } - const uno::Reference< ucb::XCommandEnvironment > xEnv = - pSession->getRequestEnvironment().m_xEnv.get(); - + const uno::Reference< ucb::XCommandEnvironment > xEnv( + pSession->getRequestEnvironment().m_xEnv ); if ( xEnv.is() ) { - failures = static_cast<int>(certValidity); + failures = static_cast< int >( certValidity ); - uno::Reference< task::XInteractionHandler > xIH - = xEnv->getInteractionHandler(); + uno::Reference< task::XInteractionHandler > xIH( + xEnv->getInteractionHandler() ); if ( xIH.is() ) { - rtl::Reference< ucbhelper::SimpleCertificateValidationRequest > xRequest - = new ucbhelper::SimpleCertificateValidationRequest((sal_Int32)failures, xEECert, pSession->getHostName() ); + rtl::Reference< ucbhelper::SimpleCertificateValidationRequest > + xRequest( new ucbhelper::SimpleCertificateValidationRequest( + (sal_Int32)failures, xEECert, pSession->getHostName() ) ); xIH->handle( xRequest.get() ); rtl::Reference< ucbhelper::InteractionContinuation > xSelection @@ -510,31 +539,34 @@ extern "C" int NeonSession_CertificationNotify( void *userdata, if ( xSelection.is() ) { - uno::Reference< task::XInteractionApprove > xApprove( + uno::Reference< task::XInteractionApprove > xApprove( xSelection.get(), uno::UNO_QUERY ); - if ( xApprove.is() ) + if ( xApprove.is() ) { - xCertificateContainer->addCertificate(pSession->getHostName(), cert_subject, sal_True ); + xCertificateContainer->addCertificate( + pSession->getHostName(), cert_subject, sal_True ); return 0; - } else { - // Dont trust Cert - xCertificateContainer->addCertificate(pSession->getHostName(), cert_subject, sal_False ); + } + else + { + // Don't trust cert + xCertificateContainer->addCertificate( + pSession->getHostName(), cert_subject, sal_False ); return 1; } - } - } else + } + else { - // Dont trust Cert - xCertificateContainer->addCertificate(pSession->getHostName(), cert_subject, sal_False ); + // Don't trust cert + xCertificateContainer->addCertificate( + pSession->getHostName(), cert_subject, sal_False ); return 1; } - - } - return 1; } + // ------------------------------------------------------------------- extern "C" void NeonSession_PreSendRequest( ne_request * req, void * userdata, @@ -604,9 +636,10 @@ extern "C" void NeonSession_PreSendRequest( ne_request * req, ++it1; } - } } +} // namespace + // ------------------------------------------------------------------- // Constructor // ------------------------------------------------------------------- @@ -755,7 +788,6 @@ void NeonSession::Init() // ne_buffer *header); ne_hook_pre_send( m_pHttpSession, NeonSession_PreSendRequest, this ); - #if 0 /* Hook called after the request is sent. May return: * NE_OK everything is okay @@ -802,15 +834,8 @@ void NeonSession::Init() ne_redirect_register( m_pHttpSession ); // authentication callbacks. - - // Note: Calling ne_set_[server|proxy]_auth more than once per - // m_pHttpSession instance sometimes(?) crashes Neon! ( last - // checked: 0.22.0) - //ne_set_server_auth( m_pHttpSession, NeonSession_NeonAuth, this ); ne_add_server_auth( m_pHttpSession, NE_AUTH_ALL, NeonSession_NeonAuth, this ); - //ne_set_proxy_auth ( m_pHttpSession, NeonSession_NeonAuth, this ); ne_add_proxy_auth ( m_pHttpSession, NE_AUTH_ALL, NeonSession_NeonAuth, this ); - } } diff --git a/ucb/source/ucp/webdav/makefile.mk b/ucb/source/ucp/webdav/makefile.mk index 496b33b82220..c8891723cd2c 100644 --- a/ucb/source/ucp/webdav/makefile.mk +++ b/ucb/source/ucp/webdav/makefile.mk @@ -50,6 +50,7 @@ NO_BSYMBOLIC=TRUE # --- Settings --------------------------------------------------------- .INCLUDE: settings.mk +.IF "$(L10N_framework)"=="" .IF "$(DISABLE_NEON)" == "TRUE" @@ -160,6 +161,7 @@ DEF1NAME=$(SHL1TARGET) .ENDIF #"$(DISABLE_NEON)" == "TRUE" +.ENDIF # L10N_framework # --- Targets ---------------------------------------------------------- .INCLUDE: target.mk diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx index e4c33a274b17..996fd24e531d 100644 --- a/uui/source/iahndl.cxx +++ b/uui/source/iahndl.cxx @@ -68,6 +68,8 @@ #include "com/sun/star/task/ErrorCodeRequest.hpp" #include "com/sun/star/task/MasterPasswordRequest.hpp" #include "com/sun/star/task/NoMasterException.hpp" +#include "com/sun/star/task/DocumentMacroConfirmationRequest.hpp" +#include "com/sun/star/task/DocumentMacroConfirmationRequest2.hpp" #include "com/sun/star/task/XInteractionAbort.hpp" #include "com/sun/star/task/XInteractionApprove.hpp" #include "com/sun/star/task/XInteractionDisapprove.hpp" @@ -75,8 +77,10 @@ #include "com/sun/star/task/XInteractionRequest.hpp" #include "com/sun/star/task/XInteractionRetry.hpp" #include "com/sun/star/task/XPasswordContainer.hpp" +#include "com/sun/star/task/XUrlContainer.hpp" #include "com/sun/star/task/XInteractionAskLater.hpp" #include "com/sun/star/ucb/AuthenticationRequest.hpp" +#include "com/sun/star/ucb/URLAuthenticationRequest.hpp" #include "com/sun/star/ucb/CertificateValidationRequest.hpp" #include "com/sun/star/ucb/HandleCookiesRequest.hpp" #include "com/sun/star/ucb/InteractiveAppException.hpp" @@ -97,22 +101,24 @@ #include "com/sun/star/ucb/XInteractionCookieHandling.hpp" #include "com/sun/star/ucb/XInteractionReplaceExistingData.hpp" #include "com/sun/star/ucb/XInteractionSupplyAuthentication.hpp" +#include "com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp" #include "com/sun/star/ucb/XInteractionSupplyName.hpp" #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #include "com/sun/star/uno/RuntimeException.hpp" #include "com/sun/star/xforms/InvalidDataOnSubmitException.hpp" #include <com/sun/star/security/CertificateValidity.hpp> +#include <com/sun/star/lang/XInitialization.hpp> #include "vos/mutex.hxx" #include "tools/rcid.h" #include "vcl/svapp.hxx" #include "svtools/svtools.hrc" -#include "svtools/loginerr.hxx" #include "svtools/httpcook.hxx" #include "svtools/sfxecode.hxx" #include "toolkit/helper/vclunohelper.hxx" #include "comphelper/sequenceashashmap.hxx" +#include "comphelper/documentconstants.hxx" #include "unotools/configmgr.hxx" #include "ids.hrc" @@ -131,6 +137,8 @@ #include "filechanged.hxx" #include "trylater.hxx" #include "lockfailed.hxx" +#include "loginerr.hxx" + #include <comphelper/processfactory.hxx> #include <svtools/zforlist.hxx> using namespace com::sun; @@ -198,6 +206,8 @@ getContinuations( star::uno::Reference< star::task::XInteractionAbort > * pAbort, star::uno::Reference< star::ucb::XInteractionSupplyAuthentication > * pSupplyAuthentication, + star::uno::Reference< star::ucb::XInteractionSupplyAuthentication2 > * + pSupplyAuthentication2, star::uno::Reference< star::task::XInteractionPassword > * pPassword, star::uno::Reference< star::ucb::XInteractionSupplyName > * pSupplyName, @@ -244,7 +254,16 @@ getContinuations( star::ucb::XInteractionSupplyAuthentication >( rContinuations[i], star::uno::UNO_QUERY); if (pSupplyAuthentication->is()) + { + // is it even a supplyauthentication2, which is derived from + // supplyauthentication? + if (pSupplyAuthentication2 && !pSupplyAuthentication2->is()) + *pSupplyAuthentication2 + = star::uno::Reference< + star::ucb::XInteractionSupplyAuthentication2 >( + rContinuations[i], star::uno::UNO_QUERY); continue; + } } if (pPassword && !pPassword->is()) { @@ -607,7 +626,7 @@ bool UUIInteractionHelper::handleMessageboxRequests( star::task::XInteractionDisapprove > xDisapprove; getContinuations( rRequest->getContinuations(), - &xApprove, &xDisapprove, 0, 0, 0, 0, 0, 0); + &xApprove, &xDisapprove, 0, 0, 0, 0, 0, 0, 0); if( xApprove.is() && xDisapprove.is() ) { @@ -1094,11 +1113,21 @@ bool UUIInteractionHelper::handleDialogRequests( { star::uno::Any aAnyRequest(rRequest->getRequest()); + star::ucb::URLAuthenticationRequest aURLAuthenticationRequest; + if (aAnyRequest >>= aURLAuthenticationRequest) + { + handleAuthenticationRequest(aURLAuthenticationRequest, + rRequest->getContinuations(), + aURLAuthenticationRequest.URL); + return true; + } + star::ucb::AuthenticationRequest aAuthenticationRequest; if (aAnyRequest >>= aAuthenticationRequest) { handleAuthenticationRequest(aAuthenticationRequest, - rRequest->getContinuations()); + rRequest->getContinuations(), + rtl::OUString()); return true; } @@ -1255,7 +1284,23 @@ bool UUIInteractionHelper::handleErrorHandlerRequests( if (aAnyRequest >>= aMacroConfirmRequest) { handleMacroConfirmRequest( - aMacroConfirmRequest, + aMacroConfirmRequest.DocumentURL, + aMacroConfirmRequest.DocumentStorage, + ODFVER_012_TEXT, + aMacroConfirmRequest.DocumentSignatureInformation, + rRequest->getContinuations() + ); + return true; + } + + star::task::DocumentMacroConfirmationRequest2 aMacroConfirmRequest2; + if (aAnyRequest >>= aMacroConfirmRequest2) + { + handleMacroConfirmRequest( + aMacroConfirmRequest2.DocumentURL, + aMacroConfirmRequest2.DocumentZipStorage, + aMacroConfirmRequest2.DocumentVersion, + aMacroConfirmRequest2.DocumentSignatureInformation, rRequest->getContinuations() ); return true; @@ -1326,10 +1371,29 @@ UUIInteractionHelper::handle_impl( Reference< uno::XInterface > xIfc = m_xServiceFactory->createInstance(aIt->ServiceName); - Reference< com::sun::star::task::XInteractionHandler2 > xInteractionHandler = - Reference< com::sun::star::task::XInteractionHandler2 >( xIfc, UNO_QUERY ); - OSL_ENSURE( xInteractionHandler.is(), "Custom Interactionhandler does not implement mandatory interface XInteractionHandler2!" ); + Reference< com::sun::star::lang::XInitialization > xInitialization = + Reference< com::sun::star::lang::XInitialization >( xIfc, UNO_QUERY ); + + OSL_ENSURE( xInitialization.is(), "Custom Interactionhandler does not implement mandatory interface XInitialization!" ); + if (xInitialization.is()) + { + uno::Sequence< uno::Any > propertyValues(1);
+ beans::PropertyValue aProperty;
+
+ aProperty.Name = rtl::OUString::createFromAscii( "Parent" );
+ aProperty.Value <<= getParentXWindow(); + propertyValues[ 0 ] <<= aProperty; + + xInitialization->initialize(propertyValues); + } + + Reference< task::XInteractionHandler2 > + xInteractionHandler( xIfc, UNO_QUERY ); + + OSL_ENSURE( xInteractionHandler.is(), + "Custom Interactionhandler does not implement " + "mandatory interface XInteractionHandler2!" ); if (xInteractionHandler.is()) if (xInteractionHandler->handleInteractionRequest(rRequest)) return true; @@ -1457,6 +1521,15 @@ void UUIInteractionHelper::GetInteractionHandlerList(InteractionHandlerDataList Window * UUIInteractionHelper::getParentProperty() SAL_THROW(()) { + star::uno::Reference< star::awt::XWindow > xWindow = getParentXWindow(); + if ( xWindow.is() ) + return VCLUnoHelper::GetWindow(xWindow); + + return 0; +} + +star::uno::Reference< ::com::sun::star::awt::XWindow> UUIInteractionHelper::getParentXWindow() SAL_THROW(()) +{ osl::MutexGuard aGuard(m_aPropertyMutex); for (sal_Int32 i = 0; i < m_aProperties.getLength(); ++i) { @@ -1467,7 +1540,7 @@ Window * UUIInteractionHelper::getParentProperty() SAL_THROW(()) { star::uno::Reference< star::awt::XWindow > xWindow; aProperty.Value >>= xWindow; - return VCLUnoHelper::GetWindow(xWindow); + return xWindow; } } return 0; @@ -1493,7 +1566,8 @@ rtl::OUString UUIInteractionHelper::getContextProperty() SAL_THROW(()) bool UUIInteractionHelper::initPasswordContainer( - star::uno::Reference< star::task::XPasswordContainer > * pContainer) + star::uno::Reference< star::task::XPasswordContainer > * pContainer, + star::uno::Reference< star::task::XUrlContainer > * pUrlContainer) const SAL_THROW(()) { OSL_ENSURE(pContainer, "specification violation"); @@ -1508,11 +1582,17 @@ UUIInteractionHelper::initPasswordContainer( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.PasswordContainer"))), star::uno::UNO_QUERY); + + if ( pContainer->is() ) + { + *pUrlContainer = star::uno::Reference< star::task::XUrlContainer >( *pContainer, UNO_QUERY ); + OSL_ENSURE( pUrlContainer->is(), "Got no XUrlContainer!" ); + } } catch (star::uno::Exception const &) {} OSL_ENSURE(pContainer->is(), "unexpected situation"); - return pContainer->is(); + return pContainer->is() && pUrlContainer->is(); } @@ -1691,6 +1771,7 @@ void UUIInteractionHelper::executeLoginDialog(LoginErrorInfo & rInfo, != 0; bool bSavePassword = rInfo.GetIsPersistentPassword() || rInfo.GetIsSavePassword(); + bool bCanUseSysCreds = rInfo.GetCanUseSystemCredentials(); sal_uInt16 nFlags = 0; if (rInfo.GetPath().Len() == 0) @@ -1705,6 +1786,9 @@ void UUIInteractionHelper::executeLoginDialog(LoginErrorInfo & rInfo, if (!bSavePassword) nFlags |= LF_NO_SAVEPASSWORD; + if (!bCanUseSysCreds) + nFlags |= LF_NO_USESYSCREDS; + std::auto_ptr< ResMgr > xManager(ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui))); UniString aRealm(rRealm); // Forte compiler needs it spelled out... @@ -1733,12 +1817,18 @@ void UUIInteractionHelper::executeLoginDialog(LoginErrorInfo & rInfo, xDialog->SetSavePassword(rInfo.GetIsSavePassword()); } + if ( bCanUseSysCreds ) + xDialog->SetUseSystemCredentials( rInfo.GetIsUseSystemCredentials() ); + rInfo.SetResult(xDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL); rInfo.SetUserName(xDialog->GetName()); rInfo.SetPassword(xDialog->GetPassword()); rInfo.SetAccount(xDialog->GetAccount()); rInfo.SetSavePassword(xDialog->IsSavePassword()); + + if ( bCanUseSysCreds ) + rInfo.SetIsUseSystemCredentials( xDialog->IsUseSystemCredentials() ); } catch (std::bad_alloc const &) { @@ -2100,12 +2190,87 @@ UUIInteractionHelper::getInteractionHandler() const return xIH; } +namespace +{ +bool fillContinuation( + bool bUseSystemCredentials, + const star::ucb::AuthenticationRequest & rRequest, + const star::task::UrlRecord & aRec, + const star::uno::Reference< star::ucb::XInteractionSupplyAuthentication > & + xSupplyAuthentication, + const star::uno::Reference< star::ucb::XInteractionSupplyAuthentication2 > & + xSupplyAuthentication2, + bool bCanUseSystemCredentials, + bool bCheckForEqualPasswords ) +{ + if ( bUseSystemCredentials ) + { + // "use system creds" record found. + // Wants client that we use it? + if ( xSupplyAuthentication2.is() && + bCanUseSystemCredentials ) + { + xSupplyAuthentication2->setUseSystemCredentials( sal_True ); + return true; + } + return false; + } + else if (aRec.UserList.getLength() != 0) + { + if (aRec.UserList[0].Passwords.getLength() == 0) + { + // Password sequence can be empty, for instance if master + // password was not given (e.g. master pw dialog canceled) + // pw container does not throw NoMasterException in this case. + // bug??? + return false; + } + + // "user/pass" record found. + if (!bCheckForEqualPasswords || !rRequest.HasPassword + || rRequest.Password != aRec.UserList[0].Passwords[0]) // failed login attempt? + { + if (xSupplyAuthentication->canSetUserName()) + xSupplyAuthentication-> + setUserName(aRec.UserList[0].UserName.getStr()); + + if (xSupplyAuthentication->canSetPassword()) + xSupplyAuthentication-> + setPassword(aRec.UserList[0].Passwords[0].getStr()); + if (aRec.UserList[0].Passwords.getLength() > 1) + { + if (rRequest.HasRealm) + { + if (xSupplyAuthentication->canSetRealm()) + xSupplyAuthentication-> + setRealm(aRec.UserList[0].Passwords[1]. + getStr()); + } + else if (xSupplyAuthentication->canSetAccount()) + xSupplyAuthentication-> + setAccount(aRec.UserList[0].Passwords[1]. + getStr()); + } + + if ( xSupplyAuthentication2.is() && + bCanUseSystemCredentials ) + xSupplyAuthentication2->setUseSystemCredentials( sal_False ); + + return true; + } + } + return false; +} + +} + void UUIInteractionHelper::handleAuthenticationRequest( star::ucb::AuthenticationRequest const & rRequest, star::uno::Sequence< star::uno::Reference< star::task::XInteractionContinuation > > const & - rContinuations) + rContinuations, + const rtl::OUString & rURL) SAL_THROW((star::uno::RuntimeException)) { star::uno::Reference< star::task::XInteractionHandler > xIH; @@ -2114,9 +2279,12 @@ UUIInteractionHelper::handleAuthenticationRequest( star::uno::Reference< star::task::XInteractionAbort > xAbort; star::uno::Reference< star::ucb::XInteractionSupplyAuthentication > xSupplyAuthentication; + star::uno::Reference< star::ucb::XInteractionSupplyAuthentication2 > + xSupplyAuthentication2; getContinuations( rContinuations, - 0, 0, &xRetry, &xAbort, &xSupplyAuthentication, 0, 0, 0 ); + 0, 0, &xRetry, &xAbort, + &xSupplyAuthentication, &xSupplyAuthentication2, 0, 0, 0 ); bool bRemember; bool bRememberPersistent; if (xSupplyAuthentication.is()) @@ -2139,90 +2307,103 @@ UUIInteractionHelper::handleAuthenticationRequest( bRememberPersistent = false; } + sal_Bool bCanUseSystemCredentials; + sal_Bool bDefaultUseSystemCredentials; + if (xSupplyAuthentication2.is()) + { + bCanUseSystemCredentials + = xSupplyAuthentication2->canUseSystemCredentials( + bDefaultUseSystemCredentials ); + } + else + { + bCanUseSystemCredentials = sal_False; + bDefaultUseSystemCredentials = sal_False; + } + com::sun::star::uno::Reference< com::sun::star::task::XPasswordContainer > xContainer; + com::sun::star::uno::Reference< com::sun::star::task::XUrlContainer > + xUrlContainer; + + if ( bCanUseSystemCredentials && initPasswordContainer( &xContainer, &xUrlContainer ) ) + { + // Runtime / Persistent info avail for current auth request? + + rtl::OUString aResult = xUrlContainer->findUrl( + rURL.getLength() ? rURL : rRequest.ServerName ); + if ( aResult.getLength() > 0 ) + { + if ( fillContinuation( true, + rRequest, + star::task::UrlRecord(), + xSupplyAuthentication, + xSupplyAuthentication2, + bCanUseSystemCredentials, + false ) ) + { + xSupplyAuthentication->select(); + return; + } + } + } // xContainer works with userName passwdSequences pairs: if (rRequest.HasUserName && rRequest.HasPassword - && initPasswordContainer(&xContainer)) + && initPasswordContainer(&xContainer, &xUrlContainer)) { xIH = getInteractionHandler(); try { if (rRequest.UserName.getLength() == 0) { - star::task::UrlRecord - aRec(xContainer->find(rRequest.ServerName, xIH)); - if (aRec.UserList.getLength() != 0) + star::task::UrlRecord aRec; + if ( rURL.getLength() ) + aRec = xContainer->find(rURL, xIH); + + if ( aRec.UserList.getLength() == 0 ) + { + // compat: try server name. + aRec = xContainer->find(rRequest.ServerName, xIH); + } + + if ( fillContinuation( false, + rRequest, + aRec, + xSupplyAuthentication, + xSupplyAuthentication2, + bCanUseSystemCredentials, + false ) ) { - if (xSupplyAuthentication->canSetUserName()) - xSupplyAuthentication-> - setUserName(aRec.UserList[0].UserName.getStr()); - if (xSupplyAuthentication->canSetPassword()) - { - OSL_ENSURE(aRec.UserList[0].Passwords.getLength() != 0, - "empty password list"); - xSupplyAuthentication-> - setPassword( - aRec.UserList[0].Passwords[0].getStr()); - } - if (aRec.UserList[0].Passwords.getLength() > 1) - { - if (rRequest.HasRealm) - { - if (xSupplyAuthentication->canSetRealm()) - xSupplyAuthentication-> - setRealm(aRec.UserList[0].Passwords[1]. - getStr()); - } - else if (xSupplyAuthentication->canSetAccount()) - xSupplyAuthentication-> - setAccount(aRec.UserList[0].Passwords[1]. - getStr()); - } xSupplyAuthentication->select(); return; } } else { - star::task::UrlRecord - aRec(xContainer->findForName(rRequest.ServerName, - rRequest.UserName, - xIH)); - if (aRec.UserList.getLength() != 0) + star::task::UrlRecord aRec; + if ( rURL.getLength() ) + aRec = xContainer->findForName( + rURL, rRequest.UserName, xIH); + + if ( aRec.UserList.getLength() == 0 ) { - OSL_ENSURE(aRec.UserList[0].Passwords.getLength() != 0, - "empty password list"); - if (!rRequest.HasPassword - || rRequest.Password != aRec.UserList[0].Passwords[0]) - { - if (xSupplyAuthentication->canSetUserName()) - xSupplyAuthentication-> - setUserName( - aRec.UserList[0].UserName.getStr()); - if (xSupplyAuthentication->canSetPassword()) - xSupplyAuthentication-> - setPassword(aRec.UserList[0].Passwords[0]. - getStr()); - if (aRec.UserList[0].Passwords.getLength() > 1) - { - if (rRequest.HasRealm) - { - if (xSupplyAuthentication->canSetRealm()) - xSupplyAuthentication-> - setRealm(aRec.UserList[0].Passwords[1]. - getStr()); - } - else if (xSupplyAuthentication->canSetAccount()) - xSupplyAuthentication-> - setAccount(aRec.UserList[0].Passwords[1]. - getStr()); - } - xSupplyAuthentication->select(); - return; - } + // compat: try server name. + aRec = xContainer->findForName( + rRequest.ServerName, rRequest.UserName, xIH); + } + + if ( fillContinuation( false, + rRequest, + aRec, + xSupplyAuthentication, + xSupplyAuthentication2, + bCanUseSystemCredentials, + true ) ) + { + xSupplyAuthentication->select(); + return; } } } @@ -2242,6 +2423,8 @@ UUIInteractionHelper::handleAuthenticationRequest( aInfo.SetErrorText(rRequest.Diagnostic); aInfo.SetPersistentPassword(bRememberPersistent); aInfo.SetSavePassword(bRemember); + aInfo.SetCanUseSystemCredentials( bCanUseSystemCredentials ); + aInfo.SetIsUseSystemCredentials( bDefaultUseSystemCredentials ); aInfo.SetModifyAccount(rRequest.HasAccount && xSupplyAuthentication.is() && xSupplyAuthentication->canSetAccount()); @@ -2274,34 +2457,51 @@ UUIInteractionHelper::handleAuthenticationRequest( else if (xSupplyAuthentication->canSetAccount()) xSupplyAuthentication->setAccount(aInfo.GetAccount()); + if ( xSupplyAuthentication2.is() && bCanUseSystemCredentials ) + xSupplyAuthentication2->setUseSystemCredentials( + aInfo.GetIsUseSystemCredentials() ); + xSupplyAuthentication->select(); } - // Empty user name can not be valid: - if (aInfo.GetUserName().Len() != 0 - && initPasswordContainer(&xContainer)) + + if ( aInfo.GetIsUseSystemCredentials() ) + { + if (aInfo.GetIsSavePassword()) + { + if ( initPasswordContainer(&xContainer, &xUrlContainer) ) + xUrlContainer->addUrl( + rURL.getLength() ? rURL : rRequest.ServerName, + bRememberPersistent ); + } + } + else if (aInfo.GetUserName().Len() != 0 // Empty user name can not be valid: + && initPasswordContainer(&xContainer, &xUrlContainer)) { - star::uno::Sequence< rtl::OUString > - aPassList(aInfo.GetAccount().Len() == 0 ? 1 : 2); - aPassList[0] = aInfo.GetPassword(); - if (aInfo.GetAccount().Len() != 0) - aPassList[1] = aInfo.GetAccount(); try { if (aInfo.GetIsSavePassword()) { + star::uno::Sequence< rtl::OUString > + aPassList(aInfo.GetAccount().Len() == 0 ? 1 : 2); + aPassList[0] = aInfo.GetPassword(); + if (aInfo.GetAccount().Len() != 0) + aPassList[1] = aInfo.GetAccount(); + if (!xIH.is()) xIH = getInteractionHandler(); if (bRememberPersistent) - xContainer->addPersistent(rRequest.ServerName, - aInfo.GetUserName(), - aPassList, - xIH); + xContainer->addPersistent( + rURL.getLength() ? rURL : rRequest.ServerName, + aInfo.GetUserName(), + aPassList, + xIH); else - xContainer->add(rRequest.ServerName, - aInfo.GetUserName(), - aPassList, - xIH); + xContainer->add( + rURL.getLength() ? rURL : rRequest.ServerName, + aInfo.GetUserName(), + aPassList, + xIH); } } catch (star::task::NoMasterException const &) @@ -2356,7 +2556,7 @@ UUIInteractionHelper::handleCertificateValidationRequest( star::uno::Reference< star::task::XInteractionAbort > xAbort; getContinuations( - rContinuations, &xApprove, 0, 0, &xAbort, 0, 0, 0, 0); + rContinuations, &xApprove, 0, 0, &xAbort, 0, 0, 0, 0, 0); sal_Int32 failures = rRequest.CertificateValidity; @@ -2483,7 +2683,7 @@ UUIInteractionHelper::handleNameClashResolveRequest( xReplaceExistingData; getContinuations( rContinuations, - 0, 0, 0, &xAbort, 0, 0, &xSupplyName, &xReplaceExistingData); + 0, 0, 0, &xAbort, 0, 0, 0, &xSupplyName, &xReplaceExistingData); OSL_ENSURE( xAbort.is(), "NameClashResolveRequest must contain Abort continuation" ); @@ -2544,7 +2744,7 @@ UUIInteractionHelper::handleMasterPasswordRequest( xSupplyAuthentication; getContinuations( rContinuations, - 0, 0, &xRetry, &xAbort, &xSupplyAuthentication, 0, 0, 0); + 0, 0, &xRetry, &xAbort, &xSupplyAuthentication, 0, 0, 0, 0); LoginErrorInfo aInfo; // in case of master password a hash code is returned @@ -2587,7 +2787,7 @@ UUIInteractionHelper::handlePasswordRequest( star::uno::Reference< star::task::XInteractionPassword > xPassword; getContinuations( - rContinuations, 0, 0, &xRetry, &xAbort, 0, &xPassword, 0, 0); + rContinuations, 0, 0, &xRetry, &xAbort, 0, 0, &xPassword, 0, 0); LoginErrorInfo aInfo; executePasswordDialog(aInfo, nMode, aDocumentName); @@ -2628,7 +2828,7 @@ UUIInteractionHelper::handleMSPasswordRequest( star::uno::Reference< star::task::XInteractionPassword > xPassword; getContinuations( - rContinuations, 0, 0, &xRetry, &xAbort, 0, &xPassword, 0, 0); + rContinuations, 0, 0, &xRetry, &xAbort, 0, 0, &xPassword, 0, 0); LoginErrorInfo aInfo; executeMSPasswordDialog(aInfo, nMode, aDocumentName); @@ -3044,13 +3244,13 @@ UUIInteractionHelper::handleGenericErrorRequest( ErrCode nError = (ErrCode)nErrorCode; sal_Bool bWarning = !ERRCODE_TOERROR(nError); - if ( nError == ERRCODE_SFX_BROKENSIGNATURE ) + if ( nError == ERRCODE_SFX_BROKENSIGNATURE + || nError == ERRCODE_SFX_INCOMPLETE_ENCRYPTION ) { - // the broken signature warning needs a special title + // the security warning need a special title String aErrorString; ErrorHandler::GetErrorString( nErrorCode, aErrorString ); - std::auto_ptr< ResMgr > xManager( ResMgr::CreateResMgr( CREATEVERSIONRESMGR_NAME( uui ) ) ); ::rtl::OUString aTitle; @@ -3064,7 +3264,8 @@ UUIInteractionHelper::handleGenericErrorRequest( } catch( star::uno::Exception& ) {} - ::rtl::OUString aErrTitle = String( ResId( STR_WARNING_BROKENSIGNATURE_TITLE, *xManager.get() ) ); + ::rtl::OUString aErrTitle = String( ResId( nError == ERRCODE_SFX_BROKENSIGNATURE ? STR_WARNING_BROKENSIGNATURE_TITLE : STR_WARNING_INCOMPLETE_ENCRYPTION_TITLE, *xManager.get() ) ); + if ( aTitle.getLength() && aErrTitle.getLength() ) aTitle += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " - " ) ); aTitle += aErrTitle; @@ -3100,7 +3301,10 @@ namespace void UUIInteractionHelper::handleMacroConfirmRequest( - const star::task::DocumentMacroConfirmationRequest& _rRequest, + const ::rtl::OUString& aDocumentURL, + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xZipStorage, + const ::rtl::OUString& aDocumentVersion, + const ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation > aSignInfo, star::uno::Sequence< star::uno::Reference< star::task::XInteractionContinuation > > const & rContinuations ) @@ -3114,17 +3318,17 @@ UUIInteractionHelper::handleMacroConfirmRequest( std::auto_ptr< ResMgr > pResMgr( ResMgr::CreateResMgr( CREATEVERSIONRESMGR_NAME( uui ) ) ); if ( pResMgr.get() ) { - bool bShowSignatures = _rRequest.DocumentSignatureInformation.getLength() > 0; + bool bShowSignatures = aSignInfo.getLength() > 0; MacroWarning aWarning( getParentProperty(), bShowSignatures, *pResMgr.get() ); - aWarning.SetDocumentURL( _rRequest.DocumentURL ); - if ( _rRequest.DocumentSignatureInformation.getLength() > 1 ) + aWarning.SetDocumentURL( aDocumentURL ); + if ( aSignInfo.getLength() > 1 ) { - aWarning.SetStorage( _rRequest.DocumentStorage, _rRequest.DocumentSignatureInformation ); + aWarning.SetStorage( xZipStorage, aDocumentVersion, aSignInfo ); } - else if ( _rRequest.DocumentSignatureInformation.getLength() == 1 ) + else if ( aSignInfo.getLength() == 1 ) { - aWarning.SetCertificate( _rRequest.DocumentSignatureInformation[ 0 ].Signer ); + aWarning.SetCertificate( aSignInfo[ 0 ].Signer ); } bApprove = aWarning.Execute() == RET_OK; @@ -3385,7 +3589,7 @@ UUIInteractionHelper::handleErrorRequest( star::uno::Reference< star::task::XInteractionAbort > xAbort; getContinuations( rContinuations, - &xApprove, &xDisapprove, &xRetry, &xAbort, 0, 0, 0, 0); + &xApprove, &xDisapprove, &xRetry, &xAbort, 0, 0, 0, 0, 0); // The following mapping uses the bit mask // Approve = 8, @@ -3503,7 +3707,7 @@ UUIInteractionHelper::handleBrokenPackageRequest( star::uno::Reference< star::task::XInteractionDisapprove > xDisapprove; star::uno::Reference< star::task::XInteractionAbort > xAbort; getContinuations( - rContinuations, &xApprove, &xDisapprove, 0, &xAbort, 0, 0, 0, 0); + rContinuations, &xApprove, &xDisapprove, 0, &xAbort, 0, 0, 0, 0, 0); ErrCode nErrorCode; if( xApprove.is() && xDisapprove.is() ) @@ -3608,7 +3812,7 @@ UUIInteractionHelper::handleLockedDocumentRequest( star::uno::Reference< star::task::XInteractionDisapprove > xDisapprove; star::uno::Reference< star::task::XInteractionAbort > xAbort; getContinuations( - rContinuations, &xApprove, &xDisapprove, 0, &xAbort, 0, 0, 0, 0); + rContinuations, &xApprove, &xDisapprove, 0, &xAbort, 0, 0, 0, 0, 0); if ( !xApprove.is() || !xDisapprove.is() || !xAbort.is() ) return; @@ -3686,7 +3890,7 @@ UUIInteractionHelper::handleChangedByOthersRequest( star::uno::Reference< star::task::XInteractionApprove > xApprove; star::uno::Reference< star::task::XInteractionAbort > xAbort; getContinuations( - rContinuations, &xApprove, 0, 0, &xAbort, 0, 0, 0, 0); + rContinuations, &xApprove, 0, 0, &xAbort, 0, 0, 0, 0, 0); if ( !xApprove.is() || !xAbort.is() ) return; @@ -3726,7 +3930,7 @@ UUIInteractionHelper::handleLockFileIgnoreRequest( star::uno::Reference< star::task::XInteractionApprove > xApprove; star::uno::Reference< star::task::XInteractionAbort > xAbort; getContinuations( - rContinuations, &xApprove, 0, 0, &xAbort, 0, 0, 0, 0); + rContinuations, &xApprove, 0, 0, &xAbort, 0, 0, 0, 0, 0); if ( !xApprove.is() || !xAbort.is() ) return; diff --git a/uui/source/iahndl.hxx b/uui/source/iahndl.hxx index e8ae3fec2df5..bea53e436c6d 100644 --- a/uui/source/iahndl.hxx +++ b/uui/source/iahndl.hxx @@ -36,13 +36,15 @@ #define INCLUDED_VECTOR #endif #include "osl/mutex.hxx" -#include "com/sun/star/beans/Optional.hpp" #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/Sequence.hxx" + +#include "com/sun/star/beans/Optional.hpp" +#include "com/sun/star/embed/XStorage.hpp" #include "com/sun/star/task/InteractionClassification.hpp" #include "com/sun/star/task/PasswordRequestMode.hpp" -#include "com/sun/star/task/DocumentMacroConfirmationRequest.hpp" #include "com/sun/star/task/FutureDocumentVersionProductUpdateRequest.hpp" +#include "com/sun/star/security/DocumentSignatureInformation.hpp" #include "tools/solar.h" #include "tools/errcode.hxx" #include "vcl/wintypes.hxx" @@ -98,6 +100,7 @@ namespace com { namespace sun { namespace star { class XInteractionHandler; class XInteractionRequest; class XPasswordContainer; + class XUrlContainer; } namespace ucb { class AuthenticationRequest; @@ -174,12 +177,17 @@ private: Window * getParentProperty() SAL_THROW(()); + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> getParentXWindow() SAL_THROW(()); + rtl::OUString getContextProperty() SAL_THROW(()); bool initPasswordContainer(com::sun::star::uno::Reference< com::sun::star::task::XPasswordContainer > * - pContainer) + pContainer, + com::sun::star::uno::Reference< + com::sun::star::task::XUrlContainer > * + pUrlContainer) const SAL_THROW(()); com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler > @@ -246,7 +254,8 @@ private: com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::task::XInteractionContinuation > > const & - rContinuations) + rContinuations, + rtl::OUString const & rURL) SAL_THROW((com::sun::star::uno::RuntimeException)); void @@ -360,7 +369,10 @@ private: void handleMacroConfirmRequest( - const ::com::sun::star::task::DocumentMacroConfirmationRequest& _rRequest, + const ::rtl::OUString& aDocumentURL, + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xZipStorage, + const ::rtl::OUString& aDocumentVersion, + const ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation > aSignInfo, com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::task::XInteractionContinuation > > const & diff --git a/uui/source/ids.hrc b/uui/source/ids.hrc index bfe6a48aed94..08624a3dda4e 100644 --- a/uui/source/ids.hrc +++ b/uui/source/ids.hrc @@ -87,7 +87,8 @@ #define STR_ALREADYOPEN_SAVE_MSG (RID_UUI_START + 50) #define STR_ALREADYOPEN_RETRY_SAVE_BTN (RID_UUI_START + 51) #define STR_ALREADYOPEN_SAVE_BTN (RID_UUI_START + 52) -#define RID_DLG_NEWER_VERSION_WARNING (RID_UUI_START + 36) +#define RID_DLG_NEWER_VERSION_WARNING (RID_UUI_START + 53) +#define STR_WARNING_INCOMPLETE_ENCRYPTION_TITLE (RID_UUI_START + 54) #define ERRCODE_UUI_IO_ABORT (ERRCODE_AREA_UUI + 0) #define ERRCODE_UUI_IO_ACCESSDENIED (ERRCODE_AREA_UUI + 1) diff --git a/uui/source/ids.src b/uui/source/ids.src index 3f0e422c1449..cb011f27a7c0 100644 --- a/uui/source/ids.src +++ b/uui/source/ids.src @@ -50,6 +50,11 @@ String( STR_WARNING_BROKENSIGNATURE_TITLE ) Text [ en-US ] = "Invalid Document Signature" ; }; +String( STR_WARNING_INCOMPLETE_ENCRYPTION_TITLE ) +{ + Text [ en-US ] = "Non-Encrypted Streams" ; +}; + Resource RID_UUI_ERRHDL { String (ERRCODE_UUI_IO_ABORT & ERRCODE_RES_MASK) @@ -313,7 +318,7 @@ Resource RID_UUI_ERRHDL String (ERRCODE_UUI_IO_BROKENPACKAGE & ERRCODE_RES_MASK) { - Text [ en-US ] = "The file '$(ARG1)' is corrupt and therefore cannot be opened. Should %PRODUCTNAME repair the file?"; + Text [ en-US ] = "The file '$(ARG1)' is corrupt and therefore cannot be opened. %PRODUCTNAME can try to repair the file.\n\nThe corruption could be the result of document manipulation or of structural document damage due to data transmission.\n\nWe recommend that you do not trust the content of the repaired document.\nExecution of macros is disabled for this document.\n\nShould %PRODUCTNAME repair the file?\n"; }; String (ERRCODE_UUI_IO_BROKENPACKAGE_CANTREPAIR & ERRCODE_RES_MASK) diff --git a/uui/source/logindlg.cxx b/uui/source/logindlg.cxx index 4d58e07e37da..195dcaaf2648 100644 --- a/uui/source/logindlg.cxx +++ b/uui/source/logindlg.cxx @@ -55,6 +55,7 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) FASTBOOL bPathHide = FALSE; FASTBOOL bErrorHide = FALSE; FASTBOOL bAccountHide = FALSE; + FASTBOOL bUseSysCredsHide = FALSE; if ( ( nFlags & LF_NO_PATH ) == LF_NO_PATH ) { @@ -104,6 +105,12 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) bAccountHide = TRUE; } + if ( ( nFlags & LF_NO_USESYSCREDS ) == LF_NO_USESYSCREDS ) + { + aUseSysCredsCB.Hide(); + bUseSysCredsHide = TRUE; + } + if ( bErrorHide ) { long nOffset = aLoginGB.GetPosPixel().Y() - @@ -147,6 +154,9 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) aNewPnt = aSavePasswdBtn.GetPosPixel(); aNewPnt.Y() -= nOffset; aSavePasswdBtn.SetPosPixel( aNewPnt ); + aNewPnt = aUseSysCredsCB.GetPosPixel(); + aNewPnt.Y() -= nOffset; + aUseSysCredsCB.SetPosPixel( aNewPnt ); aNewPnt = aLoginGB.GetPosPixel(); aNewPnt.Y() -= nOffset; aLoginGB.SetPosPixel( aNewPnt ); @@ -174,6 +184,9 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) aTmpPnt1 = aSavePasswdBtn.GetPosPixel(); aTmpPnt1.Y() -= nOffset; aSavePasswdBtn.SetPosPixel( aTmpPnt1 ); + aTmpPnt1 = aUseSysCredsCB.GetPosPixel(); + aTmpPnt1.Y() -= nOffset; + aUseSysCredsCB.SetPosPixel( aTmpPnt1 ); Size aNewSz = GetSizePixel(); aNewSz.Height() -= nOffset; SetSizePixel( aNewSz ); @@ -186,6 +199,19 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) Point aTmpPnt = aSavePasswdBtn.GetPosPixel(); aTmpPnt.Y() -= nOffset; aSavePasswdBtn.SetPosPixel( aTmpPnt ); + aTmpPnt = aUseSysCredsCB.GetPosPixel(); + aTmpPnt.Y() -= nOffset; + aUseSysCredsCB.SetPosPixel( aTmpPnt ); + Size aNewSz = GetSizePixel(); + aNewSz.Height() -= nOffset; + SetSizePixel( aNewSz ); + } + + if ( bUseSysCredsHide ) + { + long nOffset = aUseSysCredsCB.GetPosPixel().Y() - + aSavePasswdBtn.GetPosPixel().Y(); + Size aNewSz = GetSizePixel(); aNewSz.Height() -= nOffset; SetSizePixel( aNewSz ); @@ -193,6 +219,25 @@ void LoginDialog::HideControls_Impl( USHORT nFlags ) }; // ----------------------------------------------------------------------- +void LoginDialog::EnableUseSysCredsControls_Impl( BOOL bUseSysCredsEnabled ) +{ + aErrorInfo.Enable( !bUseSysCredsEnabled ); + aErrorGB.Enable( !bUseSysCredsEnabled ); + aRequestInfo.Enable( !bUseSysCredsEnabled ); + aPathFT.Enable( !bUseSysCredsEnabled ); + aPathED.Enable( !bUseSysCredsEnabled ); + aPathInfo.Enable( !bUseSysCredsEnabled ); + aPathBtn.Enable( !bUseSysCredsEnabled ); + aNameFT.Enable( !bUseSysCredsEnabled ); + aNameED.Enable( !bUseSysCredsEnabled ); + aNameInfo.Enable( !bUseSysCredsEnabled ); + aPasswordFT.Enable( !bUseSysCredsEnabled ); + aPasswordED.Enable( !bUseSysCredsEnabled ); + aAccountFT.Enable( !bUseSysCredsEnabled ); + aAccountED.Enable( !bUseSysCredsEnabled ); +} + +// ----------------------------------------------------------------------- IMPL_LINK( LoginDialog, OKHdl_Impl, OKButton *, EMPTYARG ) { @@ -221,6 +266,14 @@ IMPL_LINK( LoginDialog, PathHdl_Impl, PushButton *, EMPTYARG ) // ----------------------------------------------------------------------- +IMPL_LINK( LoginDialog, UseSysCredsHdl_Impl, CheckBox *, EMPTYARG ) +{ + EnableUseSysCredsControls_Impl( aUseSysCredsCB.IsChecked() ); + return 1; +} + +// ----------------------------------------------------------------------- + LoginDialog::LoginDialog ( Window* pParent, @@ -247,6 +300,7 @@ LoginDialog::LoginDialog aAccountFT ( this, ResId( FT_LOGIN_ACCOUNT, *pResMgr ) ), aAccountED ( this, ResId( ED_LOGIN_ACCOUNT, *pResMgr ) ), aSavePasswdBtn ( this, ResId( CB_LOGIN_SAVEPASSWORD, *pResMgr ) ), + aUseSysCredsCB ( this, ResId( CB_LOGIN_USESYSCREDS, *pResMgr ) ), aLoginGB ( this, ResId( GB_LOGIN_LOGIN, *pResMgr ) ), aOKBtn ( this, ResId( BTN_LOGIN_OK, *pResMgr ) ), aCancelBtn ( this, ResId( BTN_LOGIN_CANCEL, *pResMgr ) ), @@ -261,6 +315,10 @@ LoginDialog::LoginDialog } else aRequest = aRequestInfo.GetText(); + + if ( !( ( nFlags & LF_NO_USESYSCREDS ) == LF_NO_USESYSCREDS ) ) + EnableUseSysCredsControls_Impl( aUseSysCredsCB.IsChecked() ); + aRequest.SearchAndReplaceAscii("%1", rServer); aRequestInfo.SetText(aRequest); @@ -271,6 +329,7 @@ LoginDialog::LoginDialog aOKBtn.SetClickHdl( LINK( this, LoginDialog, OKHdl_Impl ) ); aPathBtn.SetClickHdl( LINK( this, LoginDialog, PathHdl_Impl ) ); + aUseSysCredsCB.SetClickHdl( LINK( this, LoginDialog, UseSysCredsHdl_Impl ) ); HideControls_Impl( nFlags ); }; @@ -285,6 +344,17 @@ void LoginDialog::SetName( const String& rNewName ) // ----------------------------------------------------------------------- +void LoginDialog::SetUseSystemCredentials( BOOL bUse ) +{ + if ( aUseSysCredsCB.IsVisible() ) + { + aUseSysCredsCB.Check( bUse ); + EnableUseSysCredsControls_Impl( bUse ); + } +} + +// ----------------------------------------------------------------------- + void LoginDialog::ClearPassword() { aPasswordED.SetText( String() ); diff --git a/uui/source/logindlg.hrc b/uui/source/logindlg.hrc index 20b5a5c86d46..a9c1ff853d85 100644 --- a/uui/source/logindlg.hrc +++ b/uui/source/logindlg.hrc @@ -50,6 +50,7 @@ #define ED_LOGIN_ACCOUNT 31 #define CB_LOGIN_SAVEPASSWORD 32 #define GB_LOGIN_LOGIN 33 +#define CB_LOGIN_USESYSCREDS 34 #define BTN_LOGIN_OK 50 #define BTN_LOGIN_CANCEL 51 diff --git a/uui/source/logindlg.hxx b/uui/source/logindlg.hxx index a6e92797d26f..c88bc7a93aad 100644 --- a/uui/source/logindlg.hxx +++ b/uui/source/logindlg.hxx @@ -48,6 +48,7 @@ #define LF_PATH_READONLY 0x0020 // "path" readonly #define LF_USERNAME_READONLY 0x0040 // "name" readonly #define LF_NO_ACCOUNT 0x0080 // hide "account" +#define LF_NO_USESYSCREDS 0x0100 // hide "use system cedentials" //............................................................................ //............................................................................ @@ -70,15 +71,18 @@ class LoginDialog : public ModalDialog FixedText aAccountFT; Edit aAccountED; CheckBox aSavePasswdBtn; + CheckBox aUseSysCredsCB; FixedLine aLoginGB; OKButton aOKBtn; CancelButton aCancelBtn; HelpButton aHelpBtn; void HideControls_Impl( USHORT nFlags ); + void EnableUseSysCredsControls_Impl( BOOL bUseSysCredsEnabled ); DECL_LINK( OKHdl_Impl, OKButton * ); DECL_LINK( PathHdl_Impl, PushButton * ); + DECL_LINK( UseSysCredsHdl_Impl, CheckBox * ); public: LoginDialog( Window* pParent, USHORT nFlags, @@ -103,6 +107,9 @@ public: { aSavePasswdBtn.Check( bSave ); } void SetSavePasswordText( const String& rTxt ) { aSavePasswdBtn.SetText( rTxt ); } + BOOL IsUseSystemCredentials() const + { return aUseSysCredsCB.IsChecked(); } + void SetUseSystemCredentials( BOOL bUse ); void SetErrorText( const String& rTxt ) { aErrorInfo.SetText( rTxt ); } void SetLoginRequestText( const String& rTxt ) diff --git a/uui/source/logindlg.src b/uui/source/logindlg.src index 39b98ffea1a4..7450a389e7e5 100644 --- a/uui/source/logindlg.src +++ b/uui/source/logindlg.src @@ -45,7 +45,7 @@ ModalDialog DLG_UUI_LOGIN Moveable = TRUE ; OutputSize = TRUE ; SVLook = TRUE ; - Size = MAP_APPFONT ( 265 , 158 ) ; + Size = MAP_APPFONT ( 265 , 170 ) ; FixedText INFO_LOGIN_ERROR { Pos = MAP_APPFONT ( 12 , 14 ) ; @@ -139,6 +139,12 @@ ModalDialog DLG_UUI_LOGIN Size = MAP_APPFONT ( 185 , 10 ) ; Text [ en-US ] = "~Save password" ; }; + CheckBox CB_LOGIN_USESYSCREDS + { + Pos = MAP_APPFONT ( 12 , 148 ) ; + Size = MAP_APPFONT ( 185 , 10 ) ; + Text [ en-US ] = "~Use System Credentials" ; + }; FixedLine GB_LOGIN_LOGIN { Pos = MAP_APPFONT ( 7 , 44 ) ; diff --git a/uui/source/loginerr.hxx b/uui/source/loginerr.hxx new file mode 100644 index 000000000000..6fc00c3b1eac --- /dev/null +++ b/uui/source/loginerr.hxx @@ -0,0 +1,158 @@ +/************************************************************************* + * + * 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: loginerr.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _LOGINERR_HXX +#define _LOGINERR_HXX + +#include <tools/string.hxx> + +//========================================================================= + +#define LOGINERROR_FLAG_SET_SAVE_PASSWORD 1 +#define LOGINERROR_FLAG_MODIFY_ACCOUNT 2 +#define LOGINERROR_FLAG_MODIFY_USER_NAME 4 +#define LOGINERROR_FLAG_PERSISTENT_PASSWORD 8 +#define LOGINERROR_FLAG_CAN_USE_SYSCREDS 16 +#define LOGINERROR_FLAG_IS_USE_SYSCREDS 32 + +class LoginErrorInfo +{ +private: + String _aTitle; + String _aServer; + String _aAccount; + String _aUserName; + String _aPassword; + String _aPath; + String _aErrorText; + BYTE _nFlags; + USHORT _nRet; + +public: + LoginErrorInfo() + : _nFlags( LOGINERROR_FLAG_MODIFY_USER_NAME ), + _nRet( ERRCODE_BUTTON_CANCEL ) + { + } + + const String& GetTitle() const { return _aTitle; } + const String& GetServer() const { return _aServer; } + const String& GetAccount() const { return _aAccount; } + const String& GetUserName() const { return _aUserName; } + const String& GetPassword() const { return _aPassword; } + const String& GetPath() const { return _aPath; } + const String& GetErrorText() const { return _aErrorText; } + BOOL GetIsPersistentPassword() const + { return ( _nFlags & LOGINERROR_FLAG_PERSISTENT_PASSWORD ); } + BOOL GetIsSavePassword() const + { return ( _nFlags & LOGINERROR_FLAG_SET_SAVE_PASSWORD ); } + BOOL GetCanUseSystemCredentials() const + { return ( _nFlags & LOGINERROR_FLAG_CAN_USE_SYSCREDS ); } + BOOL GetIsUseSystemCredentials() const + { return ( _nFlags & LOGINERROR_FLAG_IS_USE_SYSCREDS ) == + LOGINERROR_FLAG_IS_USE_SYSCREDS; } + BYTE GetFlags() const { return _nFlags; } + USHORT GetResult() const { return _nRet; } + + void SetTitle( const String& aTitle ) + { _aTitle = aTitle; } + void SetServer( const String& aServer ) + { _aServer = aServer; } + void SetAccount( const String& aAccount ) + { _aAccount = aAccount; } + void SetUserName( const String& aUserName ) + { _aUserName = aUserName; } + void SetPassword( const String& aPassword ) + { _aPassword = aPassword; } + void SetPath( const String& aPath ) + { _aPath = aPath; } + void SetErrorText( const String& aErrorText ) + { _aErrorText = aErrorText; } + void SetFlags( BYTE nFlags ) + { _nFlags = nFlags; } + inline void SetSavePassword( BOOL bSet ); + inline void SetPersistentPassword( BOOL bSet ); + inline void SetCanUseSystemCredentials( BOOL bSet ); + inline void SetIsUseSystemCredentials( BOOL bSet ); + inline void SetModifyAccount( BOOL bSet ); + inline void SetModifyUserName( BOOL bSet ); + void SetResult( USHORT nRet ) + { _nRet = nRet; } +}; + +inline void LoginErrorInfo::SetSavePassword( BOOL bSet ) +{ + if ( bSet ) + _nFlags |= LOGINERROR_FLAG_SET_SAVE_PASSWORD; + else + _nFlags &= ~LOGINERROR_FLAG_SET_SAVE_PASSWORD; +} + +inline void LoginErrorInfo::SetPersistentPassword( BOOL bSet ) +{ + if ( bSet ) + _nFlags |= LOGINERROR_FLAG_PERSISTENT_PASSWORD; + else + _nFlags &= ~LOGINERROR_FLAG_PERSISTENT_PASSWORD; +} + +inline void LoginErrorInfo::SetCanUseSystemCredentials( BOOL bSet ) +{ + if ( bSet ) + _nFlags |= LOGINERROR_FLAG_CAN_USE_SYSCREDS; + else + _nFlags &= ~LOGINERROR_FLAG_CAN_USE_SYSCREDS; +} + +inline void LoginErrorInfo::SetIsUseSystemCredentials( BOOL bSet ) +{ + if ( bSet ) + _nFlags |= LOGINERROR_FLAG_IS_USE_SYSCREDS; + else + _nFlags &= ~LOGINERROR_FLAG_IS_USE_SYSCREDS; +} + +inline void LoginErrorInfo::SetModifyAccount( BOOL bSet ) +{ + if ( bSet ) + _nFlags |= LOGINERROR_FLAG_MODIFY_ACCOUNT; + else + _nFlags &= ~LOGINERROR_FLAG_MODIFY_ACCOUNT; +} + +inline void LoginErrorInfo::SetModifyUserName( BOOL bSet ) +{ + if ( bSet ) + _nFlags |= LOGINERROR_FLAG_MODIFY_USER_NAME; + else + _nFlags &= ~LOGINERROR_FLAG_MODIFY_USER_NAME; +} + +#endif diff --git a/uui/source/masterpassworddlg.src b/uui/source/masterpassworddlg.src index 88e0993b8a2d..ad0f025febea 100644 --- a/uui/source/masterpassworddlg.src +++ b/uui/source/masterpassworddlg.src @@ -58,10 +58,10 @@ ModalDialog DLG_UUI_MASTERPASSWORD Size = MAP_APPFONT ( 169 , 13 ) ; PassWord = TRUE ; }; - FixedLine FL_FIXED_LINE
- {
- Pos = MAP_APPFONT( 0, 35 );
- Size = MAP_APPFONT( 175, 6 );
+ FixedLine FL_FIXED_LINE + { + Pos = MAP_APPFONT( 0, 35 ); + Size = MAP_APPFONT( 175, 6 ); }; OKButton BTN_MASTERPASSWORD_OK diff --git a/uui/source/passcrtdlg.cxx b/uui/source/passcrtdlg.cxx index 636cd4510ecc..a6db44697918 100644 --- a/uui/source/passcrtdlg.cxx +++ b/uui/source/passcrtdlg.cxx @@ -61,6 +61,7 @@ IMPL_LINK( PasswordCreateDialog, OKHdl_Impl, OKButton *, EMPTYARG ) String aErrorMsg( ResId( STR_ERROR_PASSWORDS_NOT_IDENTICAL, *pResourceMgr )); ErrorBox aErrorBox( this, WB_OK, aErrorMsg ); aErrorBox.Execute(); + aEDPasswordCrt.SetText( String() ); aEDPasswordRepeat.SetText( String() ); aEDPasswordCrt.GrabFocus(); } @@ -81,7 +82,7 @@ PasswordCreateDialog::PasswordCreateDialog( Window* _pParent, ResMgr * pResMgr, ,aCancelBtn ( this, ResId( BTN_PASSCRT_CANCEL, *pResMgr ) ) ,aHelpBtn ( this, ResId( BTN_PASSCRT_HELP, *pResMgr ) ) ,pResourceMgr ( pResMgr ) - ,nMinLen( bMSCryptoMode ? 1 : 5 ) + ,nMinLen(1) // if it should be changed for ODF, it must stay 1 for bMSCryptoMode { FreeResource(); diff --git a/uui/source/passcrtdlg.hrc b/uui/source/passcrtdlg.hrc index 54a09494e2ab..c36bec4bc9a6 100644 --- a/uui/source/passcrtdlg.hrc +++ b/uui/source/passcrtdlg.hrc @@ -43,5 +43,4 @@ #define FT_PASSWORD_CRT 9 #define FT_MSPASSWORD_WARNING 10 - #endif // UUI_PASSCRTDLG_HRC diff --git a/uui/source/passcrtdlg.src b/uui/source/passcrtdlg.src index 13f1ea688620..81629d955343 100644 --- a/uui/source/passcrtdlg.src +++ b/uui/source/passcrtdlg.src @@ -91,7 +91,7 @@ ModalDialog DLG_UUI_PASSWORD_CRT { Pos = MAP_APPFONT( 4, 64 ); Size = MAP_APPFONT( 137, 40 ); - Text [ en-US ] = "WARNING: If you lose or forget the password, it cannot be recovered. It is advisable to keep passwords in a safe place. Passwords are case-sensitive and at least five characters long."; + Text [ en-US ] = "WARNING: If you lose or forget the password, it cannot be recovered. It is advisable to keep passwords in a safe place. Passwords are case-sensitive."; WordBreak = TRUE; }; FixedText FT_MSPASSWORD_WARNING diff --git a/uui/source/passworddlg.hrc b/uui/source/passworddlg.hrc index 37938b0228ae..95a5e8a78673 100644 --- a/uui/source/passworddlg.hrc +++ b/uui/source/passworddlg.hrc @@ -28,16 +28,16 @@ * ************************************************************************/ -#ifndef PASSWORDDLG_HRC
-#define PASSWORDDLG_HRC
+#ifndef PASSWORDDLG_HRC +#define PASSWORDDLG_HRC -// local identifiers
-#define BTN_PASSWORD_OK 1
-#define ED_PASSWORD 2
-#define FT_PASSWORD 3
-#define FL_FIXED_LINE_1 4
-#define BTN_PASSWORD_HELP 5
-#define BTN_PASSWORD_CANCEL 6
+// local identifiers +#define BTN_PASSWORD_OK 1 +#define ED_PASSWORD 2 +#define FT_PASSWORD 3 +#define FL_FIXED_LINE_1 4 +#define BTN_PASSWORD_HELP 5 +#define BTN_PASSWORD_CANCEL 6 -#endif // PASSWORDDLG_HRC
+#endif // PASSWORDDLG_HRC diff --git a/uui/source/passworddlg.src b/uui/source/passworddlg.src index 41845b7488d1..c9b8dfe0847e 100644 --- a/uui/source/passworddlg.src +++ b/uui/source/passworddlg.src @@ -50,7 +50,7 @@ ModalDialog DLG_UUI_PASSWORD { Pos = MAP_APPFONT( 3, 4 ); Size = MAP_APPFONT( 139, 28 ); - Text [ en-US ] = "Enter password to open the file: \n"; + Text [ en-US ] = "Enter password to open file: \n"; WordBreak = TRUE; }; @@ -67,6 +67,7 @@ ModalDialog DLG_UUI_PASSWORD Pos = MAP_APPFONT( 27, 56 ); Size = MAP_APPFONT( 37, 15 ); DefButton = TRUE ; + DefButton = TRUE; }; CancelButton BTN_PASSWORD_CANCEL diff --git a/uui/source/secmacrowarnings.cxx b/uui/source/secmacrowarnings.cxx index 0b2759cbbde8..776c3b4385f2 100644 --- a/uui/source/secmacrowarnings.cxx +++ b/uui/source/secmacrowarnings.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/security/XDocumentDigitalSignatures.hpp> #include <comphelper/sequence.hxx> +#include "comphelper/documentconstants.hxx" #include <comphelper/processfactory.hxx> #include <vcl/msgbox.hxx> @@ -122,8 +123,10 @@ IMPL_LINK( MacroWarning, ViewSignsBtnHdl, void*, EMPTYARG ) { DBG_ASSERT( mxCert.is(), "*MacroWarning::ViewSignsBtnHdl(): no certificate set!" ); + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[0] = uno::makeAny( maODFVersion ); uno::Reference< security::XDocumentDigitalSignatures > xD( - comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), uno::UNO_QUERY ); + comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ), aArgs ), uno::UNO_QUERY ); if( xD.is() ) { if( mxCert.is() ) @@ -139,8 +142,10 @@ IMPL_LINK( MacroWarning, EnableBtnHdl, void*, EMPTYARG ) { if( mbSignedMode && maAlwaysTrustCB.IsChecked() ) { // insert path into trusted path list + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[0] = uno::makeAny( maODFVersion ); uno::Reference< security::XDocumentDigitalSignatures > xD( - comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), uno::UNO_QUERY ); + comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ), aArgs ), uno::UNO_QUERY ); if( xD.is() ) { if( mxCert.is() ) @@ -337,21 +342,23 @@ void MacroWarning::FitControls() } void MacroWarning::SetStorage( const cssu::Reference < css::embed::XStorage >& rxStore, - const cssu::Sequence< security::DocumentSignatureInformation >& _rInfos ) + const ::rtl::OUString& aODFVersion, + const cssu::Sequence< security::DocumentSignatureInformation >& rInfos ) { mxStore = rxStore; - sal_Int32 nCnt = _rInfos.getLength(); + maODFVersion = aODFVersion; + sal_Int32 nCnt = rInfos.getLength(); if( mxStore.is() && nCnt > 0 ) { - mpInfos = &_rInfos; + mpInfos = &rInfos; String aCN_Id( String::CreateFromAscii( "CN" ) ); String s; - s = GetContentPart( _rInfos[ 0 ].Signer->getSubjectName(), aCN_Id ); + s = GetContentPart( rInfos[ 0 ].Signer->getSubjectName(), aCN_Id ); for( sal_Int32 i = 1 ; i < nCnt ; ++i ) { s.AppendAscii( "\n" ); - s += GetContentPart( _rInfos[ i ].Signer->getSubjectName(), aCN_Id ); + s += GetContentPart( rInfos[ i ].Signer->getSubjectName(), aCN_Id ); } maSignsFI.SetText( s ); diff --git a/uui/source/secmacrowarnings.hxx b/uui/source/secmacrowarnings.hxx index a3bac1dcdb9f..17280ecbbac1 100644 --- a/uui/source/secmacrowarnings.hxx +++ b/uui/source/secmacrowarnings.hxx @@ -60,6 +60,7 @@ private: cssu::Reference< css::security::XCertificate > mxCert; cssu::Reference< css::embed::XStorage > mxStore; + ::rtl::OUString maODFVersion; const cssu::Sequence< css::security::DocumentSignatureInformation >* mpInfos; FixedImage maSymbolImg; @@ -96,6 +97,7 @@ public: void SetDocumentURL( const String& rDocURL ); void SetStorage( const cssu::Reference < css::embed::XStorage >& rxStore, + const ::rtl::OUString& aODFVersion, const cssu::Sequence< css::security::DocumentSignatureInformation >& _rInfos ); void SetCertificate( const cssu::Reference< css::security::XCertificate >& _rxCert ); }; diff --git a/xmlhelp/inc/xmlhelp/compilehelp.hxx b/xmlhelp/inc/xmlhelp/compilehelp.hxx deleted file mode 100644 index 7e4712977d21..000000000000 --- a/xmlhelp/inc/xmlhelp/compilehelp.hxx +++ /dev/null @@ -1,70 +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: compilehelp.hxx,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef COMPILE_HXX -#define COMPILE_HXX - -#include <xmlhelp/helplinkerdllapi.h> -#include <rtl/ustring.hxx> - -enum HelpProcessingErrorClass -{ - HELPPROCESSING_NO_ERROR, - HELPPROCESSING_GENERAL_ERROR, // Missing files, options etc. - HELPPROCESSING_INTERNAL_ERROR, // Unexpected problems - HELPPROCESSING_XMLPARSING_ERROR // Errors thrown by libxml -}; - -struct HelpProcessingErrorInfo -{ - HelpProcessingErrorClass m_eErrorClass; - rtl::OUString m_aErrorMsg; - rtl::OUString m_aXMLParsingFile; - sal_Int32 m_nXMLParsingLine; - - HelpProcessingErrorInfo( void ) - : m_eErrorClass( HELPPROCESSING_NO_ERROR ) - , m_nXMLParsingLine( -1 ) - {} - - HelpProcessingErrorInfo& operator=( const struct HelpProcessingException& e ); -}; - - -// Returns true in case of success, false in case of error -HELPLINKER_DLLPUBLIC bool compileExtensionHelp -( - const rtl::OUString& aExtensionName, - const rtl::OUString& aExtensionLanguageRoot, - sal_Int32 nXhpFileCount, const rtl::OUString* pXhpFiles, - HelpProcessingErrorInfo& o_rHelpProcessingErrorInfo -); - -#endif diff --git a/xmlhelp/inc/xmlhelp/helplinkerdllapi.h b/xmlhelp/inc/xmlhelp/helplinkerdllapi.h deleted file mode 100644 index e2454a3f8b19..000000000000 --- a/xmlhelp/inc/xmlhelp/helplinkerdllapi.h +++ /dev/null @@ -1,44 +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: helplinkerdllapi.h,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef INCLUDED_HELPLINKERDLLAPI_H -#define INCLUDED_HELPLINKERDLLAPI_H - -#include "sal/types.h" - -#if defined(HELPLINKER_DLLIMPLEMENTATION) -#define HELPLINKER_DLLPUBLIC SAL_DLLPUBLIC_EXPORT -#else -#define HELPLINKER_DLLPUBLIC SAL_DLLPUBLIC_IMPORT -#endif -#define HELPLINKER_DLLPRIVATE SAL_DLLPRIVATE - -#endif /* INCLUDED_HELPLINKERDLLAPI_H */ - diff --git a/xmlhelp/prj/build.lst b/xmlhelp/prj/build.lst index b360e5f763ee..3f468f593a1a 100644 --- a/xmlhelp/prj/build.lst +++ b/xmlhelp/prj/build.lst @@ -1,4 +1,4 @@ -xh xmlhelp : ucbhelper LIBXSLT:libxslt unoil BERKELEYDB:berkeleydb svtools LUCENE:lucene unotools javaunohelper NULL +xh xmlhelp : ucbhelper transex3 LIBXSLT:libxslt unoil BERKELEYDB:berkeleydb svtools LUCENE:lucene unotools javaunohelper NULL xh xmlhelp usr1 - all xh_mkout NULL xh xmlhelp\inc nmake - all xh_inc NULL xh xmlhelp\source\treeview nmake - all xh_treeview xh_inc NULL diff --git a/xmlhelp/source/com/sun/star/help/HelpCompiler.cxx b/xmlhelp/source/com/sun/star/help/HelpCompiler.cxx deleted file mode 100644 index 5001d0907972..000000000000 --- a/xmlhelp/source/com/sun/star/help/HelpCompiler.cxx +++ /dev/null @@ -1,593 +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: HelpCompiler.cxx,v $ - * $Revision: 1.9 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#include "HelpCompiler.hxx" -#include <limits.h> -#include <stdlib.h> -#include <string.h> -#include <libxslt/xslt.h> -#include <libxslt/xsltInternals.h> -#include <libxslt/transform.h> -#include <libxslt/xsltutils.h> -#ifdef __MINGW32__ -#include <tools/prewin.h> -#include <tools/postwin.h> -#endif -#include <osl/thread.hxx> - -static void impl_sleep( sal_uInt32 nSec ) -{ - TimeValue aTime; - aTime.Seconds = nSec; - aTime.Nanosec = 0; - - osl::Thread::wait( aTime ); -} - -HelpCompiler::HelpCompiler(StreamTable &in_streamTable, const fs::path &in_inputFile, - const fs::path &in_src, const fs::path &in_resEmbStylesheet, - const std::string &in_module, const std::string &in_lang, bool in_bExtensionMode) - : streamTable(in_streamTable), inputFile(in_inputFile), - src(in_src), module(in_module), lang(in_lang), resEmbStylesheet(in_resEmbStylesheet), - bExtensionMode( in_bExtensionMode ) -{ - xmlKeepBlanksDefaultValue = 0; -} - -xmlDocPtr HelpCompiler::getSourceDocument(const fs::path &filePath) -{ - static const char *params[4 + 1]; - static xsltStylesheetPtr cur = NULL; - - xmlDocPtr res; - if( bExtensionMode ) - { - res = xmlParseFile(filePath.native_file_string().c_str()); - if( !res ){ - impl_sleep( 3 ); - res = xmlParseFile(filePath.native_file_string().c_str()); - } - } - else - { - if (!cur) - { - static std::string fsroot('\'' + src.toUTF8() + '\''); - static std::string esclang('\'' + lang + '\''); - - xmlSubstituteEntitiesDefault(1); - xmlLoadExtDtdDefaultValue = 1; - cur = xsltParseStylesheetFile((const xmlChar *)resEmbStylesheet.native_file_string().c_str()); - - int nbparams = 0; - params[nbparams++] = "Language"; - params[nbparams++] = esclang.c_str(); - params[nbparams++] = "fsroot"; - params[nbparams++] = fsroot.c_str(); - params[nbparams] = NULL; - } - xmlDocPtr doc = xmlParseFile(filePath.native_file_string().c_str()); - if( !doc ) - { - impl_sleep( 3 ); - doc = xmlParseFile(filePath.native_file_string().c_str()); - } - - //???res = xmlParseFile(filePath.native_file_string().c_str()); - - res = xsltApplyStylesheet(cur, doc, params); - xmlFreeDoc(doc); - } - return res; -} - -HashSet HelpCompiler::switchFind(xmlDocPtr doc) -{ - HashSet hs; - xmlChar *xpath = (xmlChar*)"//switchinline"; - - xmlXPathContextPtr context = xmlXPathNewContext(doc); - xmlXPathObjectPtr result = xmlXPathEvalExpression(xpath, context); - xmlXPathFreeContext(context); - if (result) - { - xmlNodeSetPtr nodeset = result->nodesetval; - for (int i = 0; i < nodeset->nodeNr; i++) - { - xmlNodePtr el = nodeset->nodeTab[i]; - xmlChar *select = xmlGetProp(el, (xmlChar*)"select"); - if (select) - { - if (!strcmp((const char*)select, "appl")) - { - xmlNodePtr n1 = el->xmlChildrenNode; - while (n1) - { - if ((!xmlStrcmp(n1->name, (const xmlChar*)"caseinline"))) - { - xmlChar *appl = xmlGetProp(n1, (xmlChar*)"select"); - hs.push_back(std::string((const char*)appl)); - xmlFree(appl); - } - else if ((!xmlStrcmp(n1->name, (const xmlChar*)"defaultinline"))) - hs.push_back(std::string("DEFAULT")); - n1 = n1->next; - } - } - xmlFree(select); - } - } - xmlXPathFreeObject(result); - } - hs.push_back(std::string("DEFAULT")); - return hs; -} - -// returns a node representing the whole stuff compiled for the current -// application. -xmlNodePtr HelpCompiler::clone(xmlNodePtr node, const std::string& appl) -{ - xmlNodePtr parent = xmlCopyNode(node, 2); - xmlNodePtr n = node->xmlChildrenNode; - while (n != NULL) - { - bool isappl = false; - if ( (!strcmp((const char*)n->name, "switchinline")) || - (!strcmp((const char*)n->name, "switch")) ) - { - xmlChar *select = xmlGetProp(n, (xmlChar*)"select"); - if (select) - { - if (!strcmp((const char*)select, "appl")) - isappl = true; - xmlFree(select); - } - } - if (isappl) - { - xmlNodePtr caseNode = n->xmlChildrenNode; - if (appl == "DEFAULT") - { - while (caseNode) - { - if (!strcmp((const char*)caseNode->name, "defaultinline")) - { - xmlNodePtr cnl = caseNode->xmlChildrenNode; - while (cnl) - { - xmlAddChild(parent, clone(cnl, appl)); - cnl = cnl->next; - } - break; - } - caseNode = caseNode->next; - } - } - else - { - while (caseNode) - { - isappl=false; - if (!strcmp((const char*)caseNode->name, "caseinline")) - { - xmlChar *select = xmlGetProp(n, (xmlChar*)"select"); - if (select) - { - if (!strcmp((const char*)select, appl.c_str())) - isappl = true; - xmlFree(select); - } - if (isappl) - { - xmlNodePtr cnl = caseNode->xmlChildrenNode; - while (cnl) - { - xmlAddChild(parent, clone(cnl, appl)); - cnl = cnl->next; - } - break; - } - - } - caseNode = caseNode->next; - } - } - - } - else - xmlAddChild(parent, clone(n, appl)); - - n = n->next; - } - return parent; -} - -class myparser -{ -public: - std::string documentId; - std::string fileName; - std::string title; - HashSet *hidlist; - Hashtable *keywords; - Stringtable *helptexts; -private: - HashSet extendedHelpText; -public: - myparser(const std::string &indocumentId, const std::string &infileName, - const std::string &intitle) : documentId(indocumentId), fileName(infileName), - title(intitle) - { - hidlist = new HashSet; - keywords = new Hashtable; - helptexts = new Stringtable; - } - void traverse( xmlNodePtr parentNode ); -private: - std::string dump(xmlNodePtr node); -}; - -std::string myparser::dump(xmlNodePtr node) -{ - std::string app; - if (node->xmlChildrenNode) - { - xmlNodePtr list = node->xmlChildrenNode; - while (list) - { - app += dump(list); - list = list->next; - } - } - if (xmlNodeIsText(node)) - { - xmlChar *pContent = xmlNodeGetContent(node); - app += std::string((const char*)pContent); - xmlFree(pContent); - // std::cout << app << std::endl; - } - return app; -} - -void trim(std::string& str) -{ - std::string::size_type pos = str.find_last_not_of(' '); - if(pos != std::string::npos) - { - str.erase(pos + 1); - pos = str.find_first_not_of(' '); - if(pos != std::string::npos) - str.erase(0, pos); - } - else - str.erase(str.begin(), str.end()); -} - -void myparser::traverse( xmlNodePtr parentNode ) -{ - // traverse all nodes that belong to the parent - xmlNodePtr test ; - for (test = parentNode->xmlChildrenNode; test; test = test->next) - { - if (fileName.empty() && !strcmp((const char*)test->name, "filename")) - { - xmlNodePtr node = test->xmlChildrenNode; - if (xmlNodeIsText(node)) - { - xmlChar *pContent = xmlNodeGetContent(node); - fileName = std::string((const char*)pContent); - xmlFree(pContent); - } - } - else if (title.empty() && !strcmp((const char*)test->name, "title")) - { - title = dump(test); - if (title.empty()) - title = "<notitle>"; - } - else if (!strcmp((const char*)test->name, "bookmark")) - { - xmlChar *branchxml = xmlGetProp(test, (const xmlChar*)"branch"); - xmlChar *idxml = xmlGetProp(test, (const xmlChar*)"id"); - std::string branch((const char*)branchxml); - std::string anchor((const char*)idxml); - xmlFree (branchxml); - xmlFree (idxml); - - std::string hid; - - if (branch.find("hid") == 0) - { - size_t index = branch.find('/'); - if (index != std::string::npos) - { - hid = branch.substr(1 + index); - // one shall serve as a documentId - if (documentId.empty()) - documentId = hid; - extendedHelpText.push_back(hid); - std::string foo = anchor.empty() ? hid : hid + "#" + anchor; - HCDBG(std::cerr << "hid pushback" << foo << std::endl); - hidlist->push_back( anchor.empty() ? hid : hid + "#" + anchor); - } - else - continue; - } - else if (branch.compare("index") == 0) - { - LinkedList ll; - - for (xmlNodePtr nd = test->xmlChildrenNode; nd; nd = nd->next) - { - if (strcmp((const char*)nd->name, "bookmark_value")) - continue; - - std::string embedded; - xmlChar *embeddedxml = xmlGetProp(nd, (const xmlChar*)"embedded"); - if (embeddedxml) - { - embedded = std::string((const char*)embeddedxml); - xmlFree (embeddedxml); - std::transform (embedded.begin(), embedded.end(), - embedded.begin(), tolower); - } - - bool isEmbedded = !embedded.empty() && embedded.compare("true") == 0; - if (isEmbedded) - continue; - - std::string keyword = dump(nd); - size_t keywordSem = keyword.find(';'); - if (keywordSem != std::string::npos) - { - std::string tmppre = - keyword.substr(0,keywordSem); - trim(tmppre); - std::string tmppos = - keyword.substr(1+keywordSem); - trim(tmppos); - keyword = tmppre + ";" + tmppos; - } - ll.push_back(keyword); - } - if (!ll.empty()) - (*keywords)[anchor] = ll; - } - else if (branch.compare("contents") == 0) - { - // currently not used - } - } - else if (!strcmp((const char*)test->name, "ahelp")) - { - std::string text = dump(test); - trim(text); - std::string name; - - HashSet::const_iterator aEnd = extendedHelpText.end(); - for (HashSet::const_iterator iter = extendedHelpText.begin(); iter != aEnd; - ++iter) - { - name = *iter; - (*helptexts)[name] = text; - } - extendedHelpText.clear(); - } - - // traverse children - traverse(test); - } -} - -bool HelpCompiler::compile( void ) throw( HelpProcessingException ) -{ - // we now have the jaroutputstream, which will contain the document. - // now determine the document as a dom tree in variable docResolved - - xmlDocPtr docResolvedOrg = getSourceDocument(inputFile); - - // now add path to the document - // resolve the dom - if (!docResolvedOrg) - { - impl_sleep( 3 ); - docResolvedOrg = getSourceDocument(inputFile); - if( !docResolvedOrg ) - { - std::stringstream aStrStream; - aStrStream << "ERROR: file not existing: " << inputFile.native_file_string().c_str() << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - } - - // now find all applications for which one has to compile - std::string documentId; - std::string fileName; - std::string title; - // returns all applications for which one has to compile - HashSet applications = switchFind(docResolvedOrg); - - HashSet::const_iterator aEnd = applications.end(); - for (HashSet::const_iterator aI = applications.begin(); aI != aEnd; ++aI) - { - std::string appl = *aI; - std::string modulename = appl; - if (modulename[0] == 'S') - { - modulename = modulename.substr(1); - std::transform(modulename.begin(), modulename.end(), modulename.begin(), tolower); - } - if (modulename != "DEFAULT" && modulename != module) - continue; - - // returns a clone of the document with swich-cases resolved - xmlNodePtr docResolved = clone(xmlDocGetRootElement(docResolvedOrg), appl); - myparser aparser(documentId, fileName, title); - aparser.traverse(docResolved); - - documentId = aparser.documentId; - fileName = aparser.fileName; - title = aparser.title; - - HCDBG(std::cerr << documentId << " : " << fileName << " : " << title << std::endl); - - xmlDocPtr docResolvedDoc = xmlCopyDoc(docResolvedOrg, false); - xmlDocSetRootElement(docResolvedDoc, docResolved); - - if (modulename == "DEFAULT") - { - streamTable.dropdefault(); - streamTable.default_doc = docResolvedDoc; - streamTable.default_hidlist = aparser.hidlist; - streamTable.default_helptexts = aparser.helptexts; - streamTable.default_keywords = aparser.keywords; - } - else if (modulename == module) - { - streamTable.dropappl(); - streamTable.appl_doc = docResolvedDoc; - streamTable.appl_hidlist = aparser.hidlist; - streamTable.appl_helptexts = aparser.helptexts; - streamTable.appl_keywords = aparser.keywords; - } - else - { - std::stringstream aStrStream; - aStrStream << "ERROR: Found unexpected module name \"" << modulename - << "\" in file" << src.native_file_string().c_str() << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - - } // end iteration over all applications - - streamTable.document_id = documentId; - streamTable.document_path = fileName; - streamTable.document_title = title; - std::string actMod = module; - if ( !bExtensionMode && !fileName.empty()) - { - if (fileName.find("/text/") == 0) - { - int len = strlen("/text/"); - actMod = fileName.substr(len); - actMod = actMod.substr(0, actMod.find('/')); - } - } - streamTable.document_module = actMod; - - xmlFreeDoc(docResolvedOrg); - return true; -} - -namespace fs -{ - rtl_TextEncoding getThreadTextEncoding( void ) - { - static bool bNeedsInit = true; - static rtl_TextEncoding nThreadTextEncoding; - if( bNeedsInit ) - { - bNeedsInit = false; - nThreadTextEncoding = osl_getThreadTextEncoding(); - } - return nThreadTextEncoding; - } - - void create_directory(const fs::path indexDirName) - { - HCDBG( - std::cerr << "creating " << - rtl::OUStringToOString(indexDirName.data, RTL_TEXTENCODING_UTF8).getStr() - << std::endl - ); - osl::Directory::createPath(indexDirName.data); - } - - void rename(const fs::path &src, const fs::path &dest) - { - osl::File::move(src.data, dest.data); - } - - void copy(const fs::path &src, const fs::path &dest) - { - osl::File::copy(src.data, dest.data); - } - - bool exists(const fs::path &in) - { - osl::File tmp(in.data); - return (tmp.open(osl_File_OpenFlag_Read) == osl::FileBase::E_None); - } - - void remove(const fs::path &in) - { - osl::File::remove(in.data); - } - - void removeRecursive(rtl::OUString const& _suDirURL) - { - { - osl::Directory aDir(_suDirURL); - aDir.open(); - if (aDir.isOpen()) - { - osl::DirectoryItem aItem; - osl::FileStatus aStatus(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_Attributes); - while (aDir.getNextItem(aItem) == ::osl::FileBase::E_None) - { - if (osl::FileBase::E_None == aItem.getFileStatus(aStatus) && - aStatus.isValid(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_Attributes)) - { - rtl::OUString suFilename = aStatus.getFileName(); - rtl::OUString suFullFileURL; - suFullFileURL += _suDirURL; - suFullFileURL += rtl::OUString::createFromAscii("/"); - suFullFileURL += suFilename; - - if (aStatus.getFileType() == osl::FileStatus::Directory) - removeRecursive(suFullFileURL); - else - osl::File::remove(suFullFileURL); - } - } - aDir.close(); - } - } - osl::Directory::remove(_suDirURL); - } - - void remove_all(const fs::path &in) - { - removeRecursive(in.data); - } -} - -/* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/xmlhelp/source/com/sun/star/help/HelpCompiler.hxx b/xmlhelp/source/com/sun/star/help/HelpCompiler.hxx deleted file mode 100644 index 768aafd0e120..000000000000 --- a/xmlhelp/source/com/sun/star/help/HelpCompiler.hxx +++ /dev/null @@ -1,320 +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: HelpCompiler.hxx,v $ - * $Revision: 1.8 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef HELPCOMPILER_HXX -#define HELPCOMPILER_HXX - -#include <string> -#include <hash_map> -#include <vector> -#include <list> -#include <fstream> -#include <iostream> -#include <sstream> -#include <algorithm> -#include <ctype.h> -#ifdef SYSTEM_DB -#include <db.h> -#else -#include <berkeleydb/db.h> -#endif - -#include <boost/shared_ptr.hpp> - -#include <libxml/xmlmemory.h> -#include <libxml/debugXML.h> -#include <libxml/HTMLtree.h> -#include <libxml/xmlIO.h> -#include <libxml/xinclude.h> -#include <libxml/catalog.h> - -#include <rtl/ustring.hxx> -#include <osl/thread.h> -#include <osl/process.h> -#include <osl/file.hxx> - -#include <xmlhelp/compilehelp.hxx> - -#define EMULATEORIGINAL 1 - -#ifdef CMCDEBUG - #define HCDBG(foo) do { if (1) foo; } while(0) -#else - #define HCDBG(foo) do { if (0) foo; } while(0) -#endif - -namespace fs -{ - rtl_TextEncoding getThreadTextEncoding( void ); - - enum convert { native }; - class path - { - public: - ::rtl::OUString data; - public: - path() {} - path(const path &rOther) : data(rOther.data) {} - path(const std::string &in, convert) - { - rtl::OUString sWorkingDir; - osl_getProcessWorkingDir(&sWorkingDir.pData); - - rtl::OString tmp(in.c_str()); - rtl::OUString ustrSystemPath(rtl::OStringToOUString(tmp, getThreadTextEncoding())); - osl::File::getFileURLFromSystemPath(ustrSystemPath, data); - osl::File::getAbsoluteFileURL(sWorkingDir, data, data); - } - path(const std::string &FileURL) - { - rtl::OString tmp(FileURL.c_str()); - data = rtl::OStringToOUString(tmp, getThreadTextEncoding()); - } - std::string native_file_string() const - { - ::rtl::OUString ustrSystemPath; - osl::File::getSystemPathFromFileURL(data, ustrSystemPath); - rtl::OString tmp(rtl::OUStringToOString(ustrSystemPath, getThreadTextEncoding())); - HCDBG(std::cerr << "native_file_string is " << tmp.getStr() << std::endl); - return std::string(tmp.getStr()); - } - std::string native_directory_string() const { return native_file_string(); } - std::string toUTF8() const - { - rtl::OString tmp(rtl::OUStringToOString(data, RTL_TEXTENCODING_UTF8)); - return std::string(tmp.getStr()); - } - bool empty() const { return data.getLength() == 0; } - path operator/(const std::string &in) const - { - path ret(*this); - HCDBG(std::cerr << "orig was " << - rtl::OUStringToOString(ret.data, RTL_TEXTENCODING_UTF8).getStr() << std::endl); - rtl::OString tmp(in.c_str()); - rtl::OUString ustrSystemPath(rtl::OStringToOUString(tmp, getThreadTextEncoding())); - ret.data += rtl::OUString(sal_Unicode('/')); - ret.data += ustrSystemPath; - HCDBG(std::cerr << "final is " << - rtl::OUStringToOString(ret.data, RTL_TEXTENCODING_UTF8).getStr() << std::endl); - return ret; - } - void append(const char *in) - { - rtl::OString tmp(in); - rtl::OUString ustrSystemPath(rtl::OStringToOUString(tmp, getThreadTextEncoding())); - data = data + ustrSystemPath; - } - void append(const std::string &in) { append(in.c_str()); } - }; - - void create_directory(const fs::path indexDirName); - void rename(const fs::path &src, const fs::path &dest); - void copy(const fs::path &src, const fs::path &dest); - bool exists(const fs::path &in); - void remove_all(const fs::path &in); - void remove(const fs::path &in); -} - -struct joaat_hash -{ - size_t operator()(const std::string &str) const - { - size_t hash = 0; - const char *key = str.data(); - for (size_t i = 0; i < str.size(); i++) - { - hash += key[i]; - hash += (hash << 10); - hash ^= (hash >> 6); - } - hash += (hash << 3); - hash ^= (hash >> 11); - hash += (hash << 15); - return hash; - } -}; - -#define get16bits(d) ((((sal_uInt32)(((const sal_uInt8 *)(d))[1])) << 8)\ - +(sal_uInt32)(((const sal_uInt8 *)(d))[0]) ) - -struct SuperFastHash -{ - size_t operator()(const std::string &str) const - { - const char * data = str.data(); - int len = str.size(); - size_t hash = len, tmp; - if (len <= 0 || data == NULL) return 0; - - int rem = len & 3; - len >>= 2; - - /* Main loop */ - for (;len > 0; len--) - { - hash += get16bits (data); - tmp = (get16bits (data+2) << 11) ^ hash; - hash = (hash << 16) ^ tmp; - data += 2*sizeof (sal_uInt16); - hash += hash >> 11; - } - - /* Handle end cases */ - switch (rem) - { - case 3: hash += get16bits (data); - hash ^= hash << 16; - hash ^= data[sizeof (sal_uInt16)] << 18; - hash += hash >> 11; - break; - case 2: hash += get16bits (data); - hash ^= hash << 11; - hash += hash >> 17; - break; - case 1: hash += *data; - hash ^= hash << 10; - hash += hash >> 1; - } - - /* Force "avalanching" of final 127 bits */ - hash ^= hash << 3; - hash += hash >> 5; - hash ^= hash << 4; - hash += hash >> 17; - hash ^= hash << 25; - hash += hash >> 6; - - return hash; - } -}; - -#define pref_hash joaat_hash - -typedef std::hash_map<std::string, std::string, pref_hash> Stringtable; -typedef std::list<std::string> LinkedList; -typedef std::vector<std::string> HashSet; - -typedef std::hash_map<std::string, LinkedList, pref_hash> Hashtable; - -class StreamTable -{ -public: - std::string document_id; - std::string document_path; - std::string document_module; - std::string document_title; - - HashSet *appl_hidlist; - Hashtable *appl_keywords; - Stringtable *appl_helptexts; - xmlDocPtr appl_doc; - - HashSet *default_hidlist; - Hashtable *default_keywords; - Stringtable *default_helptexts; - xmlDocPtr default_doc; - - StreamTable() : - appl_hidlist(NULL), appl_keywords(NULL), appl_helptexts(NULL), appl_doc(NULL), - default_hidlist(NULL), default_keywords(NULL), default_helptexts(NULL), default_doc(NULL) - {} - void dropdefault() - { - delete default_hidlist; - delete default_keywords; - delete default_helptexts; - if (default_doc) xmlFreeDoc(default_doc); - } - void dropappl() - { - delete appl_hidlist; - delete appl_keywords; - delete appl_helptexts; - if (appl_doc) xmlFreeDoc(appl_doc); - } - ~StreamTable() - { - dropappl(); - dropdefault(); - } -}; - -struct HelpProcessingException -{ - HelpProcessingErrorClass m_eErrorClass; - std::string m_aErrorMsg; - std::string m_aXMLParsingFile; - int m_nXMLParsingLine; - - HelpProcessingException( HelpProcessingErrorClass eErrorClass, const std::string& aErrorMsg ) - : m_eErrorClass( eErrorClass ) - , m_aErrorMsg( aErrorMsg ) - {} - HelpProcessingException( const std::string& aErrorMsg, const std::string& aXMLParsingFile, int nXMLParsingLine ) - : m_eErrorClass( HELPPROCESSING_XMLPARSING_ERROR ) - , m_aErrorMsg( aErrorMsg ) - , m_aXMLParsingFile( aXMLParsingFile ) - , m_nXMLParsingLine( nXMLParsingLine ) - {} -}; - -class HelpCompiler -{ -public: - HelpCompiler(StreamTable &streamTable, - const fs::path &in_inputFile, - const fs::path &in_src, - const fs::path &in_resEmbStylesheet, - const std::string &in_module, - const std::string &in_lang, - bool in_bExtensionMode); - bool compile( void ) throw (HelpProcessingException); - void addEntryToJarFile(const std::string &prefix, - const std::string &entryName, const std::string &bytesToAdd); - void addEntryToJarFile(const std::string &prefix, - const std::string &entryName, const HashSet &bytesToAdd); - void addEntryToJarFile(const std::string &prefix, - const std::string &entryName, const Stringtable &bytesToAdd); - void addEntryToJarFile(const std::string &prefix, - const std::string &entryName, const Hashtable &bytesToAdd); -private: - xmlDocPtr getSourceDocument(const fs::path &filePath); - HashSet switchFind(xmlDocPtr doc); - xmlNodePtr clone(xmlNodePtr node, const std::string& appl); - StreamTable &streamTable; - const fs::path inputFile, src; - const std::string module, lang; - const fs::path resEmbStylesheet; - bool bExtensionMode; -}; - -#endif - -/* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/xmlhelp/source/com/sun/star/help/HelpFileDocument.java b/xmlhelp/source/com/sun/star/help/HelpFileDocument.java deleted file mode 100644 index 2212db27f251..000000000000 --- a/xmlhelp/source/com/sun/star/help/HelpFileDocument.java +++ /dev/null @@ -1,89 +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: HelpFileDocument.java,v $ - * $Revision: 1.2 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.help; - -import java.io.File; -import java.io.Reader; -import java.io.FileInputStream; -import java.io.InputStreamReader; -//import java.io.FileReader; -import java.io.StringReader; - -import org.apache.lucene.document.Document; -import org.apache.lucene.document.Field; - -/** Lucene Document for help files */ -public class HelpFileDocument -{ - /** Creates reader for UTF-8 files - */ - private static Reader getReaderForFile( File aFile ) - throws java.io.FileNotFoundException, java.io.UnsupportedEncodingException { - Reader aReader; - if( aFile != null ) { - FileInputStream fis = new FileInputStream( aFile ); - aReader = new InputStreamReader( fis, "UTF-8" ); - } - else { - aReader = new StringReader( "" ); - } - return aReader; - } - - /** Makes a document for a File. - */ - public static Document Document( String aModule, File aCaptionFile, File aContentFile ) - throws java.io.FileNotFoundException, java.io.UnsupportedEncodingException { - Document doc = new Document(); - - // Add the path of the file as a field named "path". Use a field that is - // indexed (i.e. searchable), but don't tokenize the field into words. - File aFile = aCaptionFile != null ? aCaptionFile : aContentFile; - if( aFile != null ) - { - String aPath = "#HLP#" + aModule + "/" + aFile.getName(); - doc.add(new Field("path", aPath, Field.Store.YES, Field.Index.UN_TOKENIZED)); - } - - // Add the caption of the file to a field named "caption". Specify a Reader, - // so that the text of the file is tokenized and indexed, but not stored. - doc.add( new Field( "caption", getReaderForFile( aCaptionFile ) ) ); - - // Add the contents of the file to a field named "content". Specify a Reader, - // so that the text of the file is tokenized and indexed, but not stored. - doc.add( new Field( "content", getReaderForFile( aContentFile ) ) ); - - // return the document - return doc; - } - - private HelpFileDocument() {} -} diff --git a/xmlhelp/source/com/sun/star/help/HelpIndexer.java b/xmlhelp/source/com/sun/star/help/HelpIndexer.java index eabf1fdd6e88..abb803289e7e 100644 --- a/xmlhelp/source/com/sun/star/help/HelpIndexer.java +++ b/xmlhelp/source/com/sun/star/help/HelpIndexer.java @@ -37,23 +37,11 @@ import com.sun.star.beans.XIntrospectionAccess; import com.sun.star.uno.AnyConverter; import com.sun.star.uno.XComponentContext; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; -import java.util.zip.CRC32; -import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.apache.lucene.analysis.cjk.CJKAnalyzer; -import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.index.IndexWriter; - import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Date; +import java.util.zip.ZipOutputStream; public class HelpIndexer extends WeakBase implements XServiceInfo, XInvocation @@ -62,6 +50,8 @@ public class HelpIndexer extends WeakBase "com.sun.star.help.HelpIndexer"; static private final String aCreateIndexMethodName = "createIndex"; + static private com.sun.star.help.HelpIndexerTool helpindexer = new com.sun.star.help.HelpIndexerTool(); + public HelpIndexer() { } @@ -70,292 +60,26 @@ public class HelpIndexer extends WeakBase { } - /** - * @param args the command line arguments - */ - public static void main( String[] args ) + public static void mainImpl( String[] args, boolean bExtensionMode ) { - boolean bExtensionMode = false; - mainImpl( args, bExtensionMode ); - } - - private static void mainImpl( String[] args, boolean bExtensionMode ) - { - String aDirToZipStr = ""; - String aSrcDirStr = ""; - String aLanguageStr = ""; - String aModule = ""; - String aTargetZipFileStr = ""; - - // Scan arguments - boolean bLang = false; - boolean bMod = false; - boolean bZipDir = false; - boolean bSrcDir = false; - boolean bOutput = false; - - int nArgCount = args.length; - for( int i = 0 ; i < nArgCount ; i++ ) - { - if( "-lang".equals(args[i]) ) - { - if( i + 1 < nArgCount ) - { - aLanguageStr = args[i + 1]; - bLang = true; - } - i++; - } - else if( "-mod".equals(args[i]) ) - { - if( i + 1 < nArgCount ) - { - aModule = args[i + 1]; - bMod = true; - } - i++; - } - else if( "-zipdir".equals(args[i]) ) - { - if( i + 1 < nArgCount ) - { - aDirToZipStr = args[i + 1]; - bZipDir = true; - } - i++; - } - else if( "-srcdir".equals(args[i]) ) - { - if( i + 1 < nArgCount ) - { - aSrcDirStr = args[i + 1]; - bSrcDir = true; - } - i++; - } - else if( "-o".equals(args[i]) ) - { - if( i + 1 < nArgCount ) - { - aTargetZipFileStr = args[i + 1]; - bOutput = true; - } - i++; - } - } - - if( !bLang || !bMod || !bZipDir || (!bOutput && !bExtensionMode) ) - { - if( bExtensionMode ) - return; - - System.out.println("Usage: HelpIndexer -lang ISOLangCode -mod HelpModule -zipdir TempZipDir -o OutputZipFile"); - System.exit( -1 ); - } - - String aIndexDirName = aModule + ".idxl"; - File aIndexDir = new File( aDirToZipStr + File.separator + aIndexDirName ); - if( !bSrcDir ) - aSrcDirStr = aDirToZipStr; - File aCaptionFilesDir = new File( aSrcDirStr + File.separator + "caption" ); - File aContentFilesDir = new File( aSrcDirStr + File.separator + "content" ); - - try - { - Date start = new Date(); - Analyzer analyzer = aLanguageStr.equals("ja") ? (Analyzer)new CJKAnalyzer() : (Analyzer)new StandardAnalyzer(); - IndexWriter writer = new IndexWriter( aIndexDir, analyzer, true ); - if( !bExtensionMode ) - System.out.println( "Lucene: Indexing to directory '" + aIndexDir + "'..." ); - int nRet = indexDocs( writer, aModule, bExtensionMode, aCaptionFilesDir, aContentFilesDir ); - if( nRet != -1 ) - { - if( !bExtensionMode ) - { - System.out.println(); - System.out.println( "Optimizing ..." ); - } - writer.optimize(); - } - writer.close(); - - if( bExtensionMode ) - { - if( !bSrcDir ) - { - deleteRecursively( aCaptionFilesDir ); - deleteRecursively( aContentFilesDir ); - } - } - else - { - if( nRet == -1 ) - deleteRecursively( aIndexDir ); - - if( !bExtensionMode ) - System.out.println( "Zipping ..." ); - File aDirToZipFile = new File( aDirToZipStr ); - createZipFile( aDirToZipFile, aTargetZipFileStr ); - deleteRecursively( aDirToZipFile ); - } - - Date end = new Date(); - if( !bExtensionMode ) - System.out.println(end.getTime() - start.getTime() + " total milliseconds"); - } - catch (IOException e) - { - if( bExtensionMode ) - return; - - System.out.println(" caught a " + e.getClass() + - "\n with message: " + e.getMessage()); - System.exit( -1 ); - } - } - - private static int indexDocs(IndexWriter writer, String aModule, boolean bExtensionMode, - File aCaptionFilesDir, File aContentFilesDir) throws IOException - { - if( !aCaptionFilesDir.canRead() || !aCaptionFilesDir.isDirectory() ) - { - if( !bExtensionMode ) - System.out.println( "Not found: " + aCaptionFilesDir ); - return -1; - } - if( !aContentFilesDir.canRead() || !aContentFilesDir.isDirectory() ) - { - if( !bExtensionMode ) - System.out.println( "Not found: " + aContentFilesDir ); - return -1; - } - - String[] aCaptionFiles = aCaptionFilesDir.list(); - List aCaptionFilesList = Arrays.asList( aCaptionFiles ); - HashSet aCaptionFilesHashSet = new HashSet( aCaptionFilesList ); - - String[] aContentFiles = aContentFilesDir.list(); - List aContentFilesList = Arrays.asList( aContentFiles ); - HashSet aContentFilesHashSet = new HashSet( aContentFilesList ); - - // Loop over caption files and find corresponding content file - if( !bExtensionMode ) - System.out.println( "Indexing, adding files" ); - int nCaptionFilesLen = aCaptionFiles.length; - for( int i = 0 ; i < nCaptionFilesLen ; i++ ) - { - String aCaptionFileStr = aCaptionFiles[i]; - File aCaptionFile = new File( aCaptionFilesDir, aCaptionFileStr ); - File aContentFile = null; - if( aContentFilesHashSet.contains( aCaptionFileStr ) ) - aContentFile = new File( aContentFilesDir, aCaptionFileStr ); - - if( !bExtensionMode ) - System.out.print( "." ); - writer.addDocument( HelpFileDocument.Document( aModule, aCaptionFile, aContentFile ) ); - } - - // Loop over content files to find remaining files not mapped to caption files - int nContentFilesLen = aContentFiles.length; - for( int i = 0 ; i < nContentFilesLen ; i++ ) - { - String aContentFileStr = aContentFiles[i]; - if( !aCaptionFilesHashSet.contains( aContentFileStr ) ) - { - // Not already handled in caption files loop - File aCaptionFile = null; - File aContentFile = new File( aContentFilesDir, aContentFileStr ); - if( !bExtensionMode ) - System.out.print( "." ); - writer.addDocument( HelpFileDocument.Document( aModule, aCaptionFile, aContentFile ) ); - } - } - return 0; + helpindexer.mainImpl( args , bExtensionMode ); } public static void createZipFile( File aDirToZip, String aTargetZipFileStr ) throws FileNotFoundException, IOException { - FileOutputStream fos = new FileOutputStream( aTargetZipFileStr ); - ZipOutputStream zos = new ZipOutputStream( fos ); - - File[] aChildrenFiles = aDirToZip.listFiles(); - int nFileCount = aChildrenFiles.length; - for( int i = 0 ; i < nFileCount ; i++ ) - addToZipRecursively( zos, aChildrenFiles[i], null ); - - zos.close(); + helpindexer.createZipFile( aDirToZip , aTargetZipFileStr ); } public static void addToZipRecursively( ZipOutputStream zos, File aFile, String aBasePath ) throws FileNotFoundException, IOException { - if( aFile.isDirectory() ) - { - String aDirName = aFile.getName(); - if( aDirName.equalsIgnoreCase( "caption" ) || aDirName.equalsIgnoreCase( "content" ) ) - return; - - File[] aChildrenFiles = aFile.listFiles(); - String aNewBasePath = ""; - if( aBasePath != null ) - aNewBasePath += aBasePath + File.separator; - aNewBasePath += aDirName; - - int nFileCount = aChildrenFiles.length; - for( int i = 0 ; i < nFileCount ; i++ ) - addToZipRecursively( zos, aChildrenFiles[i], aNewBasePath ); - - return; - } - - // No directory - // read contents of file we are going to put in the zip - int fileLength = (int) aFile.length(); - FileInputStream fis = new FileInputStream( aFile ); - byte[] wholeFile = new byte[fileLength]; - int bytesRead = fis.read( wholeFile, 0, fileLength ); - fis.close(); - - String aFileName = aFile.getName(); - String aEntryName = ""; - if( aBasePath != null ) - aEntryName += aBasePath + "/"; - aEntryName += aFileName; - ZipEntry aZipEntry = new ZipEntry( aEntryName ); - aZipEntry.setTime( aFile.lastModified() ); - aZipEntry.setSize( fileLength ); - - int nMethod = ( aFileName.toLowerCase().endsWith( ".jar" ) ) - ? ZipEntry.STORED : ZipEntry.DEFLATED; - aZipEntry.setMethod( nMethod ); - - CRC32 tempCRC = new CRC32(); - tempCRC.update( wholeFile, 0, wholeFile.length ); - aZipEntry.setCrc( tempCRC.getValue() ); - - // write the contents into the zip element - zos.putNextEntry( aZipEntry ); - zos.write( wholeFile, 0, fileLength ); - zos.closeEntry(); + helpindexer.addToZipRecursively( zos , aFile , aBasePath ); } static public boolean deleteRecursively( File aFile ) { - if( aFile.isDirectory() ) - { - File[] aChildrenFiles = aFile.listFiles(); - int nFileCount = aChildrenFiles.length; - for( int i = 0 ; i < nFileCount ; i++ ) - { - File aChildrenFile = aChildrenFiles[i]; - boolean bSuccess = deleteRecursively( aChildrenFile ); - if( !bSuccess ) - return false; - } - } - - return aFile.delete(); + return helpindexer.deleteRecursively( aFile ); } //=================================================== @@ -371,7 +95,8 @@ public class HelpIndexer extends WeakBase com.sun.star.script.CannotConvertException, com.sun.star.reflection.InvocationTargetException { - if( !aFunctionName.equals( aCreateIndexMethodName ) ) + if( + !aFunctionName.equals( aCreateIndexMethodName ) ) throw new com.sun.star.lang.IllegalArgumentException(); aOutParamIndex[0] = new short[0]; @@ -421,6 +146,7 @@ public class HelpIndexer extends WeakBase } + /** This method returns an array of all supported service names. * @return Array of supported service names. */ @@ -439,6 +165,7 @@ public class HelpIndexer extends WeakBase return sSupportedServiceNames; } + /** This method returns true, if the given service will be * supported by the component. * @param sServiceName Service name. @@ -449,6 +176,7 @@ public class HelpIndexer extends WeakBase return sServiceName.equals( __serviceName ); } + /** Return the class name of the component. * @return Class name of the component. */ @@ -456,5 +184,6 @@ public class HelpIndexer extends WeakBase { return HelpIndexer.class.getName(); } + } diff --git a/xmlhelp/source/com/sun/star/help/HelpLinker.cxx b/xmlhelp/source/com/sun/star/help/HelpLinker.cxx deleted file mode 100644 index 8acb129b21fb..000000000000 --- a/xmlhelp/source/com/sun/star/help/HelpLinker.cxx +++ /dev/null @@ -1,1161 +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: HelpLinker.cxx,v $ - * $Revision: 1.16 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "HelpCompiler.hxx" - -#include <map> - -#include <string.h> -#include <limits.h> - -#include <libxslt/xslt.h> -#include <libxslt/transform.h> -#include <libxslt/xsltutils.h> -#include <libxslt/functions.h> -#include <libxslt/extensions.h> - -#include <sal/types.h> -#include <osl/time.h> -#include <rtl/bootstrap.hxx> - -#ifdef SYSTEM_EXPAT -#include <expat.h> -#else -#include <expat/xmlparse.h> -#endif - -#define DBHELP_ONLY - - -class IndexerPreProcessor -{ -private: - std::string m_aModuleName; - fs::path m_fsIndexBaseDir; - fs::path m_fsCaptionFilesDirName; - fs::path m_fsContentFilesDirName; - - xsltStylesheetPtr m_xsltStylesheetPtrCaption; - xsltStylesheetPtr m_xsltStylesheetPtrContent; - -public: - IndexerPreProcessor( const std::string& aModuleName, const fs::path& fsIndexBaseDir, - const fs::path& idxCaptionStylesheet, const fs::path& idxContentStylesheet ); - ~IndexerPreProcessor(); - - void processDocument( xmlDocPtr doc, const std::string& EncodedDocPath ); -}; - -IndexerPreProcessor::IndexerPreProcessor - ( const std::string& aModuleName, const fs::path& fsIndexBaseDir, - const fs::path& idxCaptionStylesheet, const fs::path& idxContentStylesheet ) - : m_aModuleName( aModuleName ) - , m_fsIndexBaseDir( fsIndexBaseDir ) -{ - m_fsCaptionFilesDirName = fsIndexBaseDir / "caption"; - fs::create_directory( m_fsCaptionFilesDirName ); - - m_fsContentFilesDirName = fsIndexBaseDir / "content"; - fs::create_directory( m_fsContentFilesDirName ); - - m_xsltStylesheetPtrCaption = xsltParseStylesheetFile - ((const xmlChar *)idxCaptionStylesheet.native_file_string().c_str()); - m_xsltStylesheetPtrContent = xsltParseStylesheetFile - ((const xmlChar *)idxContentStylesheet.native_file_string().c_str()); -} - -IndexerPreProcessor::~IndexerPreProcessor() -{ - if( m_xsltStylesheetPtrCaption ) - xsltFreeStylesheet( m_xsltStylesheetPtrCaption ); - if( m_xsltStylesheetPtrContent ) - xsltFreeStylesheet( m_xsltStylesheetPtrContent ); -} - - -std::string getEncodedPath( const std::string& Path ) -{ - rtl::OString aOStr_Path( Path.c_str() ); - rtl::OUString aOUStr_Path( rtl::OStringToOUString - ( aOStr_Path, fs::getThreadTextEncoding() ) ); - rtl::OUString aPathURL; - osl::File::getFileURLFromSystemPath( aOUStr_Path, aPathURL ); - rtl::OString aOStr_PathURL( rtl::OUStringToOString - ( aPathURL, fs::getThreadTextEncoding() ) ); - std::string aStdStr_PathURL( aOStr_PathURL.getStr() ); - return aStdStr_PathURL; -} - -void IndexerPreProcessor::processDocument - ( xmlDocPtr doc, const std::string &EncodedDocPath ) -{ - std::string aStdStr_EncodedDocPathURL = getEncodedPath( EncodedDocPath ); - - xmlDocPtr resCaption = xsltApplyStylesheet( m_xsltStylesheetPtrCaption, doc, NULL ); - xmlNodePtr pResNodeCaption = resCaption->xmlChildrenNode; - if( pResNodeCaption ) - { - fs::path fsCaptionPureTextFile_docURL = m_fsCaptionFilesDirName / aStdStr_EncodedDocPathURL; - std::string aCaptionPureTextFileStr_docURL = fsCaptionPureTextFile_docURL.native_file_string(); - FILE* pFile_docURL = fopen( aCaptionPureTextFileStr_docURL.c_str(), "w" ); - if( pFile_docURL ) - { - fprintf( pFile_docURL, "%s\n", pResNodeCaption->content ); - fclose( pFile_docURL ); - } - } - xmlFreeDoc(resCaption); - - xmlDocPtr resContent = xsltApplyStylesheet( m_xsltStylesheetPtrContent, doc, NULL ); - xmlNodePtr pResNodeContent = resContent->xmlChildrenNode; - if( pResNodeContent ) - { - fs::path fsContentPureTextFile_docURL = m_fsContentFilesDirName / aStdStr_EncodedDocPathURL; - std::string aContentPureTextFileStr_docURL = fsContentPureTextFile_docURL.native_file_string(); - FILE* pFile_docURL = fopen( aContentPureTextFileStr_docURL.c_str(), "w" ); - if( pFile_docURL ) - { - fprintf( pFile_docURL, "%s\n", pResNodeContent->content ); - fclose( pFile_docURL ); - } - } - xmlFreeDoc(resContent); -} - -struct Data -{ - std::vector<std::string> _idList; - typedef std::vector<std::string>::const_iterator cIter; - - void append(const std::string &id) - { - _idList.push_back(id); - } - - std::string getString() const - { - std::string ret; - cIter aEnd = _idList.end(); - for (cIter aIter = _idList.begin(); aIter != aEnd; ++aIter) - ret += *aIter + ";"; - return ret; - } -}; - -void writeKeyValue_DBHelp( FILE* pFile, const std::string& aKeyStr, const std::string& aValueStr ) -{ - if( pFile == NULL ) - return; - char cLF = 10; - int nKeyLen = aKeyStr.length(); - int nValueLen = aValueStr.length(); - fprintf( pFile, "%x ", nKeyLen ); - if( nKeyLen > 0 ) - fwrite( aKeyStr.c_str(), 1, nKeyLen, pFile );
- fprintf( pFile, " %x ", nValueLen ); - if( nValueLen > 0 ) - fwrite( aValueStr.c_str(), 1, nValueLen, pFile );
- fprintf( pFile, "%c", cLF ); -} - -class HelpKeyword -{ -private: - typedef std::hash_map<std::string, Data, pref_hash> DataHashtable; - DataHashtable _hash; - -public: - void insert(const std::string &key, const std::string &id) - { - Data &data = _hash[key]; - data.append(id); - } - - void dump(DB* table) - { - DataHashtable::const_iterator aEnd = _hash.end(); - for (DataHashtable::const_iterator aIter = _hash.begin(); aIter != aEnd; ++aIter) - { - const std::string &keystr = aIter->first; - DBT key; - memset(&key, 0, sizeof(key)); - key.data = const_cast<char*>(keystr.c_str()); - key.size = keystr.length(); - - const Data &data = aIter->second; - std::string str = data.getString(); - DBT value; - memset(&value, 0, sizeof(value)); - value.data = const_cast<char*>(str.c_str()); - value.size = str.length(); - - table->put(table, NULL, &key, &value, 0); - } - } - - void dump_DBHelp( const std::string& rFileName ) - { - FILE* pFile = fopen( rFileName.c_str(), "wb" ); - if( pFile == NULL ) - return; - - DataHashtable::const_iterator aEnd = _hash.end(); - for (DataHashtable::const_iterator aIter = _hash.begin(); aIter != aEnd; ++aIter) - writeKeyValue_DBHelp( pFile, aIter->first, aIter->second.getString() ); - - fclose( pFile ); - } -}; - -class HelpLinker -{ -public: - void main(std::vector<std::string> &args, std::string* pExtensionPath = NULL ) - throw( HelpProcessingException ); - - HelpLinker() - : init(true) - , m_pIndexerPreProcessor(NULL) - {} - ~HelpLinker() - { delete m_pIndexerPreProcessor; } - -private: - int locCount, totCount; - Stringtable additionalFiles; - HashSet helpFiles; - fs::path sourceRoot; - fs::path embeddStylesheet; - fs::path idxCaptionStylesheet; - fs::path idxContentStylesheet; - fs::path zipdir; - fs::path outputFile; - std::string module; - std::string lang; - std::string hid; - std::string extensionPath; - bool bExtensionMode; - fs::path indexDirName; - Stringtable hidlistTranslation; - fs::path indexDirParentName; - bool init; - IndexerPreProcessor* m_pIndexerPreProcessor; - void initIndexerPreProcessor(); - void link() throw( HelpProcessingException ); - void addBookmark( DB* dbBase, FILE* pFile_DBHelp, std::string thishid, - const std::string& fileB, const std::string& anchorB, - const std::string& jarfileB, const std::string& titleB ); -#if 0 - /** - * @param outputFile - * @param module - * @param lang - * @param hid - * @param helpFiles - * @param additionalFiles - */ - - private HelpURLStreamHandlerFactory urlHandler = null; -#endif -}; - -namespace URLEncoder -{ - static std::string encode(const std::string &rIn) - { - const char *good = "!$&'()*+,-.=@_"; - static const char hex[17] = "0123456789ABCDEF"; - - std::string result; - for (size_t i=0; i < rIn.length(); ++i) - { - unsigned char c = rIn[i]; - if (isalnum (c) || strchr (good, c)) - result += c; - else { - result += '%'; - result += hex[c >> 4]; - result += hex[c & 0xf]; - } - } - return result; - } -} - -void HelpLinker::addBookmark( DB* dbBase, FILE* pFile_DBHelp, std::string thishid, - const std::string& fileB, const std::string& anchorB, - const std::string& jarfileB, const std::string& titleB) -{ - HCDBG(std::cerr << "HelpLinker::addBookmark " << thishid << " " << - fileB << " " << anchorB << " " << jarfileB << " " << titleB << std::endl); - - std::string temp = thishid; - std::transform (temp.begin(), temp.end(), temp.begin(), toupper); - std::replace(temp.begin(), temp.end(), ':', '_'); - const std::string& translatedHid = hidlistTranslation[temp]; - if (!translatedHid.empty()) - thishid = translatedHid; - - thishid = URLEncoder::encode(thishid); - - DBT key; - memset(&key, 0, sizeof(key)); - key.data = const_cast<char*>(thishid.c_str()); - key.size = thishid.length(); - - int fileLen = fileB.length(); - if (!anchorB.empty()) - fileLen += (1 + anchorB.length()); - int dataLen = 1 + fileLen + 1 + jarfileB.length() + 1 + titleB.length(); - - std::vector<unsigned char> dataB(dataLen); - size_t i = 0; - dataB[i++] = static_cast<unsigned char>(fileLen); - for (size_t j = 0; j < fileB.length(); ++j) - dataB[i++] = fileB[j]; - if (!anchorB.empty()) - { - dataB[i++] = '#'; - for (size_t j = 0; j < anchorB.length(); ++j) - dataB[i++] = anchorB[j]; - } - dataB[i++] = static_cast<unsigned char>(jarfileB.length()); - for (size_t j = 0; j < jarfileB.length(); ++j) - dataB[i++] = jarfileB[j]; - - dataB[i++] = static_cast<unsigned char>(titleB.length()); - for (size_t j = 0; j < titleB.length(); ++j) - dataB[i++] = titleB[j]; - - DBT data; - memset(&data, 0, sizeof(data)); - data.data = &dataB[0]; - data.size = dataB.size(); - - if( dbBase != NULL ) - dbBase->put(dbBase, NULL, &key, &data, 0); - - if( pFile_DBHelp != NULL ) - { - std::string aValueStr( dataB.begin(), dataB.end() ); - writeKeyValue_DBHelp( pFile_DBHelp, thishid, aValueStr ); - } -} - -void HelpLinker::initIndexerPreProcessor() -{ - if( m_pIndexerPreProcessor ) - delete m_pIndexerPreProcessor; - std::string mod = module; - std::transform (mod.begin(), mod.end(), mod.begin(), tolower); - m_pIndexerPreProcessor = new IndexerPreProcessor( mod, indexDirParentName, - idxCaptionStylesheet, idxContentStylesheet ); -} - -/** -* -*/ -void HelpLinker::link() throw( HelpProcessingException ) -{ - bool bIndexForExtension = true;
-
- if( bExtensionMode ) - { - indexDirParentName = sourceRoot; - } - else - { - indexDirParentName = zipdir; - fs::create_directory(indexDirParentName); - } - -#ifdef CMC_DEBUG - std::cerr << "will not delete tmpdir of " << indexDirParentName.native_file_string().c_str() << std::endl; -#endif - - std::string mod = module; - std::transform (mod.begin(), mod.end(), mod.begin(), tolower); - - // do the work here - // continue with introduction of the overall process thing into the - // here all hzip files will be worked on - std::string appl = mod; - if (appl[0] == 's') - appl = appl.substr(1); - - bool bUse_ = true; -#ifdef DBHELP_ONLY - if( !bExtensionMode ) - bUse_ = false; -#endif - - DB* helpText(0); -#ifndef DBHELP_ONLY - fs::path helpTextFileName(indexDirParentName / (mod + ".ht")); - db_create(&helpText,0,0); - helpText->open(helpText, NULL, helpTextFileName.native_file_string().c_str(), NULL, DB_BTREE, - DB_CREATE | DB_TRUNCATE, 0644); -#endif - - fs::path helpTextFileName_DBHelp(indexDirParentName / (mod + (bUse_ ? ".ht_" : ".ht"))); - FILE* pFileHelpText_DBHelp = fopen - ( helpTextFileName_DBHelp.native_file_string().c_str(), "wb" ); - - DB* dbBase(0); -#ifndef DBHELP_ONLY - fs::path dbBaseFileName(indexDirParentName / (mod + ".db")); - db_create(&dbBase,0,0); - dbBase->open(dbBase, NULL, dbBaseFileName.native_file_string().c_str(), NULL, DB_BTREE, - DB_CREATE | DB_TRUNCATE, 0644); -#endif - - fs::path dbBaseFileName_DBHelp(indexDirParentName / (mod + (bUse_ ? ".db_" : ".db"))); - FILE* pFileDbBase_DBHelp = fopen - ( dbBaseFileName_DBHelp.native_file_string().c_str(), "wb" ); - -#ifndef DBHELP_ONLY - DB* keyWord(0); - fs::path keyWordFileName(indexDirParentName / (mod + ".key")); - db_create(&keyWord,0,0); - keyWord->open(keyWord, NULL, keyWordFileName.native_file_string().c_str(), NULL, DB_BTREE, - DB_CREATE | DB_TRUNCATE, 0644); -#endif - - fs::path keyWordFileName_DBHelp(indexDirParentName / (mod + (bUse_ ? ".key_" : ".key"))); - - HelpKeyword helpKeyword; - - // catch HelpProcessingException to avoid locking data bases - try - { - - std::ifstream fileReader(hid.c_str()); - while (fileReader) - { - std::string key; - fileReader >> key; - std::transform (key.begin(), key.end(), key.begin(), toupper); - std::replace(key.begin(), key.end(), ':', '_'); - std::string data; - fileReader >> data; - if (!key.empty() && !data.empty()) - hidlistTranslation[key] = data; - } - fileReader.close(); - - // lastly, initialize the indexBuilder - if ( (!bExtensionMode || bIndexForExtension) && !helpFiles.empty()) - initIndexerPreProcessor(); - - if( !bExtensionMode ) - { -#ifndef OS2 // YD @TODO@ crashes libc runtime :-( - std::cout << "Making " << outputFile.native_file_string() << - " from " << helpFiles.size() << " input files" << std::endl; -#endif - } - - // here we start our loop over the hzip files. - HashSet::iterator end = helpFiles.end(); - for (HashSet::iterator iter = helpFiles.begin(); iter != end; ++iter) - { - if( !bExtensionMode ) - { - std::cout << "."; - std::cout.flush(); - } - - // process one file - // streamTable contains the streams in the hzip file - StreamTable streamTable; - const std::string &xhpFileName = *iter; - - if (!bExtensionMode && xhpFileName.rfind(".xhp") != xhpFileName.length()-4) - { - // only work on .xhp - files - std::cerr << - "ERROR: input list entry '" - << xhpFileName - << "' has the wrong extension (only files with extension .xhp " - << "are accepted)"; - continue; - } - - fs::path langsourceRoot(sourceRoot); - fs::path xhpFile; - - if( bExtensionMode ) - { - // langsourceRoot == sourceRoot for extensions - std::string xhpFileNameComplete( extensionPath ); - xhpFileNameComplete.append( '/' + xhpFileName ); - xhpFile = fs::path( xhpFileNameComplete ); - } - else - { - langsourceRoot.append('/' + lang + '/'); - xhpFile = fs::path(xhpFileName, fs::native); - } - - HelpCompiler hc( streamTable, xhpFile, langsourceRoot, - embeddStylesheet, module, lang, bExtensionMode ); - - HCDBG(std::cerr << "before compile of " << xhpFileName << std::endl); - bool success = hc.compile(); - HCDBG(std::cerr << "after compile of " << xhpFileName << std::endl); - - if (!success && !bExtensionMode) - { - std::stringstream aStrStream; - aStrStream << - "\nERROR: compiling help particle '" - << xhpFileName - << "' for language '" - << lang - << "' failed!"; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - - const std::string documentBaseId = streamTable.document_id; - std::string documentPath = streamTable.document_path; - if (documentPath.find("/") == 0) - documentPath = documentPath.substr(1); - - std::string documentJarfile = streamTable.document_module + ".jar"; - - std::string documentTitle = streamTable.document_title; - if (documentTitle.empty()) - documentTitle = "<notitle>"; - -#if 0 - std::cout << "for " << xhpFileName << " documentBaseId is " << documentBaseId << "\n"; - std::cout << "for " << xhpFileName << " documentPath is " << documentPath << "\n"; - std::cout << "for " << xhpFileName << " documentJarfile is " << documentJarfile << "\n"; - std::cout << "for " << xhpFileName << " documentPath is " << documentTitle << "\n"; -#endif - - const std::string& fileB = documentPath; - const std::string& jarfileB = documentJarfile; - std::string& titleB = documentTitle; - - // add once this as its own id. - addBookmark(dbBase, pFileDbBase_DBHelp, documentPath, fileB, std::string(), jarfileB, titleB); - - // first the database *.db - // ByteArrayInputStream bais = null; - // ObjectInputStream ois = null; - - const HashSet *hidlist = streamTable.appl_hidlist; - if (!hidlist) - hidlist = streamTable.default_hidlist; - if (hidlist && !hidlist->empty()) - { - // now iterate over all elements of the hidlist - HashSet::const_iterator aEnd = hidlist->end(); - for (HashSet::const_iterator hidListIter = hidlist->begin(); - hidListIter != aEnd; ++hidListIter) - { - std::string thishid = *hidListIter; - - std::string anchorB; - size_t index = thishid.rfind('#'); - if (index != std::string::npos) - { - anchorB = thishid.substr(1 + index); - thishid = thishid.substr(0, index); - } - addBookmark(dbBase, pFileDbBase_DBHelp, thishid, fileB, anchorB, jarfileB, titleB); - } - } - - // now the keywords - const Hashtable *anchorToLL = streamTable.appl_keywords; - if (!anchorToLL) - anchorToLL = streamTable.default_keywords; - if (anchorToLL && !anchorToLL->empty()) - { - std::string fakedHid = URLEncoder::encode(documentPath); - Hashtable::const_iterator aEnd = anchorToLL->end(); - for (Hashtable::const_iterator enumer = anchorToLL->begin(); - enumer != aEnd; ++enumer) - { - const std::string &anchor = enumer->first; - addBookmark(dbBase, pFileDbBase_DBHelp, documentPath, fileB, - anchor, jarfileB, titleB); - std::string totalId = fakedHid + "#" + anchor; - // std::cerr << hzipFileName << std::endl; - const LinkedList& ll = enumer->second; - LinkedList::const_iterator aOtherEnd = ll.end(); - for (LinkedList::const_iterator llIter = ll.begin(); - llIter != aOtherEnd; ++llIter) - { - helpKeyword.insert(*llIter, totalId); - } - } - - } - - // and last the helptexts - const Stringtable *helpTextHash = streamTable.appl_helptexts; - if (!helpTextHash) - helpTextHash = streamTable.default_helptexts; - if (helpTextHash && !helpTextHash->empty()) - { - Stringtable::const_iterator aEnd = helpTextHash->end(); - for (Stringtable::const_iterator helpTextIter = helpTextHash->begin(); - helpTextIter != aEnd; ++helpTextIter) - { - std::string helpTextId = helpTextIter->first; - const std::string& helpTextText = helpTextIter->second; - - std::string temp = helpTextId; - std::transform (temp.begin(), temp.end(), temp.begin(), toupper); - std::replace(temp.begin(), temp.end(), ':', '_'); - - const std::string& tHid = hidlistTranslation[temp]; - if (!tHid.empty()) - helpTextId = tHid; - helpTextId = URLEncoder::encode(helpTextId); - - DBT keyDbt; - memset(&keyDbt, 0, sizeof(keyDbt)); - keyDbt.data = const_cast<char*>(helpTextId.c_str()); - keyDbt.size = helpTextId.length(); - - DBT textDbt; - memset(&textDbt, 0, sizeof(textDbt)); - textDbt.data = const_cast<char*>(helpTextText.c_str()); - textDbt.size = helpTextText.length(); - - if( helpText != NULL ) - helpText->put(helpText, NULL, &keyDbt, &textDbt, 0); - - if( pFileHelpText_DBHelp != NULL ) - writeKeyValue_DBHelp( pFileHelpText_DBHelp, helpTextId, helpTextText ); - } - } - - //IndexerPreProcessor - if( !bExtensionMode || bIndexForExtension ) - { - // now the indexing - xmlDocPtr document = streamTable.appl_doc; - if (!document) - document = streamTable.default_doc; - if (document) - { - std::string temp = module; - std::transform (temp.begin(), temp.end(), temp.begin(), tolower); - m_pIndexerPreProcessor->processDocument(document, URLEncoder::encode(documentPath) ); - } - } - - } // while loop over hzip files ending - if( !bExtensionMode ) - std::cout << std::endl; - - } // try - catch( HelpProcessingException& ) - { - // catch HelpProcessingException to avoid locking data bases -#ifndef DBHELP_ONLY - helpText->close(helpText, 0); - dbBase->close(dbBase, 0); - keyWord->close(keyWord, 0); -#endif - if( pFileHelpText_DBHelp != NULL ) - fclose( pFileHelpText_DBHelp ); - if( pFileDbBase_DBHelp != NULL ) - fclose( pFileDbBase_DBHelp ); - throw; - } - -#ifndef DBHELP_ONLY - helpText->close(helpText, 0); - dbBase->close(dbBase, 0); - helpKeyword.dump(keyWord); - keyWord->close(keyWord, 0); -#endif - if( pFileHelpText_DBHelp != NULL ) - fclose( pFileHelpText_DBHelp ); - if( pFileDbBase_DBHelp != NULL ) - fclose( pFileDbBase_DBHelp ); - - helpKeyword.dump_DBHelp( keyWordFileName_DBHelp.native_file_string() ); - - if( !bExtensionMode ) - { - // New index - Stringtable::iterator aEnd = additionalFiles.end(); - for (Stringtable::iterator enumer = additionalFiles.begin(); enumer != aEnd; - ++enumer) - { - const std::string &additionalFileName = enumer->second; - const std::string &additionalFileKey = enumer->first; - - fs::path fsAdditionalFileName( additionalFileName, fs::native ); - std::string aNativeStr = fsAdditionalFileName.native_file_string(); - const char* pStr = aNativeStr.c_str(); - std::cerr << pStr; - - fs::path fsTargetName( indexDirParentName / additionalFileKey ); - - fs::copy( fsAdditionalFileName, fsTargetName ); - } - } - -/* - ///////////////////////////////////////////////////////////////////////// - /// remove temprary directory for index creation - ///////////////////////////////////////////////////////////////////////// -#ifndef CMC_DEBUG - if( !bExtensionMode ) - fs::remove_all( indexDirParentName ); -#endif -*/ -} - - -void HelpLinker::main(std::vector<std::string> &args, std::string* pExtensionPath) - throw( HelpProcessingException ) -{ - rtl::OUString aOfficeHelpPath; - - bExtensionMode = false; - if( pExtensionPath && pExtensionPath->length() > 0 ) - { - helpFiles.clear(); - bExtensionMode = true; - extensionPath = *pExtensionPath; - sourceRoot = fs::path(extensionPath); - - aOfficeHelpPath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("$OOO_BASE_DIR/help") ); - rtl::Bootstrap::expandMacros( aOfficeHelpPath ); - } - if (args.size() > 0 && args[0][0] == '@') - { - std::vector<std::string> stringList; - std::string strBuf; - std::ifstream fileReader(args[0].substr(1).c_str()); - - while (fileReader) - { - std::string token; - fileReader >> token; - if (!token.empty()) - stringList.push_back(token); - } - fileReader.close(); - - args = stringList; - } - - size_t i = 0; - - while (i < args.size()) - { - if (args[i].compare("-src") == 0) - { - ++i; - if (i >= args.size()) - { - std::stringstream aStrStream; - aStrStream << "sourceroot missing" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - - if( !bExtensionMode ) - sourceRoot = fs::path(args[i], fs::native); - } - else if (args[i].compare("-sty") == 0) - { - ++i; - if (i >= args.size()) - { - std::stringstream aStrStream; - aStrStream << "embeddingStylesheet missing" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - - embeddStylesheet = fs::path(args[i], fs::native); - } - else if (args[i].compare("-zipdir") == 0) - { - ++i; - if (i >= args.size()) - { - std::stringstream aStrStream; - aStrStream << "idxtemp missing" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - - zipdir = fs::path(args[i], fs::native); - } - else if (args[i].compare("-idxcaption") == 0) - { - ++i; - if (i >= args.size()) - { - std::stringstream aStrStream; - aStrStream << "idxcaption stylesheet missing" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - - idxCaptionStylesheet = fs::path(args[i], fs::native); - } - else if (args[i].compare("-idxcontent") == 0) - { - ++i; - if (i >= args.size()) - { - std::stringstream aStrStream; - aStrStream << "idxcontent stylesheet missing" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - - idxContentStylesheet = fs::path(args[i], fs::native); - } - else if (args[i].compare("-o") == 0) - { - ++i; - if (i >= args.size()) - { - std::stringstream aStrStream; - aStrStream << "outputfilename missing" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - - outputFile = fs::path(args[i], fs::native); - } - else if (args[i].compare("-mod") == 0) - { - ++i; - if (i >= args.size()) - { - std::stringstream aStrStream; - aStrStream << "module name missing" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - - module = args[i]; - } - else if (args[i].compare("-lang") == 0) - { - ++i; - if (i >= args.size()) - { - std::stringstream aStrStream; - aStrStream << "language name missing" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - - lang = args[i]; - } - else if (args[i].compare("-hid") == 0) - { - ++i; - if (i >= args.size()) - { - std::stringstream aStrStream; - aStrStream << "hid list missing" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - - hid = args[i]; - } - else if (args[i].compare("-add") == 0) - { - std::string addFile, addFileUnderPath; - ++i; - if (i >= args.size()) - { - std::stringstream aStrStream; - aStrStream << "pathname missing" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - - addFileUnderPath = args[i]; - ++i; - if (i >= args.size()) - { - std::stringstream aStrStream; - aStrStream << "pathname missing" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - addFile = args[i]; - if (!addFileUnderPath.empty() && !addFile.empty()) - additionalFiles[addFileUnderPath] = addFile; - } - else - helpFiles.push_back(args[i]); - ++i; - } - - if (!bExtensionMode && zipdir.empty()) - { - std::stringstream aStrStream; - aStrStream << "no index dir given" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - if (!bExtensionMode && idxCaptionStylesheet.empty()) - { - std::stringstream aStrStream; - aStrStream << "no index caption stylesheet given" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - else if ( bExtensionMode )
- {
- rtl::OUString aIdxCaptionPathFileURL( aOfficeHelpPath );
- aIdxCaptionPathFileURL += rtl::OUString::createFromAscii( "/idxcaption.xsl" );
-
- rtl::OString aOStr_IdxCaptionPathFileURL( rtl::OUStringToOString - ( aIdxCaptionPathFileURL, fs::getThreadTextEncoding() ) ); - std::string aStdStr_IdxCaptionPathFileURL( aOStr_IdxCaptionPathFileURL.getStr() ); -
- idxCaptionStylesheet = fs::path( aStdStr_IdxCaptionPathFileURL );
- }
- if (!bExtensionMode && idxContentStylesheet.empty()) - { - std::stringstream aStrStream; - aStrStream << "no index content stylesheet given" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - else if ( bExtensionMode )
- {
- rtl::OUString aIdxContentPathFileURL( aOfficeHelpPath );
- aIdxContentPathFileURL += rtl::OUString::createFromAscii( "/idxcontent.xsl" );
-
- rtl::OString aOStr_IdxContentPathFileURL( rtl::OUStringToOString - ( aIdxContentPathFileURL, fs::getThreadTextEncoding() ) ); - std::string aStdStr_IdxContentPathFileURL( aOStr_IdxContentPathFileURL.getStr() ); -
- idxContentStylesheet = fs::path( aStdStr_IdxContentPathFileURL );
- }
- if (!bExtensionMode && embeddStylesheet.empty()) - { - std::stringstream aStrStream; - aStrStream << "no embedding resolving file given" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - if (sourceRoot.empty()) - { - std::stringstream aStrStream; - aStrStream << "no sourceroot given" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - if (!bExtensionMode && outputFile.empty()) - { - std::stringstream aStrStream; - aStrStream << "no output file given" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - if (module.empty()) - { - std::stringstream aStrStream; - aStrStream << "module missing" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - if (!bExtensionMode && lang.empty()) - { - std::stringstream aStrStream; - aStrStream << "language missing" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - if (!bExtensionMode && hid.empty()) - { - std::stringstream aStrStream; - aStrStream << "hid list missing" << std::endl; - throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() ); - } - - link(); -} - -int main(int argc, char**argv) -{ - sal_uInt32 starttime = osl_getGlobalTimer(); - std::vector<std::string> args; - for (int i = 1; i < argc; ++i) - args.push_back(std::string(argv[i])); - try - { - HelpLinker* pHelpLinker = new HelpLinker(); - pHelpLinker->main( args ); - delete pHelpLinker; - } - catch( const HelpProcessingException& e ) - { - std::cerr << e.m_aErrorMsg; - exit(1); - } - sal_uInt32 endtime = osl_getGlobalTimer(); -#ifndef OS2 // YD @TODO@ crashes libc runtime :-( - std::cout << "time taken was " << (endtime-starttime)/1000.0 << " seconds" << std::endl; -#endif - return 0; -} - -// Variable to set an exception in "C" StructuredXMLErrorFunction -static const HelpProcessingException* GpXMLParsingException = NULL; - -extern "C" void StructuredXMLErrorFunction(void *userData, xmlErrorPtr error) -{ - (void)userData; - (void)error; - - std::string aErrorMsg = error->message; - std::string aXMLParsingFile; - if( error->file != NULL ) - aXMLParsingFile = error->file; - int nXMLParsingLine = error->line; - HelpProcessingException* pException = new HelpProcessingException( aErrorMsg, aXMLParsingFile, nXMLParsingLine ); - GpXMLParsingException = pException; - - // Reset error handler - xmlSetStructuredErrorFunc( NULL, NULL ); -} - -HelpProcessingErrorInfo& HelpProcessingErrorInfo::operator=( const struct HelpProcessingException& e ) -{ - m_eErrorClass = e.m_eErrorClass; - rtl::OString tmpErrorMsg( e.m_aErrorMsg.c_str() ); - m_aErrorMsg = rtl::OStringToOUString( tmpErrorMsg, fs::getThreadTextEncoding() ); - rtl::OString tmpXMLParsingFile( e.m_aXMLParsingFile.c_str() ); - m_aXMLParsingFile = rtl::OStringToOUString( tmpXMLParsingFile, fs::getThreadTextEncoding() ); - m_nXMLParsingLine = e.m_nXMLParsingLine; - return *this; -} - - -// Returns true in case of success, false in case of error -HELPLINKER_DLLPUBLIC bool compileExtensionHelp -( - const rtl::OUString& aExtensionName, - const rtl::OUString& aExtensionLanguageRoot, - sal_Int32 nXhpFileCount, const rtl::OUString* pXhpFiles, - HelpProcessingErrorInfo& o_rHelpProcessingErrorInfo -) -{ - bool bSuccess = true; - - sal_Int32 argc = nXhpFileCount + 3; - const char** argv = new const char*[argc]; - argv[0] = ""; - argv[1] = "-mod"; - rtl::OString aOExtensionName = rtl::OUStringToOString( aExtensionName, fs::getThreadTextEncoding() ); - argv[2] = aOExtensionName.getStr(); - - for( sal_Int32 iXhp = 0 ; iXhp < nXhpFileCount ; ++iXhp ) - { - rtl::OUString aXhpFile = pXhpFiles[iXhp]; - - rtl::OString aOXhpFile = rtl::OUStringToOString( aXhpFile, fs::getThreadTextEncoding() ); - char* pArgStr = new char[aOXhpFile.getLength() + 1]; - strcpy( pArgStr, aOXhpFile.getStr() ); - argv[iXhp + 3] = pArgStr; - } - - std::vector<std::string> args; - for( sal_Int32 i = 1; i < argc; ++i ) - args.push_back(std::string( argv[i]) ); - - for( sal_Int32 iXhp = 0 ; iXhp < nXhpFileCount ; ++iXhp ) - delete argv[iXhp + 3]; - delete[] argv; - - rtl::OString aOExtensionLanguageRoot = rtl::OUStringToOString( aExtensionLanguageRoot, fs::getThreadTextEncoding() ); - const char* pExtensionPath = aOExtensionLanguageRoot.getStr(); - std::string aStdStrExtensionPath = pExtensionPath; - - // Set error handler - xmlSetStructuredErrorFunc( NULL, (xmlStructuredErrorFunc)StructuredXMLErrorFunction ); - try - { - HelpLinker* pHelpLinker = new HelpLinker(); - pHelpLinker->main( args,&aStdStrExtensionPath ); - delete pHelpLinker; - } - catch( const HelpProcessingException& e ) - { - if( GpXMLParsingException != NULL ) - { - o_rHelpProcessingErrorInfo = *GpXMLParsingException; - delete GpXMLParsingException; - GpXMLParsingException = NULL; - } - else - { - o_rHelpProcessingErrorInfo = e; - } - bSuccess = false; - } - // Reset error handler - xmlSetStructuredErrorFunc( NULL, NULL ); - - // i83624: Tree files - ::rtl::OUString aTreeFileURL = aExtensionLanguageRoot; - aTreeFileURL += rtl::OUString::createFromAscii( "/help.tree" ); - osl::DirectoryItem aTreeFileItem; - osl::FileBase::RC rcGet = osl::DirectoryItem::get( aTreeFileURL, aTreeFileItem ); - osl::FileStatus aFileStatus( FileStatusMask_FileSize ); - if( rcGet == osl::FileBase::E_None && - aTreeFileItem.getFileStatus( aFileStatus ) == osl::FileBase::E_None && - aFileStatus.isValid( FileStatusMask_FileSize ) ) - { - sal_uInt64 ret, len = aFileStatus.getFileSize(); - char* s = new char[ int(len) ]; // the buffer to hold the installed files - osl::File aFile( aTreeFileURL ); - aFile.open( OpenFlag_Read ); - aFile.read( s, len, ret ); - aFile.close(); - - XML_Parser parser = XML_ParserCreate( 0 ); - int parsed = XML_Parse( parser, s, int( len ), true ); - - if( parsed == 0 ) - { - XML_Error nError = XML_GetErrorCode( parser ); - o_rHelpProcessingErrorInfo.m_eErrorClass = HELPPROCESSING_XMLPARSING_ERROR; - o_rHelpProcessingErrorInfo.m_aErrorMsg = rtl::OUString::createFromAscii( XML_ErrorString( nError ) );; - o_rHelpProcessingErrorInfo.m_aXMLParsingFile = aTreeFileURL; - // CRAHSES!!! o_rHelpProcessingErrorInfo.m_nXMLParsingLine = XML_GetCurrentLineNumber( parser ); - bSuccess = false; - } - - XML_ParserFree( parser ); - delete[] s; - } - - return bSuccess; -} - -// vnd.sun.star.help://swriter/52821?Language=en-US&System=UNIX -/* vi:set tabstop=4 shiftwidth=4 expandtab: */ - diff --git a/xmlhelp/source/com/sun/star/help/makefile.mk b/xmlhelp/source/com/sun/star/help/makefile.mk index c30b36bea8a5..1e1a2c518fa0 100644 --- a/xmlhelp/source/com/sun/star/help/makefile.mk +++ b/xmlhelp/source/com/sun/star/help/makefile.mk @@ -56,62 +56,36 @@ CFLAGS+=-DSYSTEM_DB -I$(DB_INCLUDES) CFLAGS+=-DSYSTEM_EXPAT .ENDIF -OBJFILES=\ - $(OBJ)$/HelpLinker.obj \ - $(OBJ)$/HelpCompiler.obj -SLOFILES=\ - $(SLO)$/HelpLinker.obj \ - $(SLO)$/HelpCompiler.obj - -EXCEPTIONSFILES=\ - $(OBJ)$/HelpLinker.obj \ - $(OBJ)$/HelpCompiler.obj \ - $(SLO)$/HelpLinker.obj \ - $(SLO)$/HelpCompiler.obj -.IF "$(OS)" == "MACOSX" && "$(CPU)" == "P" && "$(COM)" == "GCC" -# There appears to be a GCC 4.0.1 optimization error causing _file:good() to -# report true right before the call to writeOut at HelpLinker.cxx:1.12 l. 954 -# but out.good() to report false right at the start of writeOut at -# HelpLinker.cxx:1.12 l. 537: -NOOPTFILES=\ - $(OBJ)$/HelpLinker.obj \ - $(SLO)$/HelpLinker.obj -.ENDIF -APP1TARGET= $(TARGET) -APP1OBJS=\ - $(OBJ)$/HelpLinker.obj \ - $(OBJ)$/HelpCompiler.obj -APP1RPATH=NONE +JAVACLASSFILES = \ + $(SOLARBINDIR)$/help$/$(PACKAGE)$/HelpIndexerTool.class \ + $(SOLARBINDIR)$/help$/$(PACKAGE)$/HelpFileDocument.class \ + $(CLASSDIR)$/$(PACKAGE)$/HelpSearch.class \ + $(CLASSDIR)$/$(PACKAGE)$/HelpComponent.class \ + $(CLASSDIR)$/$(PACKAGE)$/HelpIndexer.class -APP1STDLIBS+=$(SALLIB) $(BERKELEYLIB) $(XSLTLIB) $(EXPATASCII3RDLIB) +JAVAFILES = \ + HelpSearch.java \ + HelpComponent.java \ + HelpIndexer.java -SHL1TARGET =$(LIBBASENAME)$(DLLPOSTFIX) -SHL1LIBS= $(SLB)$/$(TARGET).lib -SHL1IMPLIB =i$(LIBBASENAME) -SHL1DEF =$(MISC)$/$(SHL1TARGET).def -SHL1STDLIBS =$(SALLIB) $(BERKELEYLIB) $(XSLTLIB) $(EXPATASCII3RDLIB) -SHL1USE_EXPORTS =ordinal +TRANSEX3FILES = \ + $(SOLARBINDIR)$/help$/$(PACKAGE)$/HelpIndexerTool.class \ + $(SOLARBINDIR)$/help$/$(PACKAGE)$/HelpFileDocument.class -DEF1NAME =$(SHL1TARGET) -DEFLIB1NAME =$(TARGET) +ADDFILES = $(subst,$(SOLARBINDIR)$/help,$(CLASSDIR) $(TRANSEX3FILES)) -JAVACLASSFILES = \ - $(CLASSDIR)$/$(PACKAGE)$/HelpSearch.class \ - $(CLASSDIR)$/$(PACKAGE)$/HelpIndexer.class \ - $(CLASSDIR)$/$(PACKAGE)$/HelpComponent.class \ - $(CLASSDIR)$/$(PACKAGE)$/HelpFileDocument.class +#JAVAFILES = $(subst,$(CLASSDIR)$/$(PACKAGE)$/, $(subst,.class,.java $(JAVACLASSFILES))) -JARFILES = ridl.jar jurt.jar unoil.jar juh.jar +JARFILES = ridl.jar jurt.jar unoil.jar juh.jar HelpIndexerTool.jar .IF "$(SYSTEM_LUCENE)" == "YES" XCLASSPATH!:=$(XCLASSPATH)$(PATH_SEPERATOR)$(LUCENE_CORE_JAR)$(PATH_SEPERATOR)$(LUCENE_ANALYZERS_JAR) COMP=fix_system_lucene .ELSE JARFILES += lucene-core-2.3.jar lucene-analyzers-2.3.jar .ENDIF -JAVAFILES = $(subst,$(CLASSDIR)$/$(PACKAGE)$/, $(subst,.class,.java $(JAVACLASSFILES))) -JARTARGET = LuceneHelpWrapper.jar +JARTARGET = LuceneHelpWrapper.jar JARCOMPRESS = TRUE CUSTOMMANIFESTFILE = MANIFEST.MF @@ -119,10 +93,18 @@ CUSTOMMANIFESTFILE = MANIFEST.MF .INCLUDE : target.mk +ALLTAR : $(ADDFILES) + .IF "$(JARTARGETN)"!="" +$(JARTARGETN) : $(ADDFILES) $(JARTARGETN) : $(COMP) .ENDIF +$(CLASSDIR)$/$(PACKAGE)$/%.class : $(SOLARBINDIR)$/help$/$(PACKAGE)$/%.class + $(MKDIRHIER) $(@:d) + $(COPY) $< $@ + + fix_system_lucene: @echo "Fix Java Class-Path entry for Lucene libraries from system." @$(SED) -r -e "s#^(Class-Path:).*#\1 file://$(LUCENE_CORE_JAR) file://$(LUCENE_ANALYZERS_JAR)#" \ diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx index 5ec3be8a231c..bd8b0dcd9c1b 100644 --- a/xmlhelp/source/cxxhelp/provider/databases.cxx +++ b/xmlhelp/source/cxxhelp/provider/databases.cxx @@ -52,6 +52,7 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/beans/Optional.hpp> +#include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/frame/XConfigManager.hpp> #include <com/sun/star/util/XMacroExpander.hpp> #include <com/sun/star/uri/XUriReferenceFactory.hpp> @@ -59,7 +60,8 @@ #include <com/sun/star/script/XInvocation.hpp> #include <comphelper/locale.hxx> -#include <xmlhelp/compilehelp.hxx> +#include <transex3/compilehelp.hxx> +#include <comphelper/storagehelper.hxx> #include "databases.hxx" #include "urlparameter.hxx" @@ -1080,7 +1082,7 @@ Reference< XHierarchicalNameAccess > Databases::jarFile( const rtl::OUString& ja zipFile = getInstallPathAsURL() + key; } - Sequence< Any > aArguments( 1 ); + Sequence< Any > aArguments( 2 ); XInputStream_impl* p = new XInputStream_impl( zipFile ); if( p->CtorSuccess() ) @@ -1094,6 +1096,12 @@ Reference< XHierarchicalNameAccess > Databases::jarFile( const rtl::OUString& ja aArguments[ 0 ] <<= zipFile; } + // let ZipPackage be used ( no manifest.xml is required ) + beans::NamedValue aArg; + aArg.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StorageFormat" ) ); + aArg.Value <<= ZIP_STORAGE_FORMAT_STRING; + aArguments[ 1 ] <<= aArg; + Reference< XInterface > xIfc = m_xSMgr->createInstanceWithArgumentsAndContext( rtl::OUString::createFromAscii( @@ -1862,9 +1870,15 @@ Reference< XHierarchicalNameAccess > JarFileIterator::implGetJarFromPackage try { - Sequence< Any > aArguments( 1 ); + Sequence< Any > aArguments( 2 ); aArguments[ 0 ] <<= zipFile; + // let ZipPackage be used ( no manifest.xml is required ) + beans::NamedValue aArg; + aArg.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StorageFormat" ) ); + aArg.Value <<= ZIP_STORAGE_FORMAT_STRING; + aArguments[ 1 ] <<= aArg; + Reference< XMultiComponentFactory >xSMgr( m_xContext->getServiceManager(), UNO_QUERY ); Reference< XInterface > xIfc = xSMgr->createInstanceWithArgumentsAndContext( diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx index 226fc056a237..b31f124fb005 100644 --- a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx +++ b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx @@ -749,8 +749,8 @@ fileMatch(const char * URI) { } static int -pkgMatch(const char * URI) { - if ((URI != NULL) && !strncmp(URI, "vnd.sun.star.pkg:/", 18)) +zipMatch(const char * URI) { + if ((URI != NULL) && !strncmp(URI, "vnd.sun.star.zip:/", 18)) return 1; return 0; } @@ -770,7 +770,7 @@ fileOpen(const char *URI) { } static void * -pkgOpen(const char * /*URI*/) { +zipOpen(const char * /*URI*/) { rtl::OUString language,jar,path; if( ugblData->m_pInitial->get_eid().getLength() ) @@ -855,7 +855,7 @@ helpRead(void * context, char * buffer, int len) { } static int -pkgRead(void * context, char * buffer, int len) { +zipRead(void * context, char * buffer, int len) { if( ugblData->m_pInitial->get_eid().getLength() ) { ugblData->m_pDatabases->popupDocument( ugblData->m_pInitial,&buffer,&len); @@ -1071,7 +1071,7 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam, ugblData = &userData; - xmlRegisterInputCallbacks(pkgMatch, pkgOpen, pkgRead, uriClose); + xmlRegisterInputCallbacks(zipMatch, zipOpen, zipRead, uriClose); xmlRegisterInputCallbacks(helpMatch, helpOpen, helpRead, uriClose); xmlRegisterInputCallbacks(fileMatch, fileOpen, fileRead, fileClose); //xmlSetStructuredErrorFunc( NULL, (xmlStructuredErrorFunc)StructuredXMLErrorFunction ); @@ -1079,7 +1079,7 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam, xsltStylesheetPtr cur = xsltParseStylesheetFile((const xmlChar *)xslURLascii.getStr()); - xmlDocPtr doc = xmlParseFile("vnd.sun.star.pkg:/"); + xmlDocPtr doc = xmlParseFile("vnd.sun.star.zip:/"); xmlDocPtr res = xsltApplyStylesheet(cur, doc, parameter); if (res) @@ -1092,7 +1092,7 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam, } xmlPopInputCallbacks(); //filePatch xmlPopInputCallbacks(); //helpPatch - xmlPopInputCallbacks(); //pkgMatch + xmlPopInputCallbacks(); //zipMatch xmlFreeDoc(res); xmlFreeDoc(doc); xsltFreeStylesheet(cur); diff --git a/xmloff/inc/xmlnmspe.hxx b/xmloff/inc/xmlnmspe.hxx index a79890f19a7d..f90ff05c084d 100644 --- a/xmloff/inc/xmlnmspe.hxx +++ b/xmloff/inc/xmlnmspe.hxx @@ -82,7 +82,15 @@ XML_NAMESPACE( OF, 34U ) // OpenFormula aka ODFF XML_NAMESPACE( XHTML, 35U ) XML_NAMESPACE( GRDDL, 36U ) -#define _XML_OLD_NAMESPACE_BASE 37U +// namespaces for odf extended formats + +#define XML_NAMESPACE_EXT( prefix, key ) \ +const sal_uInt16 XML_NAMESPACE_##prefix##_EXT = key; \ +const sal_uInt16 XML_NAMESPACE_##prefix##_EXT_IDX = key; + +XML_NAMESPACE_EXT( OFFICE, 37U ) + +#define _XML_OLD_NAMESPACE_BASE 38U // namespaces used in the technical preview (SO 5.2) XML_OLD_NAMESPACE( FO, 0U ) diff --git a/xmloff/inc/xmloff/xmlimp.hxx b/xmloff/inc/xmloff/xmlimp.hxx index 717f117be415..71a241d86008 100644 --- a/xmloff/inc/xmloff/xmlimp.hxx +++ b/xmloff/inc/xmloff/xmlimp.hxx @@ -175,6 +175,8 @@ protected: void SetAutoStyles( SvXMLStylesContext *pAutoStyles ); void SetMasterStyles( SvXMLStylesContext *pMasterStyles ); + sal_Bool IsODFVersionConsistent( const ::rtl::OUString& aODFVersion ); + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEmbeddedObjectResolver >& GetEmbeddedResolver() const { return mxEmbeddedResolver; } inline void SetEmbeddedResolver( com::sun::star::uno::Reference< com::sun::star::document::XEmbeddedObjectResolver >& _xEmbeddedResolver ); diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx index 978f6e698cc8..70e8ed82ca49 100644 --- a/xmloff/inc/xmloff/xmltoken.hxx +++ b/xmloff/inc/xmloff/xmltoken.hxx @@ -144,6 +144,10 @@ namespace xmloff { namespace token { XML_NP_GRDDL, XML_N_GRDDL, + // ODF Enhanced namespaces + XML_NP_OFFICE_EXT, + XML_N_OFFICE_EXT, + // units XML_UNIT_MM, XML_UNIT_M, diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index 8045cd582e2f..55af99802f9d 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -1358,6 +1358,7 @@ sal_uInt32 SvXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass ) const sal_Char* pVersion = 0; switch( getDefaultVersion() ) { + case SvtSaveOptions::ODFVER_LATEST: pVersion = sXML_1_2; break; case SvtSaveOptions::ODFVER_012: pVersion = sXML_1_2; break; case SvtSaveOptions::ODFVER_011: pVersion = sXML_1_1; break; case SvtSaveOptions::ODFVER_010: break; diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 975cb5432eb7..d4dc48ede241 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -58,13 +58,17 @@ #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> #include <com/sun/star/io/XOutputStream.hpp> #include <com/sun/star/document/XBinaryStreamResolver.hpp> +#include <com/sun/star/document/XStorageBasedDocument.hpp> #include <com/sun/star/xml/sax/XLocator.hpp> +#include <com/sun/star/packages/zip/ZipIOException.hpp> #include <comphelper/namecontainer.hxx> #include <rtl/logfile.hxx> #include <tools/string.hxx> // used in StartElement for logging #include <cppuhelper/implbase1.hxx> #include <comphelper/extract.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/documentconstants.hxx> +#include <comphelper/storagehelper.hxx> #include <vcl/fontcvt.hxx> #include <com/sun/star/rdf/XMetadatable.hpp> @@ -89,6 +93,7 @@ using namespace ::com::sun::star::document; using namespace ::xmloff::token; sal_Char __READONLY_DATA sXML_np__office[] = "_office"; +sal_Char __READONLY_DATA sXML_np__office_ext[] = "_office_ooo"; sal_Char __READONLY_DATA sXML_np__ooo[] = "_ooo"; sal_Char __READONLY_DATA sXML_np__ooow[] = "_ooow"; sal_Char __READONLY_DATA sXML_np__oooc[] = "_oooc"; @@ -241,6 +246,9 @@ void SvXMLImport::_InitCtor() mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office ) ), GetXMLToken(XML_N_OFFICE), XML_NAMESPACE_OFFICE ); + mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office_ext ) ), + GetXMLToken(XML_N_OFFICE_EXT), + XML_NAMESPACE_OFFICE_EXT ); mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__ooo ) ), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO ); mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__style) ), GetXMLToken(XML_N_STYLE), @@ -649,6 +657,21 @@ void SAL_CALL SvXMLImport::startElement( const OUString& rName, if ( rAttrName.equalsAscii("office:version") ) { mpImpl->aODFVersion = xAttrList->getValueByIndex( i ); + + // the ODF version in content.xml and manifest.xml must be the same starting from ODF1.2 + if ( mpImpl->mStreamName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "content.xml" ) ) ) + && !IsODFVersionConsistent( mpImpl->aODFVersion ) ) + { + throw xml::sax::SAXException( + ::rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "Inconsistent ODF versions in content.xml and manifest.xml!" ) ), + uno::Reference< uno::XInterface >(), + uno::makeAny( + packages::zip::ZipIOException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "Inconsistent ODF versions in content.xml and manifest.xml!" ) ), + Reference< XInterface >() ) ) ); + } } else if( ( rAttrName.getLength() >= 5 ) && ( rAttrName.compareToAscii( sXML_xmlns, 5 ) == 0 ) && @@ -1598,6 +1621,50 @@ OUString SvXMLImport::GetAbsoluteReference(const OUString& rValue) const return rValue; } +sal_Bool SvXMLImport::IsODFVersionConsistent( const ::rtl::OUString& aODFVersion ) +{ + // the check returns sal_False only if the storage version could be retrieved + sal_Bool bResult = sal_True; + + if ( aODFVersion.getLength() && aODFVersion.compareTo( ODFVER_012_TEXT ) >= 0 ) + { + // check the consistency only for the ODF1.2 and later ( according to content.xml ) + try + { + uno::Reference< document::XStorageBasedDocument > xDoc( mxModel, uno::UNO_QUERY_THROW ); + uno::Reference< embed::XStorage > xStor = xDoc->getDocumentStorage(); + uno::Reference< beans::XPropertySet > xStorProps( xStor, uno::UNO_QUERY_THROW ); + + // the check should be done only for OASIS format + ::rtl::OUString aMediaType; + xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ) ) >>= aMediaType; + if ( ::comphelper::OStorageHelper::GetXStorageFormat( xStor ) >= SOFFICE_FILEFORMAT_8 ) + { + sal_Bool bRepairPackage = sal_False; + try + { + xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RepairPackage" ) ) ) + >>= bRepairPackage; + } catch ( uno::Exception& ) + {} + + // check only if not in Repair mode + if ( !bRepairPackage ) + { + ::rtl::OUString aStorVersion; + xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) ) + >>= aStorVersion; + bResult = aODFVersion.equals( aStorVersion ); + } + } + } + catch( uno::Exception& ) + {} + } + + return bResult; +} + void SvXMLImport::_CreateNumberFormatsSupplier() { DBG_ASSERT( !mxNumberFormatsSupplier.is(), diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index d4f60e053b3c..ae95763f1936 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -152,6 +152,10 @@ namespace xmloff { namespace token { TOKEN( "grddl", XML_NP_GRDDL ), TOKEN( "http://www.w3.org/2003/g/data-view#", XML_N_GRDDL ), + // ODF Enhanced namespaces + TOKEN( "officeooo", XML_NP_OFFICE_EXT ), + TOKEN( "http://openoffice.org/2009/office", XML_N_OFFICE_EXT ), + // units TOKEN( "mm", XML_UNIT_MM ), TOKEN( "m", XML_UNIT_M ), diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index 67c66b6a1d5f..1d7414d4ca23 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -39,7 +39,9 @@ #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> #include <com/sun/star/presentation/XPresentationSupplier.hpp> #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp> +#include <com/sun/star/geometry/RealPoint2D.hpp> #include <com/sun/star/task/XStatusIndicatorSupplier.hpp> +#include <com/sun/star/office/XAnnotationAccess.hpp> #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/uno/Any.hxx> #include "sdxmlexp_impl.hxx" @@ -51,9 +53,7 @@ #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/style/XStyle.hpp> -#ifndef _COM_SUN_STAR_FORM_XFORMSUPPLIER2_HPP_ #include <com/sun/star/form/XFormsSupplier2.hpp> -#endif #include <com/sun/star/presentation/XPresentationPage.hpp> #include <com/sun/star/drawing/XMasterPageTarget.hpp> #include <com/sun/star/text/XText.hpp> @@ -96,9 +96,13 @@ using ::rtl::OUStringBuffer; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::util; using namespace ::com::sun::star::container; using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::office; using namespace ::com::sun::star::presentation; +using namespace ::com::sun::star::geometry; +using namespace ::com::sun::star::text; using namespace ::xmloff::token; @@ -640,6 +644,14 @@ void SAL_CALL SdXMLExport::setSourceDocument( const Reference< lang::XComponent GetXMLToken(XML_N_ANIMATION), XML_NAMESPACE_ANIMATION); + if( getDefaultVersion() == SvtSaveOptions::ODFVER_LATEST ) + { + _GetNamespaceMap().Add( + GetXMLToken(XML_NP_OFFICE_EXT), + GetXMLToken(XML_N_OFFICE_EXT), + XML_NAMESPACE_OFFICE_EXT); + } + GetShapeExport()->enableLayerExport(); // #88546# enable progress bar increments @@ -2060,6 +2072,8 @@ void SdXMLExport::_ExportContent() } } } + + exportAnnotations( xDrawPage ); } } @@ -2355,10 +2369,9 @@ void SdXMLExport::_ExportAutoStyles() // create auto style infos for objects on master pages for(sal_Int32 nMPageId(0L); nMPageId < mnDocMasterPageCount; nMPageId++) { - Any aAny(mxDocMasterPages->getByIndex(nMPageId)); - Reference< XDrawPage > xMasterPage; + Reference< XDrawPage > xMasterPage(mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY ); - if((aAny >>= xMasterPage) && xMasterPage.is() ) + if( xMasterPage.is() ) { // collect layer information GetFormExport()->examineForms( xMasterPage ); @@ -2397,6 +2410,7 @@ void SdXMLExport::_ExportAutoStyles() } } } + collectAnnotationAutoStyles(xMasterPage); } } } @@ -2413,10 +2427,8 @@ void SdXMLExport::_ExportAutoStyles() // create auto style infos for objects on pages for(sal_Int32 nPageInd(0); nPageInd < mnDocDrawPageCount; nPageInd++) { - Any aAny(mxDocDrawPages->getByIndex(nPageInd)); - Reference<XDrawPage> xDrawPage; - - if((aAny >>= xDrawPage) && xDrawPage.is() ) + Reference<XDrawPage> xDrawPage( mxDocDrawPages->getByIndex(nPageInd), UNO_QUERY ); + if( xDrawPage.is() ) { // collect layer information GetFormExport()->examineForms( xDrawPage ); @@ -2466,6 +2478,8 @@ void SdXMLExport::_ExportAutoStyles() } } } + + collectAnnotationAutoStyles( xDrawPage ); } } if(IsImpress()) @@ -2536,10 +2550,8 @@ void SdXMLExport::_ExportMasterStyles() // export MasterPages in master-styles section for(sal_Int32 nMPageId = 0L; nMPageId < mnDocMasterPageCount; nMPageId++) { - Any aAny(mxDocMasterPages->getByIndex(nMPageId)); - Reference< XDrawPage > xMasterPage; - - if((aAny >>= xMasterPage) && xMasterPage.is()) + Reference< XDrawPage > xMasterPage( mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY ); + if(xMasterPage.is()) { // prepare masterpage attributes OUString sMasterPageName; @@ -2610,6 +2622,7 @@ void SdXMLExport::_ExportMasterStyles() } } } + exportAnnotations( xMasterPage ); } } } @@ -2770,6 +2783,98 @@ OUString SdXMLExport::getNavigationOrder( const Reference< XDrawPage >& xDrawPag ////////////////////////////////////////////////////////////////////////////// +void SdXMLExport::collectAnnotationAutoStyles( const Reference<XDrawPage>& xDrawPage ) +{ + Reference< XAnnotationAccess > xAnnotationAccess( xDrawPage, UNO_QUERY ); + if( xAnnotationAccess.is() ) try + { + Reference< XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() ); + if( xAnnotationEnumeration.is() ) + { + while( xAnnotationEnumeration->hasMoreElements() ) + { + Reference< XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement(), UNO_QUERY_THROW ); + Reference< XText > xText( xAnnotation->getTextRange() ); + if(xText.is() && xText->getString().getLength()) + GetTextParagraphExport()->collectTextAutoStyles( xText ); + } + } + } + catch( Exception& ) + { + DBG_ERROR("SdXMLExport::collectAnnotationAutoStyles(), exception caught during export of annotation auto styles"); + } +} + +void SdXMLExport::exportAnnotations( const Reference<XDrawPage>& xDrawPage ) +{ + // do not export in ODF 1.2 or older + if( getDefaultVersion() != SvtSaveOptions::ODFVER_LATEST ) + return; + + Reference< XAnnotationAccess > xAnnotationAccess( xDrawPage, UNO_QUERY ); + if( xAnnotationAccess.is() ) try + { + Reference< XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() ); + if( xAnnotationEnumeration.is() && xAnnotationEnumeration->hasMoreElements() ) + { + OUStringBuffer sStringBuffer; + do + { + Reference< XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement(), UNO_QUERY_THROW ); + + RealPoint2D aPosition( xAnnotation->getPosition() ); + + GetMM100UnitConverter().convertMeasure(sStringBuffer, static_cast<sal_Int32>( aPosition.X * 100 ) ); + AddAttribute(XML_NAMESPACE_SVG, XML_X, sStringBuffer.makeStringAndClear()); + + GetMM100UnitConverter().convertMeasure(sStringBuffer, static_cast<sal_Int32>( aPosition.Y * 100 ) ); + AddAttribute(XML_NAMESPACE_SVG, XML_Y, sStringBuffer.makeStringAndClear()); + + RealSize2D aSize( xAnnotation->getSize() ); + + if( aSize.Width || aSize.Height ) + { + GetMM100UnitConverter().convertMeasure(sStringBuffer, static_cast<sal_Int32>( aSize.Width * 100 ) ); + AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, sStringBuffer.makeStringAndClear()); + GetMM100UnitConverter().convertMeasure(sStringBuffer, static_cast<sal_Int32>( aSize.Height * 100 ) ); + AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, sStringBuffer.makeStringAndClear()); + } + + // annotation element + content + SvXMLElementExport aElem(*this, XML_NAMESPACE_OFFICE_EXT, XML_ANNOTATION, sal_False, sal_True); + + // author + OUString aAuthor( xAnnotation->getAuthor() ); + if( aAuthor.getLength() ) + { + SvXMLElementExport aCreatorElem( *this, XML_NAMESPACE_DC, XML_CREATOR, sal_True, sal_False ); + this->Characters(aAuthor); + } + + { + // date time + DateTime aDate( xAnnotation->getDateTime() ); + GetMM100UnitConverter().convertDateTime(sStringBuffer, aDate, sal_True); + SvXMLElementExport aDateElem( *this, XML_NAMESPACE_DC, XML_DATE, sal_True, sal_False ); + Characters(sStringBuffer.makeStringAndClear()); + } + + com::sun::star::uno::Reference < com::sun::star::text::XText > xText( xAnnotation->getTextRange() ); + if( xText.is() ) + this->GetTextParagraphExport()->exportText( xText ); + } + while( xAnnotationEnumeration->hasMoreElements() ); + } + } + catch( Exception& ) + { + DBG_ERROR("SdXMLExport::exportAnnotations(), exception caught during export of annotations"); + } +} + +////////////////////////////////////////////////////////////////////////////// + #define SERVICE( classname, servicename, implementationname, draw, flags )\ uno::Sequence< OUString > SAL_CALL classname##_getSupportedServiceNames() throw()\ {\ diff --git a/xmloff/source/draw/sdxmlexp_impl.hxx b/xmloff/source/draw/sdxmlexp_impl.hxx index eaf5c7c531f2..2738e948ea69 100644 --- a/xmloff/source/draw/sdxmlexp_impl.hxx +++ b/xmloff/source/draw/sdxmlexp_impl.hxx @@ -186,6 +186,9 @@ class SdXMLExport : public SvXMLExport rtl::OUString getNavigationOrder( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xDrawPage ); + void collectAnnotationAutoStyles( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xDrawPage ); + void exportAnnotations( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xDrawPage ); + protected: virtual void GetViewSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps); virtual void GetConfigurationSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps); diff --git a/xmloff/source/draw/ximppage.cxx b/xmloff/source/draw/ximppage.cxx index 4daa6263d391..9d64d49f9421 100644 --- a/xmloff/source/draw/ximppage.cxx +++ b/xmloff/source/draw/ximppage.cxx @@ -32,6 +32,9 @@ #include "precompiled_xmloff.hxx" #include <tools/debug.hxx> +#include <com/sun/star/geometry/RealPoint2D.hpp> +#include <com/sun/star/text/XTextCursor.hpp> +#include <com/sun/star/util/DateTime.hpp> #include <cppuhelper/implbase1.hxx> #include "XMLNumberStylesImport.hxx" #include <xmloff/xmlstyle.hxx> @@ -41,6 +44,7 @@ #include "ximppage.hxx" #include "ximpshap.hxx" #include "animimp.hxx" +#include "XMLStringBufferImportContext.hxx" #include <xmloff/formsimp.hxx> #include <xmloff/xmlictxt.hxx> #include "ximpstyl.hxx" @@ -57,9 +61,155 @@ using namespace ::com::sun::star; using namespace ::xmloff::token; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::util; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::drawing; using namespace ::com::sun::star::container; +using namespace ::com::sun::star::office; +using namespace ::com::sun::star::xml::sax; +using namespace ::com::sun::star::geometry; + + +////////////////////////////////////////////////////////////////////////////// + +class DrawAnnotationContext : public SvXMLImportContext +{ + +public: + DrawAnnotationContext( SvXMLImport& rImport, USHORT nPrfx, const OUString& rLocalName,const Reference< xml::sax::XAttributeList>& xAttrList, const Reference< XAnnotationAccess >& xAnnotationAccess ); + + virtual SvXMLImportContext * CreateChildContext( USHORT nPrefix, const ::rtl::OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList ); + virtual void EndElement(); + +private: + Reference< XAnnotation > mxAnnotation; + Reference< XTextCursor > mxCursor; + + OUStringBuffer maAuthorBuffer; + OUStringBuffer maDateBuffer; +}; + +DrawAnnotationContext::DrawAnnotationContext( SvXMLImport& rImport, USHORT nPrfx, const OUString& rLocalName,const Reference< xml::sax::XAttributeList>& xAttrList, const Reference< XAnnotationAccess >& xAnnotationAccess ) +: SvXMLImportContext( rImport, nPrfx, rLocalName ) +, mxAnnotation( xAnnotationAccess->createAndInsertAnnotation() ) +{ + if( mxAnnotation.is() ) + { + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + + RealPoint2D aPosition; + RealSize2D aSize; + + for(sal_Int16 i=0; i < nAttrCount; i++) + { + OUString sValue( xAttrList->getValueByIndex( i ) ); + OUString sAttrName( xAttrList->getNameByIndex( i ) ); + OUString aLocalName; + switch( GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ) ) + { + case XML_NAMESPACE_SVG: + if( IsXMLToken( aLocalName, XML_X ) ) + { + sal_Int32 x; + GetImport().GetMM100UnitConverter().convertMeasure(x, sValue); + aPosition.X = static_cast<double>(x) / 100.0; + } + else if( IsXMLToken( aLocalName, XML_Y ) ) + { + sal_Int32 y; + GetImport().GetMM100UnitConverter().convertMeasure(y, sValue); + aPosition.Y = static_cast<double>(y) / 100.0; + } + else if( IsXMLToken( aLocalName, XML_WIDTH ) ) + { + sal_Int32 w; + GetImport().GetMM100UnitConverter().convertMeasure(w, sValue); + aSize.Width = static_cast<double>(w) / 100.0; + } + else if( IsXMLToken( aLocalName, XML_HEIGHT ) ) + { + sal_Int32 h; + GetImport().GetMM100UnitConverter().convertMeasure(h, sValue); + aSize.Height = static_cast<double>(h) / 100.0; + } + break; + default: + break; + } + } + + mxAnnotation->setPosition( aPosition ); + mxAnnotation->setSize( aSize ); + } +} + +SvXMLImportContext * DrawAnnotationContext::CreateChildContext( USHORT nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList ) +{ + SvXMLImportContext * pContext = NULL; + + if( mxAnnotation.is() ) + { + if( XML_NAMESPACE_DC == nPrefix ) + { + if( IsXMLToken( rLocalName, XML_CREATOR ) ) + pContext = new XMLStringBufferImportContext(GetImport(), nPrefix, rLocalName, maAuthorBuffer); + else if( IsXMLToken( rLocalName, XML_DATE ) ) + pContext = new XMLStringBufferImportContext(GetImport(), nPrefix, rLocalName, maDateBuffer); + } + else + { + // create text cursor on demand + if( !mxCursor.is() ) + { + uno::Reference< text::XText > xText( mxAnnotation->getTextRange() ); + if( xText.is() ) + { + UniReference < XMLTextImportHelper > xTxtImport = GetImport().GetTextImport(); + mxCursor = xText->createTextCursor(); + if( mxCursor.is() ) + xTxtImport->SetCursor( mxCursor ); + } + } + + // if we have a text cursor, lets try to import some text + if( mxCursor.is() ) + { + pContext = GetImport().GetTextImport()->CreateTextChildContext( GetImport(), nPrefix, rLocalName, xAttrList ); + } + } + } + + // call parent for content + if(!pContext) + pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList ); + + return pContext; +} + +void DrawAnnotationContext::EndElement() +{ + if(mxCursor.is()) + { + // delete addition newline + const OUString aEmpty; + mxCursor->gotoEnd( sal_False ); + mxCursor->goLeft( 1, sal_True ); + mxCursor->setString( aEmpty ); + + // reset cursor + GetImport().GetTextImport()->ResetCursor(); + } + + if( mxAnnotation.is() ) + { + mxAnnotation->setAuthor( maAuthorBuffer.makeStringAndClear() ); + + DateTime aDateTime; + if(SvXMLUnitConverter::convertDateTime(aDateTime, maDateBuffer.makeStringAndClear())) + mxAnnotation->setDateTime(aDateTime); + } +} ////////////////////////////////////////////////////////////////////////////// @@ -70,8 +220,9 @@ SdXMLGenericPageContext::SdXMLGenericPageContext( USHORT nPrfx, const OUString& rLocalName, const Reference< xml::sax::XAttributeList>& xAttrList, Reference< drawing::XShapes >& rShapes) -: SvXMLImportContext( rImport, nPrfx, rLocalName ), - mxShapes( rShapes ) +: SvXMLImportContext( rImport, nPrfx, rLocalName ) +, mxShapes( rShapes ) +, mxAnnotationAccess( rShapes, UNO_QUERY ) { sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; @@ -100,10 +251,8 @@ void SdXMLGenericPageContext::StartElement( const Reference< ::com::sun::star::x { GetImport().GetShapeImport()->pushGroupForSorting( mxShapes ); -#ifndef SVX_LIGHT if( GetImport().IsFormsSupported() ) GetImport().GetFormImport()->startPage( Reference< drawing::XDrawPage >::query( mxShapes ) ); -#endif } ////////////////////////////////////////////////////////////////////////////// @@ -120,10 +269,13 @@ SvXMLImportContext* SdXMLGenericPageContext::CreateChildContext( USHORT nPrefix, } else if( nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_FORMS ) ) { -#ifndef SVX_LIGHT if( GetImport().IsFormsSupported() ) pContext = GetImport().GetFormImport()->createOfficeFormsContext( GetImport(), nPrefix, rLocalName ); -#endif + } + else if( ((nPrefix == XML_NAMESPACE_OFFICE) || (nPrefix == XML_NAMESPACE_OFFICE_EXT)) && IsXMLToken( rLocalName, XML_ANNOTATION ) ) + { + if( mxAnnotationAccess.is() ) + pContext = new DrawAnnotationContext( GetImport(), nPrefix, rLocalName, xAttrList, mxAnnotationAccess ); } else { diff --git a/xmloff/source/draw/ximppage.hxx b/xmloff/source/draw/ximppage.hxx index fa32546b0810..45b505e2044f 100644 --- a/xmloff/source/draw/ximppage.hxx +++ b/xmloff/source/draw/ximppage.hxx @@ -35,6 +35,7 @@ #include "sdxmlimp_impl.hxx" #include <xmloff/nmspmap.hxx> #include <com/sun/star/drawing/XShapes.hpp> +#include <com/sun/star/office/XAnnotationAccess.hpp> #include <tools/rtti.hxx> #include "ximpshap.hxx" @@ -44,7 +45,8 @@ class SdXMLGenericPageContext : public SvXMLImportContext { // the shape group this group is working on - com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > mxShapes; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > mxShapes; + ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotationAccess > mxAnnotationAccess; protected: rtl::OUString maPageLayoutName; diff --git a/xmloff/source/meta/MetaExportComponent.cxx b/xmloff/source/meta/MetaExportComponent.cxx index 0b65592c3613..996e75d0f740 100644 --- a/xmloff/source/meta/MetaExportComponent.cxx +++ b/xmloff/source/meta/MetaExportComponent.cxx @@ -170,6 +170,7 @@ sal_uInt32 XMLMetaExportComponent::exportDoc( enum XMLTokenEnum ) const sal_Char* pVersion = 0; switch( getDefaultVersion() ) { + case SvtSaveOptions::ODFVER_LATEST: pVersion = "1.2"; break; case SvtSaveOptions::ODFVER_012: pVersion = "1.2"; break; case SvtSaveOptions::ODFVER_011: pVersion = "1.1"; break; case SvtSaveOptions::ODFVER_010: break; diff --git a/xmloff/util/makefile.mk b/xmloff/util/makefile.mk index d9ef85c2178d..31852e15175a 100644 --- a/xmloff/util/makefile.mk +++ b/xmloff/util/makefile.mk @@ -41,7 +41,7 @@ USE_DEFFILE=TRUE .INCLUDE: $(PRJ)$/util$/makefile.pmk # --- Allgemein ---------------------------------------------------- - +.IF "$(L10N_framework)"=="" LIB1TARGET= $(SLB)$/xo.lib LIB1FILES= \ $(SLB)$/core.lib \ @@ -115,5 +115,5 @@ DEFLIB1NAME =xo DEF1DES =XML Office Lib # --- Targets ---------------------------------------------------------- - +.ENDIF .INCLUDE : target.mk diff --git a/xmlscript/source/misc/makefile.mk b/xmlscript/source/misc/makefile.mk index 8bd9b7919857..fbd7b0b098e1 100644 --- a/xmlscript/source/misc/makefile.mk +++ b/xmlscript/source/misc/makefile.mk @@ -39,7 +39,7 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - +.IF "$(L10N_framework)"=="" #----------------------------------------------------------- SLOFILES = \ @@ -48,4 +48,5 @@ SLOFILES = \ # --- Targets ------------------------------------------------------ .INCLUDE : $(PRJ)$/util$/target.pmk +.ENDIF # L10N_framework .INCLUDE : target.mk diff --git a/xmlscript/source/xml_helper/makefile.mk b/xmlscript/source/xml_helper/makefile.mk index 61f2636064ab..e5e96ff6863c 100644 --- a/xmlscript/source/xml_helper/makefile.mk +++ b/xmlscript/source/xml_helper/makefile.mk @@ -38,7 +38,7 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - +.IF "$(L10N_framework)"=="" #----------------------------------------------------------- SLOFILES = \ @@ -49,4 +49,6 @@ SLOFILES = \ # --- Targets ------------------------------------------------------ .INCLUDE : $(PRJ)$/util$/target.pmk +.ENDIF # L10N_framework + .INCLUDE : target.mk diff --git a/xmlscript/source/xmldlg_imexp/makefile.mk b/xmlscript/source/xmldlg_imexp/makefile.mk index acb8321266f2..86b57a27f601 100644 --- a/xmlscript/source/xmldlg_imexp/makefile.mk +++ b/xmlscript/source/xmldlg_imexp/makefile.mk @@ -38,7 +38,7 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - +.IF "$(L10N_framework)"=="" #----------------------------------------------------------- SLOFILES = \ @@ -51,4 +51,6 @@ SLOFILES = \ # --- Targets ------------------------------------------------------ .INCLUDE : $(PRJ)$/util$/target.pmk +.ENDIF # L10N_framework + .INCLUDE : target.mk diff --git a/xmlscript/source/xmlflat_imexp/makefile.mk b/xmlscript/source/xmlflat_imexp/makefile.mk index f2c677fd888a..8d6f9fbfa9d9 100644 --- a/xmlscript/source/xmlflat_imexp/makefile.mk +++ b/xmlscript/source/xmlflat_imexp/makefile.mk @@ -39,7 +39,7 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - +.IF "$(L10N_framework)"=="" #----------------------------------------------------------- SLOFILES = \ @@ -49,4 +49,6 @@ SLOFILES = \ # --- Targets ------------------------------------------------------ .INCLUDE : $(PRJ)$/util$/target.pmk +.ENDIF # L10N_framework + .INCLUDE : target.mk diff --git a/xmlscript/source/xmllib_imexp/makefile.mk b/xmlscript/source/xmllib_imexp/makefile.mk index ca4cae0e23b3..2d29c3d2d4bc 100644 --- a/xmlscript/source/xmllib_imexp/makefile.mk +++ b/xmlscript/source/xmllib_imexp/makefile.mk @@ -38,7 +38,7 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - +.IF "$(L10N_framework)"=="" #----------------------------------------------------------- SLOFILES = \ @@ -48,4 +48,7 @@ SLOFILES = \ # --- Targets ------------------------------------------------------ .INCLUDE : $(PRJ)$/util$/target.pmk + +.ENDIF # L10N_framework + .INCLUDE : target.mk diff --git a/xmlscript/source/xmlmod_imexp/makefile.mk b/xmlscript/source/xmlmod_imexp/makefile.mk index ee5bb85cecff..96d74a41ddec 100644 --- a/xmlscript/source/xmlmod_imexp/makefile.mk +++ b/xmlscript/source/xmlmod_imexp/makefile.mk @@ -38,7 +38,7 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - +.IF "$(L10N_framework)"=="" #----------------------------------------------------------- SLOFILES = \ @@ -48,4 +48,6 @@ SLOFILES = \ # --- Targets ------------------------------------------------------ .INCLUDE : $(PRJ)$/util$/target.pmk + +.ENDIF # L10N_framework .INCLUDE : target.mk |