From 4aa793a5588aadcea0160004631b7025d401b9c6 Mon Sep 17 00:00:00 2001 From: Martin Gallwey Date: Fri, 23 Feb 2001 13:33:30 +0000 Subject: Added export of floating-frames, plugins and applets --- sw/source/filter/xml/xmltexte.cxx | 189 +++++++++++++++++++++++++++++++++++++- sw/source/filter/xml/xmltexte.hxx | 9 +- 2 files changed, 194 insertions(+), 4 deletions(-) (limited to 'sw/source/filter/xml') diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx index 714b2b70bdc7..0f2a1a6e439f 100644 --- a/sw/source/filter/xml/xmltexte.cxx +++ b/sw/source/filter/xml/xmltexte.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmltexte.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: kz $ $Date: 2001-02-13 16:41:04 $ + * last change: $Author: mtg $ $Date: 2001-02-23 14:33:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -79,6 +79,7 @@ #include #endif +#include #ifndef _DOC_HXX //autogen wg. SwDoc #include #endif @@ -102,6 +103,32 @@ #include "xmltexte.hxx" #endif +#ifndef _APPLET_HXX //autogen +#include +#endif +#ifndef _PLUGIN_HXX //autogen +#include +#endif + +#ifndef _FRAMEOBJ_HXX //autogen +#include +#endif + +#ifndef _URLOBJ_HXX +#include +#endif + +#ifndef _SW_APPLET_IMPL_HXX +#include +#endif + +#define _SVSTDARR_ULONGS +#include + +#ifndef _SFX_FRMDESCRHXX +#include +#endif + using namespace ::rtl; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::style; @@ -259,3 +286,161 @@ void SwXMLTextParagraphExport::getTextEmbeddedObjectProperties( rClassId = aClassName.GetHexName(); } } + +void SwXMLTextParagraphExport::_exportTextEmbedded( + const Reference < XPropertySet > & rPropSet, + const Reference < XPropertySetInfo > & rPropSetInfo ) +{ + SwOLENode *pOLENd = GetNoTxtNode( rPropSet )->GetOLENode(); + SwOLEObj& rOLEObj = pOLENd->GetOLEObj(); + SvPlugInObjectRef pPlugin ( rOLEObj.GetOleRef() ); + SvAppletObjectRef pApplet ( rOLEObj.GetOleRef() ); + SfxFrameObjectRef pFrame ( rOLEObj.GetOleRef() ); + + // First the stuff common to each of Applet/Plugin/Floating Frame + OUString sStyle; + Any aAny; + if( rPropSetInfo->hasPropertyByName( sFrameStyleName ) ) + { + aAny = rPropSet->getPropertyValue( sFrameStyleName ); + aAny >>= sStyle; + } + + OUString sAutoStyle( sStyle ); + sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, sStyle ); + if( sAutoStyle.getLength() ) + GetExport().AddAttribute( XML_NAMESPACE_DRAW, sXML_style_name, + sAutoStyle ); + addTextFrameAttributes( rPropSet, sal_False ); + + if ( pApplet.Is() ) + { + // It's an applet! + + const XubString & rURL = pApplet->GetCodeBase(); + if (rURL.Len() ) + { + String sCodeBase( INetURLObject::AbsToRel(rURL, + INetURLObject::WAS_ENCODED, + INetURLObject::DECODE_UNAMBIGUOUS) ); + if( sCodeBase.Len() ) + { + GetExport().AddAttribute( XML_NAMESPACE_XLINK, sXML_href, sCodeBase ); + GetExport().AddAttributeASCII( XML_NAMESPACE_XLINK, sXML_type, sXML_simple ); + GetExport().AddAttributeASCII( XML_NAMESPACE_XLINK, sXML_show, sXML_embed ); + GetExport().AddAttributeASCII( XML_NAMESPACE_XLINK, sXML_actuate, sXML_onLoad ); + } + } + const String &rName = pApplet->GetName(); + if (rName.Len()) + GetExport().AddAttribute( XML_NAMESPACE_OFFICE, sXML_name, rName ); + + GetExport().AddAttribute( XML_NAMESPACE_DRAW, sXML_code, pApplet->GetClass() ); + + const SvCommandList& rCommands = pApplet->GetCommandList(); + SvULongs aParams; + + ULONG i = rCommands.Count(); + while ( i > 0 ) + { + const SvCommand& rCommand = rCommands [ --i ]; + const String &rName = rCommand.GetCommand(); + USHORT nType = SwApplet_Impl::GetOptionType( rName, TRUE ); + if ( nType == SWHTML_OPTTYPE_TAG) + GetExport().AddAttribute( XML_NAMESPACE_DRAW, rName, rCommand.GetArgument()); + else if (SWHTML_OPTTYPE_PARAM == nType ) + aParams.Insert( i, aParams.Count() ); + } + + if ( pApplet->IsMayScript ( ) ) + GetExport().AddAttributeASCII( XML_NAMESPACE_DRAW, sXML_may_script, sXML_true ); + else + GetExport().AddAttributeASCII( XML_NAMESPACE_DRAW, sXML_may_script, sXML_false ); + + SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW, sXML_applet, sal_False, sal_True ); + + USHORT ii = aParams.Count(); + while ( ii > 0 ) + { + const SvCommand& rCommand = rCommands [ aParams [ --ii] ]; + + GetExport().AddAttribute( XML_NAMESPACE_OFFICE, sXML_name, rCommand.GetCommand() ); + GetExport().AddAttribute( XML_NAMESPACE_DRAW, sXML_value, rCommand.GetArgument() ); + SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW, sXML_param, sal_False, sal_True ); + } + exportEvents( rPropSet ); + //exportAlternativeText( rPropSet, rPropSetInfo ); + //if (pOLENd->GetAlternateText()) + { + SvXMLElementExport aDescription (GetExport(), XML_NAMESPACE_SVG, sXML_desc, sal_True, sal_False ); + GetExport().GetDocHandler()->characters( pOLENd->GetAlternateText()); + } + exportContour( rPropSet, rPropSetInfo ); + } + else if ( pPlugin.Is() ) + { + // It's a plugin! + String sURL( INetURLObject::AbsToRel(pPlugin->GetURL()->GetMainURL(), + INetURLObject::WAS_ENCODED, + INetURLObject::DECODE_UNAMBIGUOUS) ); + if (sURL.Len()) + { + GetExport().AddAttribute ( XML_NAMESPACE_XLINK, sXML_href, sURL ); + GetExport().AddAttributeASCII( XML_NAMESPACE_XLINK, sXML_type, sXML_simple ); + GetExport().AddAttributeASCII( XML_NAMESPACE_XLINK, sXML_show, sXML_embed ); + GetExport().AddAttributeASCII( XML_NAMESPACE_XLINK, sXML_actuate, sXML_onLoad ); + } + + const String &rType = pPlugin->GetMimeType(); + if (rType.Len()) + GetExport().AddAttribute( XML_NAMESPACE_DRAW, sXML_mime_type, rType ); + + SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW, sXML_plugin, sal_False, sal_True ); + + const SvCommandList& rCommands = pPlugin->GetCommandList(); + ULONG nCommands = rCommands.Count(); + for ( ULONG i = 0; i < nCommands; i++) + { + const SvCommand& rCommand = rCommands [ i ]; + const String& rName = rCommand.GetCommand(); + if (SwApplet_Impl::GetOptionType( rName, FALSE ) == SWHTML_OPTTYPE_TAG ) + { + GetExport().AddAttribute( XML_NAMESPACE_OFFICE, sXML_name, rCommand.GetCommand() ); + GetExport().AddAttribute( XML_NAMESPACE_DRAW, sXML_value, rCommand.GetArgument() ); + SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW, sXML_param, sal_False, sal_True ); + } + } + + exportEvents( rPropSet ); + exportAlternativeText( rPropSet, rPropSetInfo ); + exportContour( rPropSet, rPropSetInfo ); + } + else if ( pFrame.Is() ) + { + // It's a floating frame! + const SfxFrameDescriptor *pDescriptor = pFrame->GetFrameDescriptor(); + + String sURL( INetURLObject::AbsToRel(pDescriptor->GetURL().GetMainURL(), + INetURLObject::WAS_ENCODED, + INetURLObject::DECODE_UNAMBIGUOUS) ); + if (sURL.Len()) + { + GetExport().AddAttribute ( XML_NAMESPACE_XLINK, sXML_href, sURL ); + GetExport().AddAttributeASCII( XML_NAMESPACE_XLINK, sXML_type, sXML_simple ); + GetExport().AddAttributeASCII( XML_NAMESPACE_XLINK, sXML_show, sXML_embed ); + GetExport().AddAttributeASCII( XML_NAMESPACE_XLINK, sXML_actuate, sXML_onLoad ); + } + const String&rName = pDescriptor->GetName(); + if (rName.Len()) + GetExport().AddAttribute( XML_NAMESPACE_OFFICE, sXML_name, rName ); + + SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW, sXML_floating_frame, sal_False, sal_True ); + exportEvents( rPropSet ); + exportAlternativeText( rPropSet, rPropSetInfo ); + exportContour( rPropSet, rPropSetInfo ); + } + else + { + // Just what the hell are you, some kinda _freak_ ?! + } +} diff --git a/sw/source/filter/xml/xmltexte.hxx b/sw/source/filter/xml/xmltexte.hxx index ba1f96b42b19..3f1b3e735b0d 100644 --- a/sw/source/filter/xml/xmltexte.hxx +++ b/sw/source/filter/xml/xmltexte.hxx @@ -2,9 +2,9 @@ * * $RCSfile: xmltexte.hxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: mib $ $Date: 2001-01-26 11:22:48 $ + * last change: $Author: mtg $ $Date: 2001-02-23 14:33:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -88,6 +88,11 @@ protected: ::com::sun::star::style::XStyle > & rStyle ); virtual void exportTextAutoStyles(); + virtual void _exportTextEmbedded( + const ::com::sun::star::uno::Reference < + ::com::sun::star::beans::XPropertySet > & rPropSet, + const ::com::sun::star::uno::Reference < + ::com::sun::star::beans::XPropertySetInfo > & rPropSetInfo ); virtual void exportTable( const ::com::sun::star::uno::Reference < -- cgit v1.2.3