[Libreoffice-commits] core.git: 2 commits - sw/source writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Sat Feb 21 10:03:32 PST 2015
sw/source/core/doc/docredln.cxx | 50 +++++++++++
sw/source/core/docnode/nodedump.cxx | 138 -------------------------------
writerfilter/source/filter/RtfFilter.cxx | 84 ++++++++++++------
writerfilter/source/filter/RtfFilter.hxx | 82 ------------------
4 files changed, 107 insertions(+), 247 deletions(-)
New commits:
commit 76e974e078d8ad77eb316cfbe5a3e2323cac390a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Sat Feb 21 11:16:07 2015 +0100
Extract SwRedlineTbl::dumpAsXml() from docnode
Change-Id: I336d7875bbd88dd1993993e0e049c264b87f2318
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 8d9cf08..20dcda5 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <libxml/xmlwriter.h>
+#include <tools/datetimeutils.hxx>
#include <hintids.hxx>
#include <svl/itemiter.hxx>
#include <sfx2/app.hxx>
@@ -564,6 +566,54 @@ const SwRangeRedline* SwRedlineTbl::FindAtPosition( const SwPosition& rSttPos,
return pFnd;
}
+void SwRedlineTbl::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+ xmlTextWriterStartElement(pWriter, BAD_CAST("swRedlineTbl"));
+ xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
+
+ for (sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < size(); ++nCurRedlinePos)
+ {
+ const SwRangeRedline* pRedline = operator[](nCurRedlinePos);
+ xmlTextWriterStartElement(pWriter, BAD_CAST("swRangeRedline"));
+
+ xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", pRedline);
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("id"), BAD_CAST(OString::number(pRedline->GetSeqNo()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("author"), BAD_CAST(SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor()).toUtf8().getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("date"), BAD_CAST(DateTimeToOString(pRedline->GetTimeStamp()).getStr()));
+
+ OString sRedlineType;
+ switch (pRedline->GetType())
+ {
+ case nsRedlineType_t::REDLINE_INSERT:
+ sRedlineType = "REDLINE_INSERT";
+ break;
+ case nsRedlineType_t::REDLINE_DELETE:
+ sRedlineType = "REDLINE_DELETE";
+ break;
+ case nsRedlineType_t::REDLINE_FORMAT:
+ sRedlineType = "REDLINE_FORMAT";
+ break;
+ default:
+ sRedlineType = "UNKNOWN";
+ break;
+ }
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"), BAD_CAST(sRedlineType.getStr()));
+
+ xmlTextWriterStartElement(pWriter, BAD_CAST("point"));
+ pRedline->GetPoint()->dumpAsXml(pWriter);
+ xmlTextWriterEndElement(pWriter);
+ xmlTextWriterStartElement(pWriter, BAD_CAST("mark"));
+ pRedline->GetMark()->dumpAsXml(pWriter);
+ xmlTextWriterEndElement(pWriter);
+
+ const SwRedlineExtraData* pExtraRedlineData = pRedline->GetExtraData();
+ xmlTextWriterStartElement(pWriter, BAD_CAST("swRedlineExtraData"));
+ xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("symbol"), "%s", BAD_CAST(typeid(pExtraRedlineData).name()));
+ xmlTextWriterEndElement(pWriter); // swRadlineExtraData
+ xmlTextWriterEndElement(pWriter); // swRangeRedline
+ }
+ xmlTextWriterEndElement(pWriter); // swRedlineTbl
+}
SwRedlineExtraData::~SwRedlineExtraData()
{
diff --git a/sw/source/core/docnode/nodedump.cxx b/sw/source/core/docnode/nodedump.cxx
index 7ab7fe8..e485e33 100644
--- a/sw/source/core/docnode/nodedump.cxx
+++ b/sw/source/core/docnode/nodedump.cxx
@@ -95,7 +95,6 @@ void WriterHelper::writeFormatAttribute( const char* attribute, const char* form
// Hack: somehow conversion from "..." to va_list does
// bomb on two string litterals in the format.
static const char* TMP_FORMAT = "%" SAL_PRIuUINTPTR;
-static const char* TMP_FORMAT_I32 = "%" SAL_PRIdINT32;
}
@@ -340,143 +339,6 @@ void SwTxtNode::dumpAsXml( xmlTextWriterPtr w ) const
writer.endElement();
}
-void SwRedlineTbl::dumpAsXml( xmlTextWriterPtr w ) const
-{
- WriterHelper writer( w );
-
- writer.startElement( "swredlinetbl" );
- writer.writeFormatAttribute( "ptr", "%p", this );
-
- const SwRedlineTbl& redlineTbl = (*this);
-
- for( sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < size(); ++nCurRedlinePos )
- {
- const SwRangeRedline* pRedline = redlineTbl[ nCurRedlinePos ];
-
- writer.startElement( "swredline" );
- writer.writeFormatAttribute( "ptr", "%p", pRedline );
-
- OString aId( OString::number( pRedline->GetSeqNo() ) );
- const OUString &rAuthor( SW_MOD()->GetRedlineAuthor( pRedline->GetAuthor() ) );
- OString aAuthor( OUStringToOString( rAuthor, RTL_TEXTENCODING_UTF8 ) );
- OString aDate( DateTimeToOString( pRedline->GetTimeStamp() ) );
- OString sRedlineType;
- switch( pRedline->GetType() )
- {
- case nsRedlineType_t::REDLINE_INSERT:
- sRedlineType = "REDLINE_INSERT";
- break;
- case nsRedlineType_t::REDLINE_DELETE:
- sRedlineType = "REDLINE_DELETE";
- break;
- case nsRedlineType_t::REDLINE_FORMAT:
- sRedlineType = "REDLINE_FORMAT";
- break;
- default:
- sRedlineType = "UNKNOWN";
- break;
- }
- writer.writeFormatAttribute( "id", "%s", BAD_CAST(aId.getStr()) );
- writer.writeFormatAttribute( "author", "%s", BAD_CAST(aAuthor.getStr()) );
- writer.writeFormatAttribute( "date", "%s", BAD_CAST(aDate.getStr()) );
- writer.writeFormatAttribute( "type", "%s", BAD_CAST(sRedlineType.getStr()) );
- {
- const SwPosition* pStart = pRedline->Start();
-
- writer.startElement( "swposition_start" );
- //writer.writeFormatAttribute( "ptr", "%p", pStart );
- {
- const SwNodeIndex pStartNodeIndex = pStart->nNode;
- //writer.startElement( "swnodeindex" );
- //writer.writeFormatAttribute( "ptr", "%p", &pStartNodeIndex );
- {
- const SwNode& pStartSwNode = pStartNodeIndex.GetNode();
- //writer.startElement( "swnode" );
- //writer.writeFormatAttribute( "ptr", "%p", &pStartSwNode );
- //writer.writeFormatAttribute( "type", "%d", pStartSwNode.GetNodeType() );
- //writer.endElement( ); // swnode
- writer.writeFormatAttribute( "swnode_type", TMP_FORMAT, pStartSwNode.GetNodeType() );
-
- writer.writeFormatAttribute( "paragraph_index", "%d", (int)pStartNodeIndex.GetIndex() );
-
- const SwIndex& pStartContent = pStart->nContent;
- //writer.startElement( "swindex" );
- //writer.writeFormatAttribute( "ptr", "%p", &pStartContent );
- //writer.writeFormatAttribute( "content_index", "%d", pStartContent.GetIndex() );
- //writer.endElement( ); // swindex
- writer.writeFormatAttribute( "character_index", TMP_FORMAT_I32, pStartContent.GetIndex() );
- }
- //writer.endElement( ); // swnodeindex
- }
- writer.endElement( ); // swposition_start
-
- const SwPosition* pEnd;
- bool bEndIsMark = false;
- if ( pStart == pRedline->GetPoint() )
- {
- // End = Mark
- pEnd = pRedline->GetMark();
- bEndIsMark = true;
- }
- else
- {
- // End = Point
- pEnd = pRedline->GetPoint();
- }
-
- writer.startElement( "swposition_end" );
- //writer.writeFormatAttribute( "ptr", "%p", pStart );
- {
- const SwNodeIndex pEndNodeIndex = pEnd->nNode;
- //writer.startElement( "swnodeindex" );
- //writer.writeFormatAttribute( "ptr", "%p", &pEndNodeIndex );
- {
- const SwNode& pEndSwNode = pEndNodeIndex.GetNode();
- //writer.startElement( "swnode" );
- //writer.writeFormatAttribute( "ptr", "%p", &pEndSwNode );
- //writer.writeFormatAttribute( "type", "%d", pEndSwNode.GetNodeType() );
- //writer.endElement( ); // swnode
- writer.writeFormatAttribute( "swnode_type", TMP_FORMAT, pEndSwNode.GetNodeType() );
-
- writer.writeFormatAttribute( "paragraph_index", "%d", (int)pEndNodeIndex.GetIndex() );
-
- const SwIndex& pEndContent = pEnd->nContent;
- //writer.startElement( "swindex" );
- //writer.writeFormatAttribute( "ptr", "%p", &pEndContent );
- //writer.writeFormatAttribute( "content_index", "%d", pEndContent.GetIndex() );
- //writer.endElement( ); // swindex
- writer.writeFormatAttribute( "character_index", TMP_FORMAT_I32, pEndContent.GetIndex() );
- }
- //writer.endElement( ); // swnodeindex
- }
- writer.writeFormatAttribute( "end_is", "%s", BAD_CAST(bEndIsMark ? "mark" : "point"));
- writer.endElement( ); // swposition_end
-
- //const SwRedlineData& aRedlineData = pRedline->GetRedlineData();
- const SwRedlineExtraData* pExtraRedlineData = pRedline->GetExtraData();
- writer.startElement( "extra_redline_data" );
- {
- const SwRedlineExtraData_FmtColl* pExtraData_FmtColl = dynamic_cast<const SwRedlineExtraData_FmtColl*>(pExtraRedlineData);
- const SwRedlineExtraData_Format* pExtraData_Format = dynamic_cast<const SwRedlineExtraData_Format*>(pExtraRedlineData);
- const SwRedlineExtraData_FormattingChanges* pExtraData_FormattingChanges = dynamic_cast<const SwRedlineExtraData_FormattingChanges*>(pExtraRedlineData);
- if (pExtraData_FmtColl)
- writer.writeFormatAttribute( "extra_data_type", "%s", BAD_CAST( "fmt coll" ) );
- else if (pExtraData_Format)
- writer.writeFormatAttribute( "extra_data_type", "%s", BAD_CAST( "format" ) );
- else if (pExtraData_FormattingChanges)
- writer.writeFormatAttribute( "extra_data_type", "%s", BAD_CAST( "formatting changes" ) );
- else
- writer.writeFormatAttribute( "extra_data_type", "%s", BAD_CAST( "UNKNOWN" ) );
- }
- writer.endElement( ); // extra_redline_data
- }
-
- writer.endElement( ); // extra_redline_data
- }
-
- writer.endElement( ); // swredlinetbl
-}
-
void SwExtraRedlineTbl::dumpAsXml( xmlTextWriterPtr w ) const
{
WriterHelper writer( w );
commit af986d2be777e7dd31ce94a70e60af754bac7131
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Sat Feb 21 10:41:07 2015 +0100
writerfilter: clean up RtfFilter
Change-Id: I4bcff4ddde2869a4aeecfdfda02c685d61d65531
diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx
index de5b505..6ab4934 100644
--- a/writerfilter/source/filter/RtfFilter.cxx
+++ b/writerfilter/source/filter/RtfFilter.cxx
@@ -17,21 +17,65 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <RtfFilter.hxx>
-#include <cppuhelper/implementationentry.hxx>
-#include <unotools/mediadescriptor.hxx>
-#include <cppuhelper/supportsservice.hxx>
-#include <dmapper/DomainMapperFactory.hxx>
-#include <rtftok/RTFDocument.hxx>
+#include <memory>
+
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
#include <com/sun/star/io/WrongFormatException.hpp>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
-#include <memory>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase.hxx>
+#include <cppuhelper/implementationentry.hxx>
+#include <cppuhelper/supportsservice.hxx>
#include <unotools/localfilehelper.hxx>
-#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/mediadescriptor.hxx>
#include <unotools/streamwrap.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+
+#include <dmapper/DomainMapperFactory.hxx>
+#include <rtftok/RTFDocument.hxx>
using namespace ::com::sun::star;
+/// Invokes the RTF tokenizer + dmapper or RtfExportFilter in sw via UNO.
+class RtfFilter : public cppu::WeakImplHelper
+ <
+ document::XFilter,
+ document::XImporter,
+ document::XExporter,
+ lang::XInitialization,
+ lang::XServiceInfo
+ >
+{
+ uno::Reference<uno::XComponentContext> m_xContext;
+ uno::Reference<lang::XComponent> m_xSrcDoc, m_xDstDoc;
+
+public:
+ RtfFilter(const uno::Reference<uno::XComponentContext>& xContext);
+ virtual ~RtfFilter();
+
+ // XFilter
+ virtual sal_Bool SAL_CALL filter(const uno::Sequence<beans::PropertyValue>& rDescriptor) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual void SAL_CALL cancel() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ // XImporter
+ virtual void SAL_CALL setTargetDocument(const uno::Reference<lang::XComponent>& xDoc) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ // XExporter
+ virtual void SAL_CALL setSourceDocument(const uno::Reference<lang::XComponent>& xDoc) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ // XInitialization
+ virtual void SAL_CALL initialize(const uno::Sequence<uno::Any>& rArguments) throw (uno::Exception, uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+};
+
RtfFilter::RtfFilter(const uno::Reference< uno::XComponentContext >& rxContext)
: m_xContext(rxContext)
{
@@ -103,8 +147,7 @@ sal_Bool RtfFilter::filter(const uno::Sequence< beans::PropertyValue >& aDescrip
writerfilter::dmapper::SourceDocumentType eType = writerfilter::dmapper::SourceDocumentType::RTF;
writerfilter::Stream::Pointer_t pStream(
writerfilter::dmapper::DomainMapperFactory::createMapper(m_xContext, xInputStream, m_xDstDoc, bRepairStorage, eType, xInsertTextRange, aMediaDesc));
- writerfilter::rtftok::RTFDocument::Pointer_t const pDocument(
- writerfilter::rtftok::RTFDocumentFactory::createDocument(m_xContext, xInputStream, m_xDstDoc, xFrame, xStatusIndicator));
+ writerfilter::rtftok::RTFDocument::Pointer_t pDocument(writerfilter::rtftok::RTFDocumentFactory::createDocument(m_xContext, xInputStream, m_xDstDoc, xFrame, xStatusIndicator));
pDocument->resolve(*pStream);
bResult = true;
sal_uInt32 nEndTime = osl_getGlobalTimer();
@@ -148,7 +191,7 @@ void RtfFilter::initialize(const uno::Sequence< uno::Any >& /*aArguments*/) thro
OUString RtfFilter::getImplementationName() throw(uno::RuntimeException, std::exception)
{
- return RtfFilter_getImplementationName();
+ return OUString("com.sun.star.comp.Writer.RtfFilter");
}
sal_Bool RtfFilter::supportsService(const OUString& rServiceName) throw(uno::RuntimeException, std::exception)
@@ -156,18 +199,7 @@ sal_Bool RtfFilter::supportsService(const OUString& rServiceName) throw(uno::Run
return cppu::supportsService(this, rServiceName);
}
-uno::Sequence< OUString > RtfFilter::getSupportedServiceNames() throw(uno::RuntimeException, std::exception)
-{
- return RtfFilter_getSupportedServiceNames();
-}
-
-/* Helpers, used by shared lib exports. */
-OUString RtfFilter_getImplementationName() throw(uno::RuntimeException)
-{
- return OUString("com.sun.star.comp.Writer.RtfFilter");
-}
-
-uno::Sequence<OUString> RtfFilter_getSupportedServiceNames() throw(uno::RuntimeException)
+uno::Sequence<OUString> RtfFilter::getSupportedServiceNames() throw(uno::RuntimeException, std::exception)
{
uno::Sequence<OUString> aRet =
{
@@ -177,10 +209,8 @@ uno::Sequence<OUString> RtfFilter_getSupportedServiceNames() throw(uno::RuntimeE
return aRet;
}
-extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
-com_sun_star_comp_Writer_RtfFilter_get_implementation(::com::sun::star::uno::XComponentContext* component,
- ::com::sun::star::uno::Sequence<css::uno::Any> const &)
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* SAL_CALL com_sun_star_comp_Writer_RtfFilter_get_implementation(uno::XComponentContext* pComponent, uno::Sequence<uno::Any> const&)
{
- return cppu::acquire(new RtfFilter(component));
+ return cppu::acquire(new RtfFilter(pComponent));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/filter/RtfFilter.hxx b/writerfilter/source/filter/RtfFilter.hxx
deleted file mode 100644
index dcd3a2e..0000000
--- a/writerfilter/source/filter/RtfFilter.hxx
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_WRITERFILTER_SOURCE_FILTER_RTFFILTER_HXX
-#define INCLUDED_WRITERFILTER_SOURCE_FILTER_RTFFILTER_HXX
-
-#include <com/sun/star/document/XExporter.hpp>
-#include <com/sun/star/document/XFilter.hpp>
-#include <com/sun/star/document/XImporter.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
-#include <cppuhelper/implbase.hxx>
-
-/// Common RTF filter, calls RtfImportFilter and RtfExportFilter via UNO.
-class RtfFilter : public cppu::WeakImplHelper
- <
- css::document::XFilter,
- css::document::XImporter,
- css::document::XExporter,
- css::lang::XInitialization,
- css::lang::XServiceInfo
- >
-{
-
-protected:
- css::uno::Reference<css::uno::XComponentContext> m_xContext;
- css::uno::Reference<css::lang::XComponent> m_xSrcDoc, m_xDstDoc;
- OUString m_sFilterName;
- css::uno::Reference<css::xml::sax::XDocumentHandler> m_xHandler;
-
-
-public:
- RtfFilter(const css::uno::Reference<css::uno::XComponentContext>& xContext);
- virtual ~RtfFilter();
-
- // XFilter
- virtual sal_Bool SAL_CALL filter(const css::uno::Sequence<css::beans::PropertyValue>& rDescriptor) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual void SAL_CALL cancel() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- // XImporter
- virtual void SAL_CALL setTargetDocument(const css::uno::Reference<css::lang::XComponent>& xDoc)
- throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- // XExporter
- virtual void SAL_CALL setSourceDocument(const css::uno::Reference<css::lang::XComponent>& xDoc)
- throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- // XInitialization
- virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArguments) throw (css::uno::Exception, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- // XServiceInfo
- virtual OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
-};
-
-
-OUString RtfFilter_getImplementationName() throw (css::uno::RuntimeException);
-css::uno::Sequence<OUString> SAL_CALL RtfFilter_getSupportedServiceNames() throw (css::uno::RuntimeException);
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list