summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorThorsten Behrens <Thorsten.Behrens@CIB.de>2018-10-01 03:21:59 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-01-07 17:49:44 +0100
commit3272c1eb5563f3bda2caa24f32b1018372622109 (patch)
treeb4b948fd36ed53b1d8399babf2dbe701469da412 /writerfilter
parent5dfd5755c709e91d2903bd7be4582f7832e89780 (diff)
related tdf#100074: prepare group shapes text input via writerfilter
Put various preps into place, that enable us to read txbxContent from group shape children via the writerfilter parser, which gets us much more features Also: - store shapecontexthandler on wrapper class in writerfilter - move adding children shapes to ctor, not dtor - remove RuntimeException in Writer's XShapes::add(), aligns this with Draw/Impress API semantics, and helps here when trying to add the same shape a 2nd time (which we then simply ignore) - make oox's Shape notion of 'inside group' less ad-hoc - make SwTextBoxHelper::getTextRectangle() cope with more than CustomShape - so passing in a group shape will also yield some sensible bounding box - have SwTextBoxHelper handle group content, too - derive WpsContext from ShapeContext, so we can later substitute it for that inside WpgContext - keep WpgContext::onCreateContext() _for the moment_ with the old delegation to ShapeContext (needs to use WpsContext to enable writerfilter text input) Change-Id: I2b0f0583e21137f3321a8dc13823058b14d19773 Reviewed-on: https://gerrit.libreoffice.org/65914 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx2
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.cxx75
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.hxx7
-rw-r--r--writerfilter/source/rtftok/rtfsdrimport.cxx9
4 files changed, 57 insertions, 36 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 5affdd4d5703..190f6257ef89 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2946,6 +2946,8 @@ void DomainMapper::markLastSectionGroup( )
void DomainMapper::lcl_startShape(uno::Reference<drawing::XShape> const& xShape)
{
+ assert(xShape.is());
+
if (m_pImpl->GetTopContext())
{
// If there is a deferred page break, handle it now, so that the
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 1c3448f59660..0d50937b0518 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -18,6 +18,7 @@
*/
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/xml/sax/FastShapeContextHandler.hpp>
#include <com/sun/star/xml/sax/SAXException.hpp>
#include <ooxml/resourceids.hxx>
@@ -48,6 +49,7 @@ namespace ooxml
using namespace ::com::sun::star;
using namespace oox;
using namespace ::std;
+using namespace ::com::sun::star::xml::sax;
/*
class OOXMLFastContextHandler
@@ -1735,7 +1737,9 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext
mrShapeContext->createFastChildContext(Element, Attribs);
OOXMLFastContextHandlerWrapper * pWrapper =
- new OOXMLFastContextHandlerWrapper(this, pChildContext);
+ new OOXMLFastContextHandlerWrapper(this,
+ pChildContext,
+ this);
if (!bGroupShape)
{
@@ -1744,7 +1748,6 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext
pWrapper->addNamespace(NMSP_vmlOffice);
pWrapper->addToken( NMSP_vml|XML_textbox );
}
-
xContextHandler.set(pWrapper);
}
else
@@ -1792,8 +1795,11 @@ void OOXMLFastContextHandlerShape::lcl_characters
OOXMLFastContextHandlerWrapper::OOXMLFastContextHandlerWrapper
(OOXMLFastContextHandler * pParent,
- uno::Reference<XFastContextHandler> const & xContext)
-: OOXMLFastContextHandler(pParent), mxContext(xContext)
+ uno::Reference<XFastContextHandler> const & xContext,
+ rtl::Reference<OOXMLFastContextHandlerShape> const & xShapeHandler)
+ : OOXMLFastContextHandler(pParent),
+ mxWrappedContext(xContext),
+ mxShapeHandler(xShapeHandler)
{
setId(pParent->getId());
setToken(pParent->getToken());
@@ -1809,16 +1815,16 @@ void SAL_CALL OOXMLFastContextHandlerWrapper::startUnknownElement
const OUString & Name,
const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
{
- if (mxContext.is())
- mxContext->startUnknownElement(Namespace, Name, Attribs);
+ if (mxWrappedContext.is())
+ mxWrappedContext->startUnknownElement(Namespace, Name, Attribs);
}
void SAL_CALL OOXMLFastContextHandlerWrapper::endUnknownElement
(const OUString & Namespace,
const OUString & Name)
{
- if (mxContext.is())
- mxContext->endUnknownElement(Namespace, Name);
+ if (mxWrappedContext.is())
+ mxWrappedContext->endUnknownElement(Namespace, Name);
}
uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
@@ -1829,8 +1835,8 @@ OOXMLFastContextHandlerWrapper::createUnknownChildContext
{
uno::Reference< xml::sax::XFastContextHandler > xResult;
- if (mxContext.is())
- xResult = mxContext->createUnknownChildContext
+ if (mxWrappedContext.is())
+ xResult = mxWrappedContext->createUnknownChildContext
(Namespace, Name, Attribs);
else
xResult.set(this);
@@ -1841,7 +1847,7 @@ OOXMLFastContextHandlerWrapper::createUnknownChildContext
void OOXMLFastContextHandlerWrapper::attributes
(const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
{
- if (mxContext.is())
+ if (mxWrappedContext.is())
{
OOXMLFastContextHandler * pHandler = getFastContextHandler();
if (pHandler != nullptr)
@@ -1869,15 +1875,15 @@ void OOXMLFastContextHandlerWrapper::lcl_startFastElement
(Token_t Element,
const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
{
- if (mxContext.is())
- mxContext->startFastElement(Element, Attribs);
+ if (mxWrappedContext.is())
+ mxWrappedContext->startFastElement(Element, Attribs);
}
void OOXMLFastContextHandlerWrapper::lcl_endFastElement
(Token_t Element)
{
- if (mxContext.is())
- mxContext->endFastElement(Element);
+ if (mxWrappedContext.is())
+ mxWrappedContext->endFastElement(Element);
}
uno::Reference< xml::sax::XFastContextHandler >
@@ -1899,22 +1905,29 @@ OOXMLFastContextHandlerWrapper::lcl_createFastChildContext
bool bSkipImages = getDocument()->IsSkipImages() && oox::getNamespace(Element) == NMSP_dml &&
!((oox::getBaseToken(Element) == XML_linkedTxbx) || (oox::getBaseToken(Element) == XML_txbx));
- if ( bInNamespaces && ((!bIsWrap && !bIsSignatureLine) || dynamic_cast<OOXMLFastContextHandlerShape&>(*mpParent).isShapeSent()) )
+ if ( bInNamespaces && ((!bIsWrap && !bIsSignatureLine)
+ || mxShapeHandler->isShapeSent()) )
+ {
xResult.set(OOXMLFactory::createFastChildContextFromStart(this, Element));
- else if (mxContext.is() && !bSkipImages)
+ }
+ else if (mxWrappedContext.is() && !bSkipImages)
{
OOXMLFastContextHandlerWrapper * pWrapper =
new OOXMLFastContextHandlerWrapper
- (this, mxContext->createFastChildContext(Element, Attribs));
+ (this, mxWrappedContext->createFastChildContext(Element, Attribs),
+ mxShapeHandler);
pWrapper->mMyNamespaces = mMyNamespaces;
+ pWrapper->mMyTokens = mMyTokens;
pWrapper->setPropertySet(getPropertySet());
xResult.set(pWrapper);
}
else
+ {
xResult.set(this);
+ }
if ( bInTokens )
- static_cast<OOXMLFastContextHandlerShape*>(mpParent)->sendShape( Element );
+ mxShapeHandler->sendShape( Element );
return xResult;
}
@@ -1922,15 +1935,15 @@ OOXMLFastContextHandlerWrapper::lcl_createFastChildContext
void OOXMLFastContextHandlerWrapper::lcl_characters
(const OUString & aChars)
{
- if (mxContext.is())
- mxContext->characters(aChars);
+ if (mxWrappedContext.is())
+ mxWrappedContext->characters(aChars);
}
OOXMLFastContextHandler *
OOXMLFastContextHandlerWrapper::getFastContextHandler() const
{
- if (mxContext.is())
- return dynamic_cast<OOXMLFastContextHandler *>(mxContext.get());
+ if (mxWrappedContext.is())
+ return dynamic_cast<OOXMLFastContextHandler *>(mxWrappedContext.get());
return nullptr;
}
@@ -1938,7 +1951,7 @@ OOXMLFastContextHandlerWrapper::getFastContextHandler() const
void OOXMLFastContextHandlerWrapper::newProperty
(Id nId, const OOXMLValue::Pointer_t& pVal)
{
- if (mxContext.is())
+ if (mxWrappedContext.is())
{
OOXMLFastContextHandler * pHandler = getFastContextHandler();
if (pHandler != nullptr)
@@ -1949,7 +1962,7 @@ void OOXMLFastContextHandlerWrapper::newProperty
void OOXMLFastContextHandlerWrapper::setPropertySet
(const OOXMLPropertySet::Pointer_t& pPropertySet)
{
- if (mxContext.is())
+ if (mxWrappedContext.is())
{
OOXMLFastContextHandler * pHandler = getFastContextHandler();
if (pHandler != nullptr)
@@ -1964,7 +1977,7 @@ OOXMLPropertySet::Pointer_t OOXMLFastContextHandlerWrapper::getPropertySet()
{
OOXMLPropertySet::Pointer_t pResult(mpPropertySet);
- if (mxContext.is())
+ if (mxWrappedContext.is())
{
OOXMLFastContextHandler * pHandler = getFastContextHandler();
if (pHandler != nullptr)
@@ -1978,7 +1991,7 @@ string OOXMLFastContextHandlerWrapper::getType() const
{
string sResult = "Wrapper(";
- if (mxContext.is())
+ if (mxWrappedContext.is())
{
OOXMLFastContextHandler * pHandler = getFastContextHandler();
if (pHandler != nullptr)
@@ -1994,7 +2007,7 @@ void OOXMLFastContextHandlerWrapper::setId(Id rId)
{
OOXMLFastContextHandler::setId(rId);
- if (mxContext.is())
+ if (mxWrappedContext.is())
{
OOXMLFastContextHandler * pHandler = getFastContextHandler();
if (pHandler != nullptr)
@@ -2006,7 +2019,7 @@ Id OOXMLFastContextHandlerWrapper::getId() const
{
Id nResult = OOXMLFastContextHandler::getId();
- if (mxContext.is())
+ if (mxWrappedContext.is())
{
OOXMLFastContextHandler * pHandler = getFastContextHandler();
if (pHandler != nullptr && pHandler->getId() != 0)
@@ -2020,7 +2033,7 @@ void OOXMLFastContextHandlerWrapper::setToken(Token_t nToken)
{
OOXMLFastContextHandler::setToken(nToken);
- if (mxContext.is())
+ if (mxWrappedContext.is())
{
OOXMLFastContextHandler * pHandler = getFastContextHandler();
if (pHandler != nullptr)
@@ -2032,7 +2045,7 @@ Token_t OOXMLFastContextHandlerWrapper::getToken() const
{
Token_t nResult = OOXMLFastContextHandler::getToken();
- if (mxContext.is())
+ if (mxWrappedContext.is())
{
OOXMLFastContextHandler * pHandler = getFastContextHandler();
if (pHandler != nullptr)
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
index 29842cc5071f..03aab0070209 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
@@ -483,7 +483,9 @@ protected:
class OOXMLFastContextHandlerWrapper : public OOXMLFastContextHandler
{
public:
- explicit OOXMLFastContextHandlerWrapper(OOXMLFastContextHandler * pParent, css::uno::Reference<css::xml::sax::XFastContextHandler> const & xContext);
+ OOXMLFastContextHandlerWrapper(OOXMLFastContextHandler * pParent,
+ css::uno::Reference<css::xml::sax::XFastContextHandler> const & xContext,
+ rtl::Reference<OOXMLFastContextHandlerShape> const & xShapeHandler);
virtual ~OOXMLFastContextHandlerWrapper() override;
// css::xml::sax::XFastContextHandler:
@@ -523,7 +525,8 @@ protected:
virtual Token_t getToken() const override;
private:
- css::uno::Reference<css::xml::sax::XFastContextHandler> mxContext;
+ css::uno::Reference<css::xml::sax::XFastContextHandler> mxWrappedContext;
+ rtl::Reference<OOXMLFastContextHandlerShape> mxShapeHandler;
std::set<Id> mMyNamespaces;
std::set<Token_t> mMyTokens;
OOXMLPropertySet::Pointer_t mpPropertySet;
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 7960f12eea15..ee3d24e3b878 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -1082,10 +1082,13 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
}
// Send it to dmapper
- m_rImport.Mapper().startShape(xShape);
- if (bClose)
+ if (xShape.is())
{
- m_rImport.Mapper().endShape();
+ m_rImport.Mapper().startShape(xShape);
+ if (bClose)
+ {
+ m_rImport.Mapper().endShape();
+ }
}
m_xShape = xShape;
}