Kaydet (Commit) 50b328f5 authored tarafından Daniel Vogelheim's avatar Daniel Vogelheim

- changed: autotext event import/export is now based on an XNameReplace

üst 35667520
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: XMLAutoTextContainerEventImport.cxx,v $ * $RCSfile: XMLAutoTextContainerEventImport.cxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: dvo $ $Date: 2001-02-06 16:34:29 $ * last change: $Author: dvo $ $Date: 2001-03-09 14:53:43 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -63,10 +63,6 @@ ...@@ -63,10 +63,6 @@
#include "XMLAutoTextContainerEventImport.hxx" #include "XMLAutoTextContainerEventImport.hxx"
#endif #endif
#ifndef _XMLOFF_XMLAUTOTEXTGROUPEVENTIMPORT_HXX
#include "XMLAutoTextGroupEventImport.hxx"
#endif
#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_ #ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
#include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Reference.hxx>
#endif #endif
...@@ -75,8 +71,8 @@ ...@@ -75,8 +71,8 @@
#include <com/sun/star/xml/sax/XAttributeList.hpp> #include <com/sun/star/xml/sax/XAttributeList.hpp>
#endif #endif
#ifndef _COM_SUN_STAR_TEXT_XAUTOTEXTCONTAINER_HPP_ #ifndef _COM_SUN_STAR_CONTAINER_XNAMEREPLACE_HPP_
#include <com/sun/star/text/XAutoTextContainer.hpp> #include <com/sun/star/container/XNameReplace.hpp>
#endif #endif
#ifndef _XMLOFF_XMLIMP_HXX #ifndef _XMLOFF_XMLIMP_HXX
...@@ -95,6 +91,10 @@ ...@@ -95,6 +91,10 @@
#include "xmlkywd.hxx" #include "xmlkywd.hxx"
#endif #endif
#ifndef _XMLOFF_XMLEVENTSIMPORTCONTEXT_HXX
#include "XMLEventsImportContext.hxx"
#endif
using namespace ::com::sun::star; using namespace ::com::sun::star;
...@@ -102,7 +102,7 @@ using ::rtl::OUString; ...@@ -102,7 +102,7 @@ using ::rtl::OUString;
using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Reference;
using ::com::sun::star::xml::sax::XAttributeList; using ::com::sun::star::xml::sax::XAttributeList;
using ::com::sun::star::text::XAutoTextContainer; using ::com::sun::star::container::XNameReplace;
...@@ -113,9 +113,9 @@ XMLAutoTextContainerEventImport::XMLAutoTextContainerEventImport( ...@@ -113,9 +113,9 @@ XMLAutoTextContainerEventImport::XMLAutoTextContainerEventImport(
SvXMLImport& rImport, SvXMLImport& rImport,
USHORT nPrfx, USHORT nPrfx,
const OUString& rLName, const OUString& rLName,
const Reference<XAutoTextContainer > & rContnr ) : const Reference<XNameReplace> & rEvnts ) :
SvXMLImportContext(rImport, nPrfx, rLName), SvXMLImportContext(rImport, nPrfx, rLName),
rContainer(rContnr) rEvents(rEvnts)
{ {
} }
...@@ -128,12 +128,12 @@ SvXMLImportContext* XMLAutoTextContainerEventImport::CreateChildContext( ...@@ -128,12 +128,12 @@ SvXMLImportContext* XMLAutoTextContainerEventImport::CreateChildContext(
const OUString& rLocalName, const OUString& rLocalName,
const Reference<XAttributeList> & xAttrList ) const Reference<XAttributeList> & xAttrList )
{ {
if ((XML_NAMESPACE_TEXT == nPrefix) && if ((XML_NAMESPACE_OFFICE == nPrefix) &&
rLocalName.equalsAsciiL(sXML_auto_text_group, rLocalName.equalsAsciiL(sXML_events,
sizeof(sXML_auto_text_group)-1)) sizeof(sXML_events)-1))
{ {
return new XMLAutoTextGroupEventImport(GetImport(), nPrefix, return new XMLEventsImportContext(GetImport(), nPrefix, rLocalName,
rLocalName, rContainer); rEvents);
} }
else else
return new SvXMLImportContext(GetImport(), nPrefix, rLocalName); return new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: XMLAutoTextContainerEventImport.hxx,v $ * $RCSfile: XMLAutoTextContainerEventImport.hxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: dvo $ $Date: 2001-02-06 16:34:29 $ * last change: $Author: dvo $ $Date: 2001-03-09 14:53:43 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -73,8 +73,7 @@ ...@@ -73,8 +73,7 @@
namespace rtl { class OUString; } namespace rtl { class OUString; }
namespace com { namespace sun { namespace star { namespace com { namespace sun { namespace star {
namespace text { class XAutoTextContainer; } namespace container { class XNameReplace; }
namespace text { class XAutoTextGroup; }
namespace xml { namespace sax { class XAttributeList; } } namespace xml { namespace sax { class XAttributeList; } }
} } } } } }
...@@ -87,7 +86,7 @@ class XMLAutoTextContainerEventImport : public SvXMLImportContext ...@@ -87,7 +86,7 @@ class XMLAutoTextContainerEventImport : public SvXMLImportContext
{ {
/// the parent auto text container /// the parent auto text container
const ::com::sun::star::uno::Reference< const ::com::sun::star::uno::Reference<
::com::sun::star::text::XAutoTextContainer> & rContainer; ::com::sun::star::container::XNameReplace> & rEvents;
public: public:
...@@ -98,7 +97,7 @@ public: ...@@ -98,7 +97,7 @@ public:
USHORT nPrfx, USHORT nPrfx,
const ::rtl::OUString& rLName, const ::rtl::OUString& rLName,
const ::com::sun::star::uno::Reference< const ::com::sun::star::uno::Reference<
::com::sun::star::text::XAutoTextContainer > & rContainer ); ::com::sun::star::container::XNameReplace > & rEvents );
~XMLAutoTextContainerEventImport(); ~XMLAutoTextContainerEventImport();
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: XMLAutoTextEventExport.hxx,v $ * $RCSfile: XMLAutoTextEventExport.hxx,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: dvo $ $Date: 2001-02-13 16:55:00 $ * last change: $Author: dvo $ $Date: 2001-03-09 14:53:43 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -71,11 +71,9 @@ ...@@ -71,11 +71,9 @@
namespace rtl { class OUString; } namespace rtl { class OUString; }
namespace com { namespace sun { namespace star { namespace com { namespace sun { namespace star {
namespace container { class XNameAccess; }
namespace frame { class XModel; } namespace frame { class XModel; }
namespace lang { class XMultiServiceFactory; } namespace lang { class XMultiServiceFactory; }
namespace text { class XAutoTextContainer; }
namespace text { class XAutoTextGroup; }
namespace text { class XAutoTextEntry; }
namespace uno { template<class X> class Reference; } namespace uno { template<class X> class Reference; }
namespace uno { template<class X> class Sequence; } namespace uno { template<class X> class Sequence; }
namespace uno { class XInterface; } namespace uno { class XInterface; }
...@@ -84,20 +82,24 @@ namespace com { namespace sun { namespace star { ...@@ -84,20 +82,24 @@ namespace com { namespace sun { namespace star {
} } } } } }
/**
* Component for the export of events attached to autotext blocks.
* Via the XInitialization interface it expects up to two strings, the
* first giving the file name (URL) of the autotext group, and the second
* identifying the autotext. If one of the strings is not given, it
* will export the whole group / all groups.
*/
class XMLAutoTextEventExport : public SvXMLExport class XMLAutoTextEventExport : public SvXMLExport
{ {
::std::set< ::rtl::OUString > * eventCount; ::com::sun::star::uno::Reference<
::com::sun::star::container::XNameAccess> xEvents;
/// names of groups to be exported; export all group if empty. const ::rtl::OUString sEventType;
::com::sun::star::uno::Sequence< ::rtl::OUString> & rGroupNames; const ::rtl::OUString sNone;
// generate a combined name for sake of counting names
::rtl::OUString combinedName(
const ::rtl::OUString& rGroupName,
const ::rtl::OUString& rEntryName);
public: public:
XMLAutoTextEventExport(); XMLAutoTextEventExport();
XMLAutoTextEventExport( XMLAutoTextEventExport(
...@@ -105,51 +107,36 @@ public: ...@@ -105,51 +107,36 @@ public:
const ::com::sun::star::uno::Reference< const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XDocumentHandler > & rHandler, ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
const ::com::sun::star::uno::Reference< const ::com::sun::star::uno::Reference<
::com::sun::star::frame::XModel > & rModel); ::com::sun::star::frame::XModel > & rModel,
const ::com::sun::star::uno::Reference<
::com::sun::star::container::XNameAccess > & rEvents);
~XMLAutoTextEventExport(); ~XMLAutoTextEventExport();
// XInitialization
virtual void SAL_CALL initialize(
const ::com::sun::star::uno::Sequence<
::com::sun::star::uno::Any> & rArguments )
throw(
::com::sun::star::uno::Exception,
::com::sun::star::uno::RuntimeException);
protected: protected:
// export the events off all autotexts
/// export the events off all autotexts
virtual sal_uInt32 exportDoc( virtual sal_uInt32 exportDoc(
const sal_Char *pClass = NULL ); const sal_Char *pClass = NULL );
void exportAutoTextContainer(
const sal_Char* pClass,
::com::sun::star::uno::Reference<
::com::sun::star::text::XAutoTextContainer> & rAutoTextContainer,
::com::sun::star::uno::Sequence< ::rtl::OUString> & rGroupNames);
void exportAutoTextGroup(
::rtl::OUString& rName,
::com::sun::star::uno::Reference<
::com::sun::star::text::XAutoTextGroup> & rGroup);
void exportAutoTextEntry(
::rtl::OUString& rGroupName,
::rtl::OUString& rName,
::com::sun::star::uno::Reference<
::com::sun::star::text::XAutoTextEntry> & rEntry);
/// count the number of events (to be used before hasXXX() methods)
void countEvents(
::com::sun::star::uno::Reference<
::com::sun::star::text::XAutoTextContainer> & rAutoTextContainer,
::com::sun::star::uno::Sequence< ::rtl::OUString> & rGroupNames);
/// does the document have any events ? /// does the document have any events ?
sal_Bool hasDocumentEvents(); sal_Bool hasEvents();
/// does the group have any events ? /// export the events element
sal_Bool hasGroupEvents( void exportEvents();
const ::rtl::OUString& rGroupName );
/// does this entry have any events ?
sal_Bool hasEntryEvents(
const ::rtl::OUString& rGroupName,
const ::rtl::OUString& rEntryName );
/// add the namespaces used by events
/// (to be called for the document element)
void addNamespaces();
// methods without content: // methods without content:
...@@ -163,6 +150,8 @@ protected: ...@@ -163,6 +150,8 @@ protected:
virtual void _ExportContent(); virtual void _ExportContent();
}; };
// global functions to support the component // global functions to support the component
::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: XMLAutoTextEventImport.cxx,v $ * $RCSfile: XMLAutoTextEventImport.cxx,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: dvo $ $Date: 2001-02-06 16:34:29 $ * last change: $Author: dvo $ $Date: 2001-03-09 14:53:43 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -71,32 +71,16 @@ ...@@ -71,32 +71,16 @@
#include <com/sun/star/xml/sax/XAttributeList.hpp> #include <com/sun/star/xml/sax/XAttributeList.hpp>
#endif #endif
#ifndef _COM_SUN_STAR_TEXT_XAUTOTEXTCONTAINER_HPP_ #ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSSUPPLIER_HPP_
#include <com/sun/star/text/XAutoTextContainer.hpp> #include <com/sun/star/document/XEventsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_XAUTOTEXTGROUP_HPP_
#include <com/sun/star/text/XAutoTextGroup.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_XAUTOTEXTGROUP_HPP_
#include <com/sun/star/text/XAutoTextGroup.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif #endif
#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_ #ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_
#include <com/sun/star/uno/XInterface.hpp> #include <com/sun/star/uno/XInterface.hpp>
#endif #endif
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_ #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <comphelper/processfactory.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
#ifndef _XMLOFF_XMLAUTOTEXTGROUPEVENTIMPORT_HXX
#include "XMLAutoTextGroupEventImport.hxx"
#endif #endif
#ifndef _XMLOFF_XMLAUTOTEXTCONTAINEREVENTIMPORT_HXX #ifndef _XMLOFF_XMLAUTOTEXTCONTAINEREVENTIMPORT_HXX
...@@ -111,16 +95,23 @@ ...@@ -111,16 +95,23 @@
#include "xmlkywd.hxx" #include "xmlkywd.hxx"
#endif #endif
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
using namespace ::com::sun::star; using namespace ::com::sun::star;
using ::rtl::OUString; using ::rtl::OUString;
using ::comphelper::getProcessServiceFactory; using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Type;
using ::com::sun::star::uno::XInterface; using ::com::sun::star::uno::XInterface;
using ::com::sun::star::uno::RuntimeException;
using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::Exception;
using ::com::sun::star::xml::sax::XAttributeList; using ::com::sun::star::xml::sax::XAttributeList;
using ::com::sun::star::text::XAutoTextContainer; using ::com::sun::star::document::XEventsSupplier;
using ::com::sun::star::container::XNameReplace;
using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::lang::XMultiServiceFactory;
const sal_Char sAPI_AutoText[] = "com.sun.star.text.AutoTextContainer"; const sal_Char sAPI_AutoText[] = "com.sun.star.text.AutoTextContainer";
...@@ -129,36 +120,55 @@ const sal_Char sAPI_AutoText[] = "com.sun.star.text.AutoTextContainer"; ...@@ -129,36 +120,55 @@ const sal_Char sAPI_AutoText[] = "com.sun.star.text.AutoTextContainer";
XMLAutoTextEventImport::XMLAutoTextEventImport() throw() : XMLAutoTextEventImport::XMLAutoTextEventImport() throw() :
SvXMLImport() SvXMLImport()
{ {
// instantiate AutoTextContainer via factory
Reference<XMultiServiceFactory> xFactory = getProcessServiceFactory();
if (xFactory.is())
{
OUString sService(RTL_CONSTASCII_USTRINGPARAM(sAPI_AutoText));
Reference<XAutoTextContainer> xContainer(
xFactory->createInstance(sService), uno::UNO_QUERY);
xAutoTextContainer = xContainer;
}
} }
XMLAutoTextEventImport::~XMLAutoTextEventImport() XMLAutoTextEventImport::~XMLAutoTextEventImport()
{ {
} }
void XMLAutoTextEventImport::initialize(
const Sequence<Any> & rArguments )
throw(Exception, RuntimeException)
{
// The events may come as either an XNameReplace or XEventsSupplier.
const sal_Int32 nLength = rArguments.getLength();
for( sal_Int32 i = 0; i < nLength; i++ )
{
const Type& rType = rArguments[i].getValueType();
if ( rType == ::getCppuType( (Reference<XEventsSupplier>*)NULL ) )
{
Reference<XEventsSupplier> xSupplier;
rArguments[i] >>= xSupplier;
DBG_ASSERT(xSupplier.is(), "need XEventsSupplier or XNameReplace");
xEvents = xSupplier->getEvents();
}
else if (rType == ::getCppuType( (Reference<XNameReplace>*)NULL ) )
{
rArguments[i] >>= xEvents;
DBG_ASSERT(xEvents.is(), "need XEventsSupplier or XNameReplace");
}
}
// call parent
SvXMLImport::initialize(rArguments);
}
SvXMLImportContext* XMLAutoTextEventImport::CreateContext( SvXMLImportContext* XMLAutoTextEventImport::CreateContext(
sal_uInt16 nPrefix, sal_uInt16 nPrefix,
const OUString& rLocalName, const OUString& rLocalName,
const Reference<XAttributeList > & xAttrList ) const Reference<XAttributeList > & xAttrList )
{ {
if ( xAutoTextContainer.is() && if ( xEvents.is() &&
(XML_NAMESPACE_TEXT == nPrefix) && (XML_NAMESPACE_OFFICE == nPrefix) &&
rLocalName.equalsAsciiL(sXML_auto_text_events, rLocalName.equalsAsciiL(sXML_auto_text_events,
sizeof(sXML_auto_text_events)-1) ) sizeof(sXML_auto_text_events)-1) )
{ {
return new XMLAutoTextContainerEventImport(*this, nPrefix, rLocalName, return new XMLAutoTextContainerEventImport(
xAutoTextContainer); *this, nPrefix, rLocalName, xEvents);
} }
else else
{ {
...@@ -167,20 +177,19 @@ SvXMLImportContext* XMLAutoTextEventImport::CreateContext( ...@@ -167,20 +177,19 @@ SvXMLImportContext* XMLAutoTextEventImport::CreateContext(
} }
Sequence< OUString > SAL_CALL Sequence< OUString > SAL_CALL
XMLAutoTextEventImport_getSupportedServiceNames() XMLAutoTextEventImport_getSupportedServiceNames()
throw() throw()
{ {
const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( Sequence< OUString > aSeq( 1 );
"com.sun.star.office.sax.importer.AutoTextEventReader" ) ); aSeq[0] = XMLAutoTextEventImport_getImplementationName();
const Sequence< OUString > aSeq( &aServiceName, 1 );
return aSeq; return aSeq;
} }
OUString SAL_CALL XMLAutoTextEventImport_getImplementationName() throw() OUString SAL_CALL XMLAutoTextEventImport_getImplementationName() throw()
{ {
return OUString( RTL_CONSTASCII_USTRINGPARAM( "XMLAutoTextEventImport" ) ); return OUString( RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.Writer.XMLAutotextEventsImporter" ) );
} }
Reference< XInterface > SAL_CALL XMLAutoTextEventImport_createInstance( Reference< XInterface > SAL_CALL XMLAutoTextEventImport_createInstance(
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: XMLAutoTextEventImport.hxx,v $ * $RCSfile: XMLAutoTextEventImport.hxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: dvo $ $Date: 2001-02-06 11:51:27 $ * last change: $Author: dvo $ $Date: 2001-03-09 14:53:43 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -89,13 +89,20 @@ namespace com { namespace sun { namespace star { ...@@ -89,13 +89,20 @@ namespace com { namespace sun { namespace star {
class XMLAutoTextEventImport : public SvXMLImport class XMLAutoTextEventImport : public SvXMLImport
{ {
::com::sun::star::uno::Reference< ::com::sun::star::uno::Reference<
::com::sun::star::text::XAutoTextContainer> xAutoTextContainer; ::com::sun::star::container::XNameReplace> xEvents;
public: public:
XMLAutoTextEventImport() throw(); XMLAutoTextEventImport() throw();
~XMLAutoTextEventImport(); ~XMLAutoTextEventImport();
// XInitialization
virtual void SAL_CALL initialize(
const ::com::sun::star::uno::Sequence<
::com::sun::star::uno::Any> & rArguments )
throw(
::com::sun::star::uno::Exception,
::com::sun::star::uno::RuntimeException);
protected: protected:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment