summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/Library_sw.mk1
-rw-r--r--sw/source/core/inc/dumpfilter.hxx87
-rw-r--r--sw/source/core/layout/dumpfilter.cxx208
-rw-r--r--sw/source/core/text/xmldump.cxx10
-rw-r--r--sw/source/ui/uno/unofreg.cxx17
-rw-r--r--sw/util/sw.component7
6 files changed, 317 insertions, 13 deletions
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 1ccedbd1ee32..6ebc1d5371eb 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -282,6 +282,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/core/layout/calcmove \
sw/source/core/layout/colfrm \
sw/source/core/layout/dbg_lay \
+ sw/source/core/layout/dumpfilter \
sw/source/core/layout/findfrm \
sw/source/core/layout/flowfrm \
sw/source/core/layout/fly \
diff --git a/sw/source/core/inc/dumpfilter.hxx b/sw/source/core/inc/dumpfilter.hxx
new file mode 100644
index 000000000000..b2472c440083
--- /dev/null
+++ b/sw/source/core/inc/dumpfilter.hxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Cedric Bosdonnat <cbosdonnat@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef _LAYOUTDUMP_HXX
+#define _LAYOUTDUMP_HXX
+
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase4.hxx>
+
+namespace sw {
+
+ /** Implementation of UNO export service to dump the layout of the
+ document as XML. This filter should be mostly be used for testing
+ purpose.
+ */
+ class LayoutDumpFilter : public cppu::WeakImplHelper4
+ <
+ com::sun::star::document::XFilter,
+ com::sun::star::document::XExporter,
+ com::sun::star::lang::XInitialization,
+ com::sun::star::lang::XServiceInfo
+ >
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xSrcDoc;
+
+
+ public:
+ LayoutDumpFilter();
+ virtual ~LayoutDumpFilter();
+
+ // XFilter
+ virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL cancel( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XExporter
+ virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+ throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ };
+} // Namespace sw
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/dumpfilter.cxx b/sw/source/core/layout/dumpfilter.cxx
new file mode 100644
index 000000000000..391da67f106c
--- /dev/null
+++ b/sw/source/core/layout/dumpfilter.cxx
@@ -0,0 +1,208 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Cedric Bosdonnat <cbosdonnat@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "dumpfilter.hxx"
+
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <rootfrm.hxx>
+#include <unotxdoc.hxx>
+#include <unobaseclass.hxx>
+#include <cppuhelper/weak.hxx>
+#include <vcl/svapp.hxx>
+
+#include <comphelper/mediadescriptor.hxx>
+
+using namespace ::com::sun::star;
+
+::rtl::OUString SAL_CALL LayoutDumpFilter_getImplementationName() throw( uno::RuntimeException )
+{
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Writer.LayoutDump" ) );
+}
+
+uno::Sequence< rtl::OUString > SAL_CALL LayoutDumpFilter_getSupportedServiceNames() throw( uno::RuntimeException )
+{
+ uno::Sequence< rtl::OUString > aSeq( 1 );
+ aSeq[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.ExportFilter" ) );
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL LayoutDumpFilter_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & )
+{
+ return static_cast< cppu::OWeakObject* >( new sw::LayoutDumpFilter( ) );
+}
+
+namespace
+{
+ int writeCallback( void* pContext, const char* sBuffer, int nLen )
+ {
+ int written = nLen;
+
+ // Actually write bytes to XOutputSream
+ try
+ {
+ uno::XInterface* pObj = ( uno::XInterface* )pContext;
+ uno::Reference< io::XOutputStream > xOut( pObj, uno::UNO_QUERY_THROW );
+
+ // Don't output the terminating \0 to the xml or the file will be invalid
+ uno::Sequence< sal_Int8 > seq( nLen );
+ strncpy( ( char * ) seq.getArray() , sBuffer, nLen );
+ xOut->writeBytes( seq );
+ }
+ catch ( uno::Exception )
+ {
+ written = -1;
+ }
+
+ return written;
+ }
+
+ int closeCallback( void* pContext )
+ {
+ int result = 0;
+ try
+ {
+ uno::XInterface* pObj = ( uno::XInterface* )pContext;
+ uno::Reference< io::XOutputStream > xOut( pObj, uno::UNO_QUERY_THROW );
+ xOut->closeOutput( );
+ }
+ catch ( uno::Exception )
+ {
+ result = -1;
+ }
+ return result;
+ }
+}
+
+namespace sw
+{
+
+ LayoutDumpFilter::LayoutDumpFilter( )
+ {
+ }
+
+ LayoutDumpFilter::~LayoutDumpFilter( )
+ {
+ }
+
+ // XFilter
+ sal_Bool LayoutDumpFilter::filter( const uno::Sequence< beans::PropertyValue >& aDescriptor )
+ throw (uno::RuntimeException)
+ {
+ sal_Bool bRet = sal_False;
+
+ comphelper::MediaDescriptor aMediaDesc = aDescriptor;
+
+ // Get the output stream
+ uno::Reference< io::XOutputStream > xOut = aMediaDesc.getUnpackedValueOrDefault(
+ comphelper::MediaDescriptor::PROP_OUTPUTSTREAM(),
+ uno::Reference< io::XOutputStream >() );
+
+ // Actually get the SwRootFrm to call dumpAsXml
+ uno::Reference< lang::XUnoTunnel > xDocTunnel( m_xSrcDoc, uno::UNO_QUERY );
+ SwXTextDocument* pXDoc = UnoTunnelGetImplementation< SwXTextDocument >( xDocTunnel );
+ if ( pXDoc )
+ {
+ SwRootFrm* pLayout = pXDoc->GetDocShell()->GetWrtShell()->GetLayout();
+
+ // Get sure that the whole layout is processed: set a visible area
+ // even though there isn't any need of it
+ pXDoc->GetDocShell()->GetWrtShell()->StartAction();
+ Rectangle aRect( 0, 0, 26000, 21000 );
+ pXDoc->GetDocShell()->SetVisArea( aRect );
+ pLayout->InvalidateAllCntnt( );
+ pXDoc->GetDocShell()->GetWrtShell()->EndAction();
+
+ // Dump the layout XML into the XOutputStream
+ xmlOutputBufferPtr outBuffer = xmlOutputBufferCreateIO(
+ writeCallback, closeCallback, ( void* ) xOut.get(), NULL );
+
+ xmlTextWriterPtr writer = xmlNewTextWriter( outBuffer );
+ xmlTextWriterStartDocument( writer, NULL, NULL, NULL );
+
+ // TODO This doesn't export the whole XML file, whereas dumpAsXML() does it nicely
+ pLayout->dumpAsXml( writer );
+
+ xmlTextWriterEndDocument( writer );
+ xmlFreeTextWriter( writer );
+
+ bRet = sal_True;
+ }
+
+ return bRet;
+ }
+
+ void LayoutDumpFilter::cancel( ) throw (uno::RuntimeException)
+ {
+ }
+
+ // XExporter
+ void LayoutDumpFilter::setSourceDocument( const uno::Reference< lang::XComponent >& xDoc )
+ throw (lang::IllegalArgumentException, uno::RuntimeException)
+ {
+ m_xSrcDoc = xDoc;
+ }
+
+ // XInitialization
+ void LayoutDumpFilter::initialize( const uno::Sequence< uno::Any >& )
+ throw (uno::Exception, uno::RuntimeException)
+ {
+ }
+
+ // XServiceInfo
+ ::rtl::OUString LayoutDumpFilter::getImplementationName( )
+ throw (uno::RuntimeException)
+ {
+ return LayoutDumpFilter_getImplementationName();
+ }
+
+ sal_Bool LayoutDumpFilter::supportsService( const ::rtl::OUString& rServiceName )
+ throw (uno::RuntimeException)
+ {
+ uno::Sequence< rtl::OUString > seqServiceNames = getSupportedServiceNames();
+ const rtl::OUString* pArray = seqServiceNames.getConstArray();
+ for ( sal_Int32 nCounter=0; nCounter < seqServiceNames.getLength(); nCounter++ )
+ {
+ if ( pArray[nCounter] == rServiceName )
+ {
+ return sal_True ;
+ }
+ }
+ return sal_False ;
+ }
+
+ uno::Sequence< ::rtl::OUString > LayoutDumpFilter::getSupportedServiceNames()
+ throw (uno::RuntimeException)
+ {
+ return LayoutDumpFilter_getSupportedServiceNames();
+ }
+
+} // Namespace sw
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index 949ffc485d1c..4152901c6dd6 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -128,21 +128,19 @@ class XmlPortionDumper:public SwPortionHandler
};
-#if OSL_DEBUG_LEVEL > 1
-
namespace
{
xmlTextWriterPtr lcl_createDefaultWriter()
{
xmlTextWriterPtr writer = xmlNewTextWriterFilename( "layout.xml", 0 );
- xmlTextWriterStartDocument(writer, NULL, NULL, NULL);
+ xmlTextWriterStartDocument( writer, NULL, NULL, NULL );
return writer;
}
void lcl_freeWriter( xmlTextWriterPtr writer )
{
- xmlTextWriterEndDocument(writer);
- xmlFreeTextWriter( writer );
+ xmlTextWriterEndDocument( writer );
+ xmlFreeTextWriter( writer );
}
}
@@ -264,6 +262,4 @@ void SwTxtFrm::dumpAsXmlAttributes( xmlTextWriterPtr writer )
xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "follow" ), "%p", GetFollow() );
}
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/unofreg.cxx b/sw/source/ui/uno/unofreg.cxx
index f63f21e12c6f..ebf6701154ae 100644
--- a/sw/source/ui/uno/unofreg.cxx
+++ b/sw/source/ui/uno/unofreg.cxx
@@ -130,7 +130,12 @@ extern uno::Sequence< OUString > SAL_CALL SwXMailMerge_getSupportedServiceNames(
extern OUString SAL_CALL SwXMailMerge_getImplementationName() throw();
extern uno::Reference< uno::XInterface > SAL_CALL SwXMailMerge_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
-// --> OD 2007-05-24 #i73788#
+// Layout dump filter
+extern uno::Sequence< OUString > SAL_CALL LayoutDumpFilter_getSupportedServiceNames() throw();
+extern OUString SAL_CALL LayoutDumpFilter_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL LayoutDumpFilter_createInstance( const uno::Reference< XMultiServiceFactory > &rSMgr ) throw( uno::Exception );
+
+// #i73788#
#include "cppuhelper/implementationentry.hxx"
namespace comp_FinalThreadManager {
@@ -141,9 +146,7 @@ com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL _crea
com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > const & context );
}
-// <--
-//
#ifdef __cplusplus
extern "C"
{
@@ -362,6 +365,14 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
SwUnoModule_createInstance,
SwUnoModule_getSupportedServiceNames() );
}
+ else if( LayoutDumpFilter_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ LayoutDumpFilter_getImplementationName(),
+ LayoutDumpFilter_createInstance,
+ LayoutDumpFilter_getSupportedServiceNames() );
+ }
else if( comp_FinalThreadManager::_getImplementationName().equalsAsciiL(
pImplName, nImplNameLen ) )
{
diff --git a/sw/util/sw.component b/sw/util/sw.component
index e76cec637d33..7f7377754af7 100644
--- a/sw/util/sw.component
+++ b/sw/util/sw.component
@@ -25,9 +25,7 @@
* for a copy of the LGPLv3 License.
*
**********************************************************************-->
-
-<component loader="com.sun.star.loader.SharedLibrary"
- xmlns="http://openoffice.org/2010/uno-components">
+<component xmlns="http://openoffice.org/2010/uno-components" loader="com.sun.star.loader.SharedLibrary">
<implementation name="SwXAutoTextContainer">
<service name="com.sun.star.text.AutoTextContainer"/>
</implementation>
@@ -101,4 +99,7 @@
<implementation name="com.sun.star.util.comp.FinalThreadManager">
<service name="com.sun.star.util.JobManager"/>
</implementation>
+ <implementation name="com.sun.star.comp.Writer.LayoutDump">
+ <service name="com.sun.star.comp.Writer.LayoutDump"/>
+ </implementation>
</component>