--- sfx2/inc/objsh.hxx	2 May 2006 16:01:46 -0000	1.65
+++ sfx2/inc/objsh.hxx	15 Jun 2006 12:12:47 -0000
@@ -714,6 +714,7 @@ public:
 					const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
 
 	SAL_DLLPRIVATE void InitOwnModel_Impl();
+	SAL_DLLPRIVATE void BreakMacroSign_Impl( sal_Bool bBreakMacroSing );
 	SAL_DLLPRIVATE void CheckMacrosOnLoading_Impl();
 
 	SAL_DLLPRIVATE static SEQUENCE< OUSTRING > GetEventNames_Impl();
Index: source/doc/sfxbasemodel.cxx
===================================================================
RCS file: /cvs/framework/sfx2/source/doc/sfxbasemodel.cxx,v
retrieving revision 1.110
diff -u -p -r1.110 sfxbasemodel.cxx
--- sfx2/source/doc/sfxbasemodel.cxx	2 May 2006 16:45:09 -0000	1.110
+++ sfx2/source/doc/sfxbasemodel.cxx	15 Jun 2006 12:15:21 -0000
@@ -1182,6 +1182,12 @@ sal_Bool SAL_CALL SfxBaseModel::attachRe
                     m_pData->m_pObjectShell->SetVisArea( aTmpRect );
                 }
 			}
+			else if ( rArgs[nInd].Name.equalsAscii( "BreakMacroSignature" ) )
+			{
+				sal_Bool bBreakMacroSign = sal_False;
+				rArgs[nInd].Value >>= bBreakMacroSign;
+				m_pData->m_pObjectShell->BreakMacroSign_Impl( bBreakMacroSign );
+			}
 			else if ( !rArgs[nInd].Name.equalsAscii( "Stream" ) && !rArgs[nInd].Name.equalsAscii( "InputStream" ) )
 			{
 				// TODO/LATER: all the parameters that are accepted by ItemSet of the DocShell must be ignored here
Index: source/inc/objshimp.hxx
===================================================================
RCS file: /cvs/framework/sfx2/source/inc/objshimp.hxx,v
retrieving revision 1.31
diff -u -p -r1.31 objshimp.hxx
--- sfx2/source/inc/objshimp.hxx	24 Mar 2006 13:18:16 -0000	1.31
+++ sfx2/source/inc/objshimp.hxx	15 Jun 2006 12:15:24 -0000
@@ -112,7 +112,8 @@ struct SfxObjectShell_Impl
                         bInitialized:1,
                         bSignatureErrorIsShown:1,
                         bModelInitialized:1, // whether the related model is initialized
-                        bPreserveVersions:1;
+                        bPreserveVersions:1,
+						m_bMacroSignBroken:1; // whether the macro signature was explicitly broken
 
 	String              aNewName;  // Der Name, unter dem das Doc gespeichert
 								   // werden soll
@@ -221,6 +222,7 @@ struct SfxObjectShell_Impl
         bLoadingWindows( sal_False ),
         bPreserveVersions( sal_True )
         //, bHidden( sal_False )
+		, m_bMacroSignBroken( sal_False )
 		, nStyleFilter( 0 )
         , nMacroMode( -1 )
 		, bDisposing( sal_False )
Index: source/script/xmlscripti.cxx
===================================================================
RCS file: /cvs/xml/xmloff/source/script/xmlscripti.cxx,v
retrieving revision 1.11
diff -u -p -r1.11 xmlscripti.cxx
--- xmloff/source/script/xmlscripti.cxx	9 Sep 2005 14:21:30 -0000	1.11
+++ xmloff/source/script/xmlscripti.cxx	15 Jun 2006 12:17:54 -0000
@@ -156,7 +156,18 @@ SvXMLImportContext* XMLScriptContext::Cr
             if ( xAttrList.is() )
             {
                 ::rtl::OUString aLanguage = xAttrList->getValueByName( aAttrName );
-                pContext = new XMLScriptChildContext( GetImport(), nPrefix, rLName, m_xModel, aLanguage );
+
+				if ( m_xModel.is() )
+				{
+					uno::Sequence< beans::PropertyValue > aMedDescr = m_xModel->getArgs();
+					sal_Int32 nNewLen = aMedDescr.getLength() + 1;
+					aMedDescr.realloc( nNewLen );
+					aMedDescr[nNewLen-1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BreakMacroSignature" ) );
+					aMedDescr[nNewLen-1].Value <<= (sal_Bool)sal_True;
+					m_xModel->attachResource( m_xModel->getURL(), aMedDescr );
+
+                	pContext = new XMLScriptChildContext( GetImport(), nPrefix, rLName, m_xModel, aLanguage );
+				}
             }
         }
 	}

--- sfx2/source/doc/objmisc.cxx.old	2007-01-24 19:06:20.765625000 +0100
+++ sfx2/source/doc/objmisc.cxx	2007-01-24 19:09:33.453125000 +0100
@@ -1058,6 +1058,12 @@
 }
 
 //-------------------------------------------------------------------------
+void SfxObjectShell::BreakMacroSign_Impl( sal_Bool bBreakMacroSign )
+{
+	pImp->m_bMacroSignBroken = bBreakMacroSign;
+}
+
+//-------------------------------------------------------------------------
 void SfxObjectShell::CheckMacrosOnLoading_Impl()
 {
 	const SfxFilter* pFilter = pMedium->GetFilter();
@@ -1072,40 +1078,23 @@
 		pImp->bMacroDisabled = sal_True;
 		pImp->nMacroMode = MacroExecMode::NEVER_EXECUTE;
 	}
-	else if ( bHasStorage && ( !pFilter || !( pFilter->GetFilterFlags() & SFX_FILTER_STARONEFILTER ) ) )
+	else 
 	{
-		uno::Reference< embed::XStorage > xStorage = pMedium->GetStorage();
-		if ( xStorage.is() )
+		sal_Bool bHasMacros = sal_False;
+		if ( bHasStorage && ( !pFilter || !( pFilter->GetFilterFlags() & SFX_FILTER_STARONEFILTER ) ) )
 		{
-			BOOL bHasMacros = StorageHasMacros( xStorage );
-
-			if ( bHasMacros )
-			{
-				AdjustMacroMode( String() ); // if macros are disabled the message will be shown here
-				if ( SvtSecurityOptions().GetMacroSecurityLevel() >= 2
-					&& MacroExecMode::NEVER_EXECUTE == pImp->nMacroMode )
-				{
-					WarningBox aBox( NULL, SfxResId( MSG_WARNING_MACRO_ISDISABLED ) );
-					aBox.Execute();
-				}
-			}
-			else if ( !pImp->bMacroDisabled )
-			{
-				// if macros will be added by the user later, the security check is obsolete
-				pImp->nMacroMode = MacroExecMode::ALWAYS_EXECUTE_NO_WARN;
-			}
+			uno::Reference< embed::XStorage > xStorage = pMedium->GetStorage();
+			if ( xStorage.is() )
+				bHasMacros = StorageHasMacros( xStorage );
+			else
+				SetError( ERRCODE_IO_GENERAL );
 		}
-		else
-			SetError( ERRCODE_IO_GENERAL );
-	}
-	else
-	{
-		if ( HasMacrosLib_Impl() )
+
+		if ( bHasMacros )
 		{
-			// no signing in alien formats!
 			AdjustMacroMode( String() ); // if macros are disabled the message will be shown here
 			if ( SvtSecurityOptions().GetMacroSecurityLevel() >= 2
-			  && MacroExecMode::NEVER_EXECUTE == pImp->nMacroMode )
+				  && MacroExecMode::NEVER_EXECUTE == pImp->nMacroMode )
 			{
 				WarningBox aBox( NULL, SfxResId( MSG_WARNING_MACRO_ISDISABLED ) );
 				aBox.Execute();
@@ -1987,6 +1976,13 @@
 	    	::com::sun::star::uno::Sequence< security::DocumentSignatureInformation > aScriptingSignatureInformations;
             uno::Reference < embed::XStorage > xStore = GetMedium()->GetLastCommitReadStorage_Impl();
 	    	sal_uInt16 nSignatureState = GetScriptingSignatureState();
+
+            if ( nSignatureState != SIGNATURESTATE_NOSIGNATURES && pImp->m_bMacroSignBroken )
+			{
+				// if there is a macro signature it must be handled as broken
+	    		nSignatureState = SIGNATURESTATE_SIGNATURES_BROKEN;
+			}
+			
 	    	if ( nSignatureState == SIGNATURESTATE_SIGNATURES_BROKEN )
 	    	{
 				if ( pImp->nMacroMode != MacroExecMode::FROM_LIST_AND_SIGNED_NO_WARN )
@@ -2263,23 +2259,30 @@
         if ( bHasMacros )
         {
             // a library container exists; check if it's empty
-            try
-            {
-                // usually a "Standard" library is always present (design)
-                // for this reason we must check if it's empty
-                uno::Reference < container::XNameAccess > xLib;
-                uno::Any aAny = pImp->pBasicLibContainer->getByName(::rtl::OUString::createFromAscii("Standard"));
-                aAny >>= xLib;
-                if ( xLib.is() )
-                    bHasMacros = xLib->hasElements();
-            }
-            catch ( uno::Exception& )
-            {
-                // if no "Standard" library is present we check for others
-                // here we assume that they are not empty (because they have been created by the user)
-                bHasMacros = pImp->pBasicLibContainer->hasElements();
-            }
-        }
+
+			// if there are libraries except "Standard" library
+			// we assume that they are not empty (because they have been created by the user)
+			if ( pImp->pBasicLibContainer->hasElements() )
+			{
+				::rtl::OUString aStdLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
+				uno::Sequence< ::rtl::OUString > aElements = pImp->pBasicLibContainer->getElementNames();
+				if ( aElements.getLength() )
+				{
+					if ( aElements.getLength() > 1 || !aElements[0].equals( aStdLibName ) )
+						bHasMacros = sal_True;
+					else	
+					{
+						// usually a "Standard" library is always present (design)
+						// for this reason we must check if it's empty
+						uno::Reference < container::XNameAccess > xLib;
+						uno::Any aAny = pImp->pBasicLibContainer->getByName( aStdLibName );
+						aAny >>= xLib;
+						if ( xLib.is() )
+							bHasMacros = xLib->hasElements();
+					}
+				}
+			}
+		}
     }
     catch( uno::Exception& )
     {
