summaryrefslogtreecommitdiff
path: root/sw/source/filter/html
diff options
context:
space:
mode:
authorMichael Brauer <mib@openoffice.org>2002-08-01 12:28:41 +0000
committerMichael Brauer <mib@openoffice.org>2002-08-01 12:28:41 +0000
commitd8dd30a5e2e802ae6c2133f8b803c55e479bec04 (patch)
treeadee60f8b18a781a1f26475a6e828f5a18213aca /sw/source/filter/html
parentd8da22e3984f053452f964347f070381f8279d2e (diff)
#98369#: <object> element for applets
Diffstat (limited to 'sw/source/filter/html')
-rw-r--r--sw/source/filter/html/SwAppletImpl.cxx34
-rw-r--r--sw/source/filter/html/htmlplug.cxx225
-rw-r--r--sw/source/filter/html/swhtml.cxx25
-rw-r--r--sw/source/filter/html/swhtml.hxx6
4 files changed, 207 insertions, 83 deletions
diff --git a/sw/source/filter/html/SwAppletImpl.cxx b/sw/source/filter/html/SwAppletImpl.cxx
index 56e0b81315e3..6cf5c42dce97 100644
--- a/sw/source/filter/html/SwAppletImpl.cxx
+++ b/sw/source/filter/html/SwAppletImpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: SwAppletImpl.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: mib $ $Date: 2001-11-26 11:33:14 $
+ * last change: $Author: mib $ $Date: 2002-08-01 13:28:37 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,7 +67,6 @@
sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_O_hidden, "HIDDEN" );
sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_HIDDEN_false, "FALSE" );
-sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_O_archive, "ARCHIVE" );
sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_O_archives, "ARCHIVES" );
sal_Char __FAR_DATA SVTOOLS_CONSTASCII_DEF( sHTML_O_object, "OBJECT" );
@@ -194,6 +193,35 @@ void SwApplet_Impl::CreateApplet( const String& rCode, const String& rName,
//sAlt = rAlt;
}
+
+sal_Bool SwApplet_Impl::CreateApplet()
+{
+ String aCode, aName, aCodeBase;
+ sal_Bool bMayScript = sal_False;
+
+ sal_uInt32 nArgCount = aCommandList.Count();
+ for( sal_uInt32 i=0; i<nArgCount; i++ )
+ {
+ const SvCommand& rArg = aCommandList[i];
+ const String& rName = rArg.GetCommand();
+ if( rName.EqualsIgnoreCaseAscii( sHTML_O_code ) )
+ aCode = rArg.GetArgument();
+ else if( rName.EqualsIgnoreCaseAscii( sHTML_O_codebase ) )
+ aCodeBase = rArg.GetArgument();
+ else if( rName.EqualsIgnoreCaseAscii( sHTML_O_name ) )
+ aName = rArg.GetArgument();
+ else if( rName.EqualsIgnoreCaseAscii( sHTML_O_mayscript ) )
+ bMayScript = sal_True;
+ }
+
+ if( !aCode.Len() )
+ return sal_False;
+
+ CreateApplet( aCode, aName, bMayScript, aCodeBase );
+ return sal_True;
+}
+
+
SwApplet_Impl::~SwApplet_Impl()
{
xApplet.Clear();
diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx
index 86b24d2c4e51..64ba7657b882 100644
--- a/sw/source/filter/html/htmlplug.cxx
+++ b/sw/source/filter/html/htmlplug.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: htmlplug.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: os $ $Date: 2001-09-28 06:27:53 $
+ * last change: $Author: mib $ $Date: 2002-08-01 13:28:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -282,14 +282,15 @@ void SwHTMLParser::SetSpace( const Size& rPixSpace,
SvxCSS1PropertyInfo& rCSS1PropInfo,
SfxItemSet& rFlyItemSet )
{
- USHORT nLeftSpace = 0, nRightSpace = 0, nUpperSpace = 0, nLowerSpace = 0;
+ sal_Int32 nLeftSpace = 0, nRightSpace = 0;
+ sal_uInt16 nUpperSpace = 0, nLowerSpace = 0;
if( (rPixSpace.Width() || rPixSpace.Height()) && Application::GetDefaultDevice() )
{
Size aTwipSpc( rPixSpace.Width(), rPixSpace.Height() );
aTwipSpc =
Application::GetDefaultDevice()->PixelToLogic( aTwipSpc,
MapMode(MAP_TWIP) );
- nLeftSpace = nRightSpace = (USHORT)aTwipSpc.Width();
+ nLeftSpace = nRightSpace = aTwipSpc.Width();
nUpperSpace = nLowerSpace = (USHORT)aTwipSpc.Height();
}
@@ -313,11 +314,11 @@ void SwHTMLParser::SetSpace( const Size& rPixSpace,
}
rCSS1ItemSet.ClearItem( RES_LR_SPACE );
}
- if( nLeftSpace || nRightSpace )
+ if( nLeftSpace > 0 || nRightSpace > 0 )
{
SvxLRSpaceItem aLRItem;
- aLRItem.SetLeft( nLeftSpace );
- aLRItem.SetRight( nRightSpace );
+ aLRItem.SetLeft( nLeftSpace > 0 ? nLeftSpace : 0 );
+ aLRItem.SetRight( nRightSpace > 0 ? nRightSpace : 0 );
rFlyItemSet.Put( aLRItem );
if( nLeftSpace )
{
@@ -544,98 +545,172 @@ void SwHTMLParser::InsertEmbed()
/* */
-#if 0
-class SwHTMLApplet_Impl
+void SwHTMLParser::NewObject()
{
- SvAppletObjectRef xApplet; // das aktuelle Applet
- SvCommandList aCommandList; // und die szugehorige Command-List
- SfxItemSet aItemSet;
- String sAlt;
+#ifdef SOLAR_JAVA
+ String aClassID, aName, aStandBy, aId, aStyle, aClass;
+ Size aSize( USHRT_MAX, USHRT_MAX );
+ Size aSpace( 0, 0 );
+ SwVertOrient eVertOri = VERT_TOP;
+ SwHoriOrient eHoriOri = HORI_NONE;
-public:
+ sal_Bool bPrcWidth = sal_False, bPrcHeight = sal_False,
+ bDeclare = sal_False;
+ // Eine neue Command-List anlegen
+ if( pAppletImpl )
+ delete pAppletImpl;
+ pAppletImpl = new SwApplet_Impl( pDoc->GetAttrPool(),
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
- SwHTMLApplet_Impl( SfxItemPool& rPool, USHORT nWhich1, USHORT nWhich2 ) :
- aItemSet( rPool, nWhich1, nWhich2 )
+ const HTMLOptions *pOptions = GetOptions();
+ for( USHORT i = pOptions->Count(); i; )
{
- }
+ const HTMLOption *pOption = (*pOptions)[--i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ID:
+ aId = pOption->GetString();
+ break;
+ case HTML_O_STYLE:
+ aStyle = pOption->GetString();
+ break;
+ case HTML_O_CLASS:
+ aClass = pOption->GetString();
+ break;
+ case HTML_O_DECLARE:
+ bDeclare = sal_True;
+ break;
+ case HTML_O_CLASSID:
+ aClassID = pOption->GetString();
+ break;
+ case HTML_O_CODEBASE:
+ break;
+ case HTML_O_DATA:
+ break;
+ case HTML_O_TYPE:
+ break;
+ case HTML_O_CODETYPE:
+ break;
+ case HTML_O_ARCHIVE:
+ case HTML_O_UNKNOWN:
+ break;
+ case HTML_O_STANDBY:
+ aStandBy = pOption->GetString();
+ break;
+ case HTML_O_WIDTH:
+ bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
+ aSize.Width() = (long)pOption->GetNumber();
+ break;
+ case HTML_O_HEIGHT:
+ bPrcHeight = (pOption->GetString().Search('%') != STRING_NOTFOUND);
+ aSize.Height() = (long)pOption->GetNumber();
+ break;
+ case HTML_O_ALIGN:
+ eVertOri = (SwVertOrient)pOption->GetEnum( aHTMLImgVAlignTable, eVertOri );
+ eHoriOri = (SwHoriOrient)pOption->GetEnum( aHTMLImgHAlignTable, eHoriOri );
+ break;
+ case HTML_O_USEMAP:
+ break;
+ case HTML_O_NAME:
+ aName = pOption->GetString();
+ break;
+ case HTML_O_HSPACE:
+ aSpace.Width() = (long)pOption->GetNumber();
+ break;
+ case HTML_O_VSPACE:
+ aSpace.Height() = (long)pOption->GetNumber();
+ break;
+ case HTML_O_BORDER:
+ break;
+
+ case HTML_O_SDONCLICK:
+ case HTML_O_ONCLICK:
+ case HTML_O_SDONMOUSEOVER:
+ case HTML_O_ONMOUSEOVER:
+ case HTML_O_SDONMOUSEOUT:
+ case HTML_O_ONMOUSEOUT:
+ break;
+ }
+ // Es werden alle Parameter auch an das Applet weitergereicht
+ pAppletImpl->AppendParam( pOption->GetTokenString(),
+ pOption->GetString() );
- ~SwHTMLApplet_Impl()
- {
- xApplet.Clear();
}
-#ifndef DEBUG
-inline
-#endif
- void CreateApplet( const String& rCode, const String& rName,
- BOOL bMayScript, const String& rCodeBase,
- const String& rAlt );
+ // Objects that are declared only are not evaluated. Moreover, only
+ // Java applets are supported.
+ sal_Bool bIsApplet = sal_False;;
- void FinishApplet()
+ if( !bDeclare && aClassID.Len() == 42 &&
+ aClassID.EqualsAscii( "clsid:", 0, 6 ) )
{
- xApplet->SetCommandList( aCommandList );
- xApplet->EnableSetModified( TRUE );
- }
+ aClassID.Erase( 0, 6 );
+ SvGlobalName aCID;
+ if( aCID.MakeId( aClassID ) )
+ {
+ SvGlobalName aJavaCID( 0x8AD9C840UL, 0x044EU, 0x11D1U, 0xB3U, 0xE9U,
+ 0x00U, 0x80U, 0x5FU, 0x49U, 0x9DU, 0x93U );
+ bIsApplet = aJavaCID == aCID;
+ }
+ }
- void AppendParam( const String& rName, const String& rValue )
+ if( !bIsApplet )
{
- aCommandList.Append( rName, rValue );
+ delete pAppletImpl;
+ pAppletImpl = 0;
+ return;
}
+ pAppletImpl->SetAltText( aStandBy );
- SvAppletObject* GetApplet() { return &xApplet; }
- SfxItemSet& GetItemSet() { return aItemSet; }
- const String& GetAltText() { return sAlt; }
-};
+ SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
+ SvxCSS1PropertyInfo aPropInfo;
+ if( HasStyleOptions( aStyle, aId, aClass ) )
+ ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
-#ifndef DEBUG
-inline
-#endif
-void SwHTMLApplet_Impl::CreateApplet( const String& rCode, const String& rName,
- BOOL bMayScript, const String& rCodeBase,
- const String& rAlt )
-{
- SvStorageRef pStor = new SvStorage( aEmptyStr, STREAM_STD_READWRITE );
- xApplet = new SvAppletObject();
- xApplet->DoInitNew( pStor );
+ SfxItemSet& rFrmSet = pAppletImpl->GetItemSet();
+ if( !IsNewDoc() )
+ Reader::ResetFrmFmtAttrs( rFrmSet );
- xApplet->EnableSetModified( FALSE );
- xApplet->SetClass( rCode );
- xApplet->SetName( rName );
- xApplet->SetMayScript( bMayScript );
- xApplet->SetDocBase( INetURLObject::GetBaseURL() );
+ // den Anker und die Ausrichtung setzen
+ SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, rFrmSet );
- String sCodeBase;
- if( rCodeBase.Len() )
- {
- INetURLObject aTmpURL;
+ // und noch die Groesse des Rahmens
+ Size aDfltSz( HTML_DFLT_APPLET_WIDTH, HTML_DFLT_APPLET_HEIGHT );
+ SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight, aItemSet, aPropInfo,
+ rFrmSet );
+ SetSpace( aSpace, aItemSet, aPropInfo, rFrmSet );
+#endif
+}
- INetProtocol eProt = aTmpURL.CompareProtocolScheme( rCodeBase );
- if( eProt==INET_PROT_NOT_VALID &&
- rCodeBase.Search( ':' ) != STRING_NOTFOUND )
- {
- // The codebase contains an unknown protocol rather than
- // a relative URL.
- sCodeBase = rCodeBase;
- }
- else
- {
- sCodeBase = INetURLObject::RelToAbs( rCodeBase );
- }
- }
- else
+void SwHTMLParser::EndObject()
+{
+#ifdef SOLAR_JAVA
+ if( !pAppletImpl )
+ return;
+ if( pAppletImpl->CreateApplet() )
{
- INetURLObject aTmpURL( INetURLObject::GetBaseURL() );
- sCodeBase = aTmpURL.GetPartBeforeLastName();
- }
+ pAppletImpl->FinishApplet();
- xApplet->SetCodeBase( sCodeBase );
+ // und in das Dok einfuegen
+ SwFrmFmt* pFlyFmt = pDoc->Insert( *pPam, pAppletImpl->GetApplet(),
+ &pAppletImpl->GetItemSet() );
- sAlt = rAlt;
-}
+ // den alternativen Namen setzen
+ SwNoTxtNode *pNoTxtNd =
+ pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
+ ->GetIndex()+1 ]->GetNoTxtNode();
+ pNoTxtNd->SetAlternateText( pAppletImpl->GetAltText() );
+ // Ggf Frames anlegen und auto-geb. Rahmen registrieren
+ RegisterFlyFrm( pFlyFmt );
+
+ delete pAppletImpl;
+ pAppletImpl = 0;
+ }
#endif
+}
void SwHTMLParser::InsertApplet()
{
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 985c23f1d3ff..58cf1a016d33 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: swhtml.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: mib $ $Date: 2002-07-01 12:18:05 $
+ * last change: $Author: mib $ $Date: 2002-08-01 13:28:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -288,6 +288,9 @@
#ifndef _BREAKIT_HXX
#include <breakit.hxx>
#endif
+#ifndef _SW_APPLET_IMPL_HXX
+#include <SwAppletImpl.hxx>
+#endif
#ifndef _STATSTR_HRC
#include <statstr.hrc> // ResId fuer Statusleiste
@@ -806,7 +809,12 @@ void __EXPORT SwHTMLParser::Continue( int nToken )
}
if( pAppletImpl )
- EndApplet();
+ {
+ if( pAppletImpl->GetApplet() )
+ EndApplet();
+ else
+ EndObject();
+ }
// ggf. ein noch vorhandes LF hinter dem letzen Absatz entfernen
if( IsNewDoc() )
@@ -1240,6 +1248,10 @@ void __EXPORT SwHTMLParser::NextToken( int nToken )
bCallNextToken = FALSE;
EndApplet();
break;
+ case HTML_OBJECT_OFF:
+ bCallNextToken = FALSE;
+ EndObject();
+ break;
case HTML_PARAM:
InsertParam();
@@ -1491,6 +1503,13 @@ void __EXPORT SwHTMLParser::NextToken( int nToken )
}
break;
+ case HTML_OBJECT_ON:
+#ifdef SOLAR_JAVA
+ NewObject();
+ bCallNextToken = pAppletImpl!=0 && pTable!=0;
+#endif
+ break;
+
case HTML_APPLET_ON:
#ifdef SOLAR_JAVA
InsertApplet();
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index d601963613cc..9abd8d8eb95e 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: swhtml.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: mib $ $Date: 2001-10-24 14:16:17 $
+ * last change: $Author: mib $ $Date: 2002-08-01 13:28:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -779,6 +779,8 @@ private:
void InsertImage(); // htmlgrin.cxx
void InsertEmbed(); // htmlplug.cxx
+ void NewObject(); // htmlplug.cxx
+ void EndObject(); // CommandLine mit Applet verkn. (htmlplug.cxx)
void InsertApplet(); // htmlplug.cxx
void EndApplet(); // CommandLine mit Applet verkn. (htmlplug.cxx)
void InsertParam(); // htmlplug.cxx