[Libreoffice-commits] core.git: 10 commits - include/sax oox/source sax/source sw/qa sw/source writerfilter/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.com
Wed Mar 5 11:24:35 PST 2014
include/sax/fastattribs.hxx | 1
oox/source/token/tokens.txt | 1
sax/source/tools/fastattribs.cxx | 6 +
sw/qa/extras/ooxmlexport/data/AnchorId.docx |binary
sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx | 12 ++
sw/source/filter/ww8/docxsdrexport.cxx | 76 +++++++++++++--
writerfilter/source/dmapper/GraphicImport.cxx | 129 ++++++++++++++++----------
writerfilter/source/dmapper/GraphicImport.hxx | 55 ++++++-----
writerfilter/source/ooxml/model.xml | 20 +++-
9 files changed, 219 insertions(+), 81 deletions(-)
New commits:
commit 477684669a03e7c6048b804ca3f3ebec43a4d071
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed Mar 5 20:21:58 2014 +0100
ooxml: round-trip test for w14:anchorId & wp14:anchorId
Change-Id: Iada0ba2b6d1450167977915fe95a38b5bab2559c
diff --git a/sw/qa/extras/ooxmlexport/data/AnchorId.docx b/sw/qa/extras/ooxmlexport/data/AnchorId.docx
new file mode 100644
index 0000000..b1b6668
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/AnchorId.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
index d3e6f6b..ed9f630 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
@@ -890,6 +890,18 @@ DECLARE_OOXMLEXPORT_TEST(testGroupshapeThemeFont, "groupshape-theme-font.docx")
CPPUNIT_ASSERT_EQUAL(OUString("Cambria"), getProperty<OUString>(xRun, "CharFontName"));
}
+DECLARE_OOXMLEXPORT_TEST(testAnchorIdForWP14AndW14, "AnchorId.docx")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[3]/mc:AlternateContent/mc:Choice/w:drawing/wp:inline", "anchorId", "78735EFD");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[3]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "anchorId", "78735EFD");
+
+
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
commit ce5cca0cdad0a414d7f5a8e007a38755e1ae1b51
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed Mar 5 20:21:04 2014 +0100
ooxml export: writer anchorId for "inline" element
Change-Id: I366c329cbdcafdda87feef73802b4d1be991bb4f
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index eeca450..835892c 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -405,12 +405,19 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrmFmt* pFrmFmt, const Size& rS
}
else
{
- m_pImpl->m_pSerializer->startElementNS(XML_wp, XML_inline,
- XML_distT, OString::number(TwipsToEMU(pULSpaceItem.GetUpper())).getStr(),
- XML_distB, OString::number(TwipsToEMU(pULSpaceItem.GetLower())).getStr(),
- XML_distL, OString::number(TwipsToEMU(pLRSpaceItem.GetLeft())).getStr(),
- XML_distR, OString::number(TwipsToEMU(pLRSpaceItem.GetRight())).getStr(),
- FSEND);
+ sax_fastparser::FastAttributeList* aAttrList = m_pImpl->m_pSerializer->createAttrList();
+ aAttrList->add(XML_distT, OString::number(TwipsToEMU(pULSpaceItem.GetUpper())).getStr());
+ aAttrList->add(XML_distB, OString::number(TwipsToEMU(pULSpaceItem.GetLower())).getStr());
+ aAttrList->add(XML_distL, OString::number(TwipsToEMU(pLRSpaceItem.GetLeft())).getStr());
+ aAttrList->add(XML_distR, OString::number(TwipsToEMU(pLRSpaceItem.GetRight())).getStr());
+ const SdrObject* pObj = pFrmFmt->FindRealSdrObject();
+ if (pObj != NULL)
+ {
+ OUString sAnchorId = lclGetAnchorIdFromGrabBag(pObj);
+ if (!sAnchorId.isEmpty())
+ aAttrList->addNS(XML_wp14, XML_anchorId, OUStringToOString(sAnchorId, RTL_TEXTENCODING_UTF8));
+ }
+ m_pImpl->m_pSerializer->startElementNS(XML_wp, XML_inline, aAttrList);
}
// now the common parts
commit 25acc2efb9df1090f9bb8f696fa1d43508b7a9b8
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed Mar 5 20:20:03 2014 +0100
writerfilter: also push anchorId for inline to a FrameGrabBag
Change-Id: I187affa518f0df8717c75855d3ea78a5bea7e69b
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index cd014c8..5f6d50d 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -587,6 +587,7 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
//enable overlapping - ignored
break;
case NS_ooxml::LN_CT_Anchor_wp14_anchorId:
+ case NS_ooxml::LN_CT_Inline_wp14_anchorId:
{
OUStringBuffer aBuffer = OUString::number(nIntValue, 16);
OUStringBuffer aString;
commit e9c6b925957bcc47337c81db5b32b16dcf38e612
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed Mar 5 20:14:49 2014 +0100
writerfilter: add anchorId also for CT_Inline in model.xml
Change-Id: Ie491345697e584597867df3937c8d832d0609a70
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index bb63221..8739717 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -7887,6 +7887,11 @@
<xs:documentation>Distance from Text</xs:documentation>
</data>
</define>
+ <define name="ST_EditId">
+ <data type="hexBinary">
+ <param name="length">4</param>
+ </data>
+ </define>
<define name="CT_Inline">
<group>
<element name="extent">
@@ -7943,6 +7948,11 @@
<xs:documentation>Distance From Text on Right Edge</xs:documentation>
</attribute>
</optional>
+ <optional>
+ <attribute name="wp14:anchorId">
+ <ref name="ST_EditId"/>
+ </attribute>
+ </optional>
</define>
<define name="ST_WrapText">
<list>
@@ -8196,11 +8206,6 @@
</choice>
</list>
</define>
- <define name="ST_EditId">
- <data type="hexBinary">
- <param name="length">4</param>
- </data>
- </define>
<define name="CT_PosV">
<choice>
<element name="align">
@@ -8325,9 +8330,11 @@
</data>
<xs:documentation>Allow Objects to Overlap</xs:documentation>
</attribute>
- <attribute name="wp14:anchorId">
- <ref name="ST_EditId"/>
- </attribute>
+ <optional>
+ <attribute name="wp14:anchorId">
+ <ref name="ST_EditId"/>
+ </attribute>
+ </optional>
</define>
<define name="inline">
<element name="inline">
@@ -8347,7 +8354,7 @@
<attribute name="b" tokenid="ooxml:CT_EffectExtent_b"/>
</resource>
<resource name="ST_WrapDistance" resource="Integer" generated="yes"/>
- <resource xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="CT_Inline" resource="Properties" tag="shape">
+ <resource xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" name="CT_Inline" resource="Properties" tag="shape">
<element name="extent" tokenid="ooxml:CT_Inline_extent"/>
<element name="effectExtent" tokenid="ooxml:CT_Inline_effectExtent"/>
<element name="docPr" tokenid="ooxml:CT_Inline_docPr"/>
@@ -8359,6 +8366,7 @@
<attribute name="distB" tokenid="ooxml:CT_Inline_distB"/>
<attribute name="distL" tokenid="ooxml:CT_Inline_distL"/>
<attribute name="distR" tokenid="ooxml:CT_Inline_distR"/>
+ <attribute name="wp14:anchorId" tokenid="ooxml:CT_Inline_wp14_anchorId"/>
</resource>
<resource name="ST_WrapText" resource="List" generated="yes">
<value name="bothSides" tokenid="ooxml:Value_wordprocessingDrawing_ST_WrapText_bothSides">bothSides</value>
commit dd02b6021ed74d9ec6605fed53f30c52ec067687
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed Mar 5 19:13:21 2014 +0100
writerfilter: stylisticly improve GraphicImport.cxx/hxx
Use css instead of com::sun:star. Additionally use scoped_ptr for
GraphicImport_Impl instance.
Change-Id: I8ab1847cbe831f8989a758b561cc8e9fc3d322fd
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index d40b570..cd014c8 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -66,11 +66,10 @@ using resourcemodel::resolveSprmProps;
namespace dmapper
{
-using namespace ::std;
-using namespace ::com::sun::star;
+using namespace std;
+using namespace css;
-class XInputStreamHelper : public cppu::WeakImplHelper1
-< io::XInputStream >
+class XInputStreamHelper : public cppu::WeakImplHelper1<io::XInputStream>
{
const sal_uInt8* m_pBuffer;
const sal_Int32 m_nLength;
@@ -90,7 +89,6 @@ public:
virtual void SAL_CALL closeInput( ) throw (io::NotConnectedException, io::IOException, uno::RuntimeException, std::exception);
};
-
XInputStreamHelper::XInputStreamHelper(const sal_uInt8* buf, size_t len, bool bBmp) :
m_pBuffer( buf ),
m_nLength( len ),
@@ -101,7 +99,6 @@ XInputStreamHelper::XInputStreamHelper(const sal_uInt8* buf, size_t len, bool bB
{0x42, 0x4d, 0xe6, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 };
m_pBMPHeader = aHeader;
m_nHeaderLength = m_bBmp ? sizeof( aHeader ) / sizeof(sal_uInt8) : 0;
-
}
@@ -109,15 +106,13 @@ XInputStreamHelper::~XInputStreamHelper()
{
}
-
-::sal_Int32 XInputStreamHelper::readBytes( uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nBytesToRead )
+sal_Int32 XInputStreamHelper::readBytes( uno::Sequence<sal_Int8>& aData, sal_Int32 nBytesToRead )
throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException, std::exception)
{
return readSomeBytes( aData, nBytesToRead );
}
-
-::sal_Int32 XInputStreamHelper::readSomeBytes( uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nMaxBytesToRead )
+sal_Int32 XInputStreamHelper::readSomeBytes( uno::Sequence<sal_Int8>& aData, sal_Int32 nMaxBytesToRead )
throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException, std::exception)
{
sal_Int32 nRet = 0;
@@ -148,7 +143,7 @@ XInputStreamHelper::~XInputStreamHelper()
}
-void XInputStreamHelper::skipBytes( ::sal_Int32 nBytesToSkip ) throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException, std::exception)
+void XInputStreamHelper::skipBytes( sal_Int32 nBytesToSkip ) throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException, std::exception)
{
if( nBytesToSkip < 0 || m_nPosition + nBytesToSkip > (m_nLength + m_nHeaderLength))
throw io::BufferSizeExceededException();
@@ -156,7 +151,7 @@ void XInputStreamHelper::skipBytes( ::sal_Int32 nBytesToSkip ) throw (io::NotCon
}
-::sal_Int32 XInputStreamHelper::available( ) throw (io::NotConnectedException, io::IOException, uno::RuntimeException, std::exception)
+sal_Int32 XInputStreamHelper::available( ) throw (io::NotConnectedException, io::IOException, uno::RuntimeException, std::exception)
{
return ( m_nLength + m_nHeaderLength ) - m_nPosition;
}
@@ -318,7 +313,7 @@ public:
,bPositionProtected(false)
,nShapeOptionType(0)
,m_rPositivePercentages(rPositivePercentages)
- {}
+ {}
void setXSize(sal_Int32 _nXSize)
{
@@ -418,25 +413,22 @@ public:
}
};
-
-GraphicImport::GraphicImport(uno::Reference < uno::XComponentContext > xComponentContext,
- uno::Reference< lang::XMultiServiceFactory > xTextFactory,
+GraphicImport::GraphicImport(uno::Reference<uno::XComponentContext> xComponentContext,
+ uno::Reference<lang::XMultiServiceFactory> xTextFactory,
DomainMapper& rDMapper,
GraphicImportType eImportType,
std::queue<OUString>& rPositivePercentages)
: LoggedProperties(dmapper_logger, "GraphicImport")
, LoggedTable(dmapper_logger, "GraphicImport")
, LoggedStream(dmapper_logger, "GraphicImport")
-, m_pImpl( new GraphicImport_Impl( eImportType, rDMapper, rPositivePercentages ))
-, m_xComponentContext( xComponentContext )
-, m_xTextFactory( xTextFactory)
+, m_pImpl(new GraphicImport_Impl(eImportType, rDMapper, rPositivePercentages))
+, m_xComponentContext(xComponentContext)
+, m_xTextFactory(xTextFactory)
{
}
-
GraphicImport::~GraphicImport()
{
- delete m_pImpl;
}
void GraphicImport::handleWrapTextValue(sal_uInt32 nVal)
@@ -491,14 +483,14 @@ void GraphicImport::putPropertyToFrameGrabBag( const OUString& sPropertyName, co
}
}
-void GraphicImport::lcl_attribute(Id nName, Value & val)
+void GraphicImport::lcl_attribute(Id nName, Value& rValue)
{
- sal_Int32 nIntValue = val.getInt();
+ sal_Int32 nIntValue = rValue.getInt();
switch( nName )
{
case NS_ooxml::LN_blip: //the binary graphic data in a shape
{
- writerfilter::Reference<Properties>::Pointer_t pProperties = val.getProperties();
+ writerfilter::Reference<Properties>::Pointer_t pProperties = rValue.getProperties();
if( pProperties.get())
{
pProperties->resolve(*this);
@@ -507,7 +499,7 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
break;
case NS_ooxml::LN_payload :
{
- writerfilter::Reference<BinaryObj>::Pointer_t pPictureData = val.getBinary();
+ writerfilter::Reference<BinaryObj>::Pointer_t pPictureData = rValue.getBinary();
if( pPictureData.get())
pPictureData->resolve(*this);
}
@@ -549,15 +541,15 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
break;
case NS_ooxml::LN_CT_NonVisualDrawingProps_name:// 90651;
//name of the object
- m_pImpl->sName = val.getString();
+ m_pImpl->sName = rValue.getString();
break;
case NS_ooxml::LN_CT_NonVisualDrawingProps_descr:// 90652;
//alternative text
- m_pImpl->sAlternativeText = val.getString();
+ m_pImpl->sAlternativeText = rValue.getString();
break;
case NS_ooxml::LN_CT_NonVisualDrawingProps_title:
//alternative text
- m_pImpl->title = val.getString();
+ m_pImpl->title = rValue.getString();
break;
case NS_ooxml::LN_CT_GraphicalObjectFrameLocking_noChangeAspect://90644;
//disallow aspect ratio change - ignored
@@ -574,7 +566,7 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
case NS_ooxml::LN_CT_Anchor_distR: // 90986;
{
m_pImpl->nShapeOptionType = nName;
- ProcessShapeOptions(val);
+ ProcessShapeOptions(rValue);
}
break;
case NS_ooxml::LN_CT_Anchor_simplePos_attr: // 90987;
@@ -585,7 +577,7 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
break;
case NS_ooxml::LN_CT_Anchor_behindDoc: // 90989; - in background
if( nIntValue > 0 )
- m_pImpl->bOpaque = false;
+ m_pImpl->bOpaque = false;
break;
case NS_ooxml::LN_CT_Anchor_locked: // 90990; - ignored
case NS_ooxml::LN_CT_Anchor_layoutInCell: // 90991; - ignored
@@ -617,23 +609,23 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
m_pImpl->bContour = true;
m_pImpl->bContourOutside = true;
- handleWrapTextValue(val.getInt());
+ handleWrapTextValue(rValue.getInt());
break;
case NS_ooxml::LN_CT_WrapThrough_wrapText:
m_pImpl->bContour = true;
m_pImpl->bContourOutside = false;
- handleWrapTextValue(val.getInt());
+ handleWrapTextValue(rValue.getInt());
break;
case NS_ooxml::LN_CT_WrapSquare_wrapText: //90928;
- handleWrapTextValue(val.getInt());
+ handleWrapTextValue(rValue.getInt());
break;
case NS_ooxml::LN_shape:
{
uno::Reference< drawing::XShape> xShape;
- val.getAny( ) >>= xShape;
+ rValue.getAny( ) >>= xShape;
if ( xShape.is( ) )
{
@@ -794,7 +786,7 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
m_pImpl->nRightMargin = ConversionHelper::convertEMUToMM100(nIntValue);
break;
case NS_ooxml::LN_CT_GraphicalObjectData_uri:
- val.getString();
+ rValue.getString();
//TODO: does it need to be handled?
break;
case NS_ooxml::LN_CT_SizeRelH_relativeFrom:
@@ -867,14 +859,13 @@ uno::Reference<text::XTextContent> GraphicImport::GetGraphicObject()
return xResult;
}
-uno::Reference< ::com::sun::star::drawing::XShape> GraphicImport::GetXShapeObject(){
+uno::Reference<drawing::XShape> GraphicImport::GetXShapeObject(){
return m_xShape;
}
-
-void GraphicImport::ProcessShapeOptions(Value& val)
+void GraphicImport::ProcessShapeOptions(Value& rValue)
{
- sal_Int32 nIntValue = val.getInt();
+ sal_Int32 nIntValue = rValue.getInt();
switch( m_pImpl->nShapeOptionType )
{
case NS_ooxml::LN_CT_Anchor_distL:
@@ -899,7 +890,7 @@ void GraphicImport::ProcessShapeOptions(Value& val)
}
-void GraphicImport::lcl_sprm(Sprm & rSprm)
+void GraphicImport::lcl_sprm(Sprm& rSprm)
{
sal_uInt32 nSprmId = rSprm.getId();
Value::Pointer_t pValue = rSprm.getValue();
@@ -1052,11 +1043,10 @@ void GraphicImport::lcl_sprm(Sprm & rSprm)
sMessage += OString::number( nSprmId, 16 );
SAL_WARN("writerfilter", sMessage.getStr());
#endif
- ;
+ break;
}
}
-
void GraphicImport::lcl_entry(int /*pos*/, writerfilter::Reference<Properties>::Pointer_t /*ref*/)
{
}
@@ -1399,9 +1389,7 @@ void GraphicImport::lcl_endShape( )
{
}
-
-
-bool GraphicImport::IsGraphic() const
+bool GraphicImport::IsGraphic() const
{
return m_pImpl->bIsGraphic;
}
diff --git a/writerfilter/source/dmapper/GraphicImport.hxx b/writerfilter/source/dmapper/GraphicImport.hxx
index 52b0339..0e5b1fa 100644
--- a/writerfilter/source/dmapper/GraphicImport.hxx
+++ b/writerfilter/source/dmapper/GraphicImport.hxx
@@ -20,11 +20,13 @@
#define INCLUDED_GRAPHICIMPORT_HXX
#include <queue>
+#include <boost/scoped_ptr.hpp>
#include <resourcemodel/LoggedResources.hxx>
-namespace com{ namespace sun { namespace star {
- namespace uno{
+namespace com { namespace sun { namespace star {
+ namespace uno
+ {
class XComponentContext;
}
namespace lang
@@ -42,11 +44,12 @@ namespace com{ namespace sun { namespace star {
namespace beans
{
struct PropertyValue;
- typedef ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > PropertyValues;
+ typedef css::uno::Sequence< css::beans::PropertyValue > PropertyValues;
}
}}}
-namespace writerfilter {
+namespace writerfilter
+{
namespace dmapper
{
class GraphicImport_Impl;
@@ -63,34 +66,34 @@ enum GraphicImportType
class GraphicImport : public LoggedProperties, public LoggedTable
,public BinaryObj, public LoggedStream
{
- GraphicImport_Impl* m_pImpl;
- ::com::sun::star::uno::Reference < ::com::sun::star::uno::XComponentContext > m_xComponentContext;
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xTextFactory;
+ boost::scoped_ptr<GraphicImport_Impl> m_pImpl;
- ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > m_xGraphicObject;
+ css::uno::Reference<css::uno::XComponentContext> m_xComponentContext;
+ css::uno::Reference<css::lang::XMultiServiceFactory> m_xTextFactory;
- ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape> m_xShape;
+ css::uno::Reference<css::text::XTextContent> m_xGraphicObject;
+
+ css::uno::Reference<css::drawing::XShape> m_xShape;
void ProcessShapeOptions(Value & val);
- ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > createGraphicObject(
- const ::com::sun::star::beans::PropertyValues& aMediaProperties );
+ css::uno::Reference<css::text::XTextContent > createGraphicObject(const css::beans::PropertyValues& aMediaProperties );
void putPropertyToFrameGrabBag( const OUString& sPropertyName, const css::uno::Any& aPropertyValue );
public:
- explicit GraphicImport(::com::sun::star::uno::Reference < ::com::sun::star::uno::XComponentContext > xComponentContext,
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xTextFactory,
- DomainMapper& rDomainMapper,
- GraphicImportType eGraphicImportType,
- std::queue<OUString>& rPositivePercentages);
+ explicit GraphicImport( css::uno::Reference<css::uno::XComponentContext> xComponentContext,
+ css::uno::Reference<css::lang::XMultiServiceFactory> xTextFactory,
+ DomainMapper& rDomainMapper,
+ GraphicImportType eGraphicImportType,
+ std::queue<OUString>& rPositivePercentages);
virtual ~GraphicImport();
// BinaryObj
- virtual void data(const sal_uInt8* buf, size_t len, writerfilter::Reference<Properties>::Pointer_t ref);
+ virtual void data(const sal_uInt8* buffer, size_t len, writerfilter::Reference<Properties>::Pointer_t ref);
- ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > GetGraphicObject();
- ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape> GetXShapeObject();
- bool IsGraphic() const;
+ css::uno::Reference<css::text::XTextContent> GetGraphicObject();
+ css::uno::Reference<css::drawing::XShape> GetXShapeObject();
+ bool IsGraphic() const;
private:
// Properties
@@ -112,16 +115,16 @@ public:
virtual void lcl_props(writerfilter::Reference<Properties>::Pointer_t ref);
virtual void lcl_table(Id name,
writerfilter::Reference<Table>::Pointer_t ref);
- virtual void lcl_substream(Id name,
- ::writerfilter::Reference<Stream>::Pointer_t ref);
+ virtual void lcl_substream(Id name, writerfilter::Reference<Stream>::Pointer_t ref);
virtual void lcl_info(const string & info);
- virtual void lcl_startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
- virtual void lcl_endShape( );
+ virtual void lcl_startShape(css::uno::Reference<css::drawing::XShape> xShape);
+ virtual void lcl_endShape();
void handleWrapTextValue(sal_uInt32 nVal);
};
-typedef boost::shared_ptr< GraphicImport > GraphicImportPtr;
+typedef boost::shared_ptr<GraphicImport> GraphicImportPtr;
+
}}
#endif
commit e77f303a2d9d244c94764ec74daf6fb26a847bf6
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed Mar 5 18:55:10 2014 +0100
ooxml export: wp14:anchorId (DML) and w14:anchorId (VML)
If a FrameGrabBag contains an "AnchorId" property, write it to the
DML section as wp14:anchorId and to the VML section as w14:anchorId.
Change-Id: I632ae3630b7605c05d8df2e92ede9cbc39956318
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index 5ed1811..eeca450 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -47,6 +47,39 @@
using namespace com::sun::star;
using namespace oox;
+namespace
+{
+
+OUString lclGetAnchorIdFromGrabBag(const SdrObject* pObj)
+{
+ OUString aResult;
+ uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pObj)->getUnoShape(), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySetInfo> xPropSetInfo;
+
+ if (!xPropertySet.is())
+ return aResult;
+
+ xPropSetInfo = xPropertySet->getPropertySetInfo();
+ if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("FrameInteropGrabBag"))
+ {
+ uno::Sequence< beans::PropertyValue > propList;
+ xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList;
+ for (sal_Int32 nProp = 0; nProp < propList.getLength(); ++nProp)
+ {
+ OUString aPropName = propList[nProp].Name;
+ if (aPropName == "AnchorId")
+ {
+ propList[nProp].Value >>= aResult;
+ break;
+ }
+ }
+ }
+ return aResult;
+}
+
+}
+
ExportDataSaveRestore::ExportDataSaveRestore(DocxExport& rExport, sal_uLong nStt, sal_uLong nEnd, sw::Frame* pParentFrame)
: m_rExport(rExport)
{
@@ -223,11 +256,14 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrmFmt* pFrmFmt, const Size& rS
}
if (isAnchor)
{
- ::sax_fastparser::FastAttributeList* attrList = m_pImpl->m_pSerializer->createAttrList();
+ sax_fastparser::FastAttributeList* attrList = m_pImpl->m_pSerializer->createAttrList();
bool bOpaque = pFrmFmt->GetOpaque().GetValue();
- if (const SdrObject* pObj = pFrmFmt->FindRealSdrObject())
+ const SdrObject* pObj = pFrmFmt->FindRealSdrObject();
+ if (pObj != NULL)
+ {
// SdrObjects know their layer, consider that instead of the frame format.
bOpaque = pObj->GetLayer() != pFrmFmt->GetDoc()->GetHellId() && pObj->GetLayer() != pFrmFmt->GetDoc()->GetInvisibleHellId();
+ }
attrList->add(XML_behindDoc, bOpaque ? "0" : "1");
attrList->add(XML_distT, OString::number(TwipsToEMU(pULSpaceItem.GetUpper())).getStr());
attrList->add(XML_distB, OString::number(TwipsToEMU(pULSpaceItem.GetLower())).getStr());
@@ -237,12 +273,18 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrmFmt* pFrmFmt, const Size& rS
attrList->add(XML_locked, "0");
attrList->add(XML_layoutInCell, "1");
attrList->add(XML_allowOverlap, "1"); // TODO
- if (const SdrObject* pObj = pFrmFmt->FindRealSdrObject())
+ if (pObj != NULL)
// It seems 0 and 1 have special meaning: just start counting from 2 to avoid issues with that.
attrList->add(XML_relativeHeight, OString::number(pObj->GetOrdNum() + 2));
else
// relativeHeight is mandatory attribute, if value is not present, we must write default value
attrList->add(XML_relativeHeight, "0");
+ if (pObj != NULL)
+ {
+ OUString sAnchorId = lclGetAnchorIdFromGrabBag(pObj);
+ if (!sAnchorId.isEmpty())
+ attrList->addNS(XML_wp14, XML_anchorId, OUStringToOString(sAnchorId, RTL_TEXTENCODING_UTF8));
+ }
sax_fastparser::XFastAttributeListRef xAttrList(attrList);
m_pImpl->m_pSerializer->startElementNS(XML_wp, XML_anchor, xAttrList);
m_pImpl->m_pSerializer->singleElementNS(XML_wp, XML_simplePos, XML_x, "0", XML_y, "0", FSEND); // required, unused
@@ -1130,6 +1172,15 @@ void DocxSdrExport::writeVMLTextFrame(sw::Frame* pParentFrame)
m_pImpl->m_aTextFrameStyle = "position:absolute";
m_pImpl->m_rExport.OutputFormat(pParentFrame->GetFrmFmt(), false, false, true);
m_pImpl->m_pFlyAttrList->add(XML_style, m_pImpl->m_aTextFrameStyle.makeStringAndClear());
+
+ const SdrObject* pObject = pParentFrame->GetFrmFmt().FindRealSdrObject();
+ if (pObject != NULL)
+ {
+ OUString sAnchorId = lclGetAnchorIdFromGrabBag(pObject);
+ if(!sAnchorId.isEmpty())
+ m_pImpl->m_pFlyAttrList->addNS(XML_w14, XML_anchorId, OUStringToOString(sAnchorId, RTL_TEXTENCODING_UTF8));
+ }
+
sax_fastparser::XFastAttributeListRef xFlyAttrList(m_pImpl->m_pFlyAttrList);
m_pImpl->m_pFlyAttrList = NULL;
m_pImpl->m_bFrameBtLr = checkFrameBtlr(m_pImpl->m_rExport.pDoc->GetNodes()[nStt], m_pImpl->m_pTextboxAttrList);
commit 693f1dee0b994b92d1256cdd9a82f642d0c3b5cd
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed Mar 5 18:46:37 2014 +0100
sax: FastAttributeList - add attribute in a specific namespace
This change is inspired by startElementNS & singleElementNS which
have namespace as first parameter to define the namespace of an
element. Some attributes of a element can be in different namespace
but until now FastAttributeList "add" method did not have a namespace
parameter. This commit adds "addNS" which accepts namespace as a
first parameter.
Change-Id: Iebf8b5e890c17f00a56923efc3506580eed070a9
diff --git a/include/sax/fastattribs.hxx b/include/sax/fastattribs.hxx
index 71bd467..29ed1f9 100644
--- a/include/sax/fastattribs.hxx
+++ b/include/sax/fastattribs.hxx
@@ -80,6 +80,7 @@ public:
void clear();
void add( sal_Int32 nToken, const sal_Char* pValue, size_t nValueLength = 0 );
void add( sal_Int32 nToken, const OString& rValue );
+ void addNS( sal_Int32 nNamespaceToken, sal_Int32 nToken, const OString& rValue );
void addUnknown( const OUString& rNamespaceURL, const OString& rName, const sal_Char* pValue );
void addUnknown( const OString& rName, const sal_Char* pValue );
diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index 03880de..e3df6b1 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -97,6 +97,12 @@ void FastAttributeList::add( sal_Int32 nToken, const OString& rValue )
add( nToken, rValue.getStr(), rValue.getLength() );
}
+void FastAttributeList::addNS( sal_Int32 nNamespaceToken, sal_Int32 nToken, const OString& rValue )
+{
+ sal_Int32 nCombinedToken = (nNamespaceToken << 16) | nToken;
+ add( nCombinedToken, rValue );
+}
+
void FastAttributeList::addUnknown( const OUString& rNamespaceURL, const OString& rName, const sal_Char* pValue )
{
maUnknownAttributes.push_back( UnknownAttribute( rNamespaceURL, rName, pValue ) );
commit 7452e530c01193de2dedf54b2f91e797f341f19e
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed Mar 5 18:44:52 2014 +0100
oox & writerfilter: add "anchorId" token and update model.xml
Change-Id: Ibcbf552621b8c6c5c143521a697026cdeac90706
diff --git a/oox/source/token/tokens.txt b/oox/source/token/tokens.txt
index ff5466c..84f28c1 100644
--- a/oox/source/token/tokens.txt
+++ b/oox/source/token/tokens.txt
@@ -563,6 +563,7 @@ alwaysShowPlaceholderText
amt
anchor
anchorCtr
+anchorId
anchorLock
anchorlock
anchorx
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index f10bb00..bb63221 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -8196,7 +8196,7 @@
</choice>
</list>
</define>
- <define name="ST_LongHexNumber">
+ <define name="ST_EditId">
<data type="hexBinary">
<param name="length">4</param>
</data>
@@ -8326,7 +8326,7 @@
<xs:documentation>Allow Objects to Overlap</xs:documentation>
</attribute>
<attribute name="wp14:anchorId">
- <ref name="ST_LongHexNumber"/>
+ <ref name="ST_EditId"/>
</attribute>
</define>
<define name="inline">
@@ -8443,7 +8443,7 @@
<element name="posOffset" tokenid="ooxml:CT_PosV_posOffset"/>
<attribute name="relativeFrom" tokenid="ooxml:CT_PosV_relativeFrom"/>
</resource>
- <resource name="ST_LongHexNumber" resource="Hex"/>
+ <resource name="ST_EditId" resource="Hex"/>
<resource xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" name="CT_Anchor" resource="Properties" tag="shape">
<element name="simplePos" tokenid="ooxml:CT_Anchor_simplePos_elem"/>
<element name="positionH" tokenid="ooxml:CT_Anchor_positionH"/>
commit ca6e60d4c014e7471acc7a7601148fe751634f27
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed Mar 5 18:43:04 2014 +0100
writerfilter: handle anchorId and put it into the FrameGrabBag
Change-Id: I44f9a1f5b5d65ebdabd5f6d1e8d87bfadb66d664
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index f22d323..d40b570 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -44,6 +44,9 @@
#include <cppuhelper/implbase1.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/math.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <comphelper/string.hxx>
+
#include <oox/drawingml/drawingmltypes.hxx>
#include <dmapper/DomainMapper.hxx>
@@ -258,6 +261,7 @@ public:
OUString sAlternativeText;
OUString title;
std::queue<OUString>& m_rPositivePercentages;
+ OUString sAnchorId;
GraphicImport_Impl(GraphicImportType eImportType, DomainMapper& rDMapper, std::queue<OUString>& rPositivePercentages) :
nXSize(0)
@@ -455,7 +459,37 @@ void GraphicImport::handleWrapTextValue(sal_uInt32 nVal)
}
}
+void GraphicImport::putPropertyToFrameGrabBag( const OUString& sPropertyName, const uno::Any& aPropertyValue )
+{
+ beans::PropertyValue pProperty;
+ pProperty.Name = sPropertyName;
+ pProperty.Value = aPropertyValue;
+
+ if (!m_xShape.is())
+ return;
+
+ uno::Reference< beans::XPropertySet > xSet(m_xShape, uno::UNO_QUERY_THROW);
+ if (!xSet.is())
+ return;
+
+ uno::Reference< beans::XPropertySetInfo > xSetInfo(xSet->getPropertySetInfo());
+ if (!xSetInfo.is())
+ return;
+
+ const OUString& aGrabBagPropName = OUString("FrameInteropGrabBag");
+
+ if (xSetInfo->hasPropertyByName(aGrabBagPropName))
+ {
+ uno::Sequence< beans::PropertyValue > aGrabBag;
+ xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
+
+ sal_Int32 nLength = aGrabBag.getLength();
+ aGrabBag.realloc(nLength + 1);
+ aGrabBag[nLength] = pProperty;
+ xSet->setPropertyValue(aGrabBagPropName, uno::makeAny(aGrabBag));
+ }
+}
void GraphicImport::lcl_attribute(Id nName, Value & val)
{
@@ -560,6 +594,15 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
case NS_ooxml::LN_CT_Anchor_allowOverlap: // 90993;
//enable overlapping - ignored
break;
+ case NS_ooxml::LN_CT_Anchor_wp14_anchorId:
+ {
+ OUStringBuffer aBuffer = OUString::number(nIntValue, 16);
+ OUStringBuffer aString;
+ comphelper::string::padToLength(aString, 8 - aBuffer.getLength(), '0');
+ aString.append(aBuffer.getStr());
+ m_pImpl->sAnchorId = aString.makeStringAndClear().toAsciiUpperCase();
+ }
+ break;
case NS_ooxml::LN_CT_Point2D_x: // 90405;
m_pImpl->nLeftPosition = ConversionHelper::convertTwipToMM100(nIntValue);
m_pImpl->nHoriRelation = text::RelOrientation::PAGE_FRAME;
@@ -702,6 +745,11 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
xShapeProps->setPropertyValue("RotateAngle", aRotation);
m_pImpl->bIsGraphic = true;
+
+ if (!m_pImpl->sAnchorId.isEmpty())
+ {
+ putPropertyToFrameGrabBag("AnchorId", uno::makeAny(m_pImpl->sAnchorId));
+ }
}
if (bUseShape && m_pImpl->eGraphicImportType == IMPORT_AS_DETECTED_ANCHOR)
@@ -801,7 +849,7 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
#ifdef DEBUG_DMAPPER_GRAPHIC_IMPORT
dmapper_logger->element("unhandled");
#endif
- ;
+ break;
}
}
diff --git a/writerfilter/source/dmapper/GraphicImport.hxx b/writerfilter/source/dmapper/GraphicImport.hxx
index 56c9680..52b0339 100644
--- a/writerfilter/source/dmapper/GraphicImport.hxx
+++ b/writerfilter/source/dmapper/GraphicImport.hxx
@@ -75,6 +75,8 @@ class GraphicImport : public LoggedProperties, public LoggedTable
::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > createGraphicObject(
const ::com::sun::star::beans::PropertyValues& aMediaProperties );
+ void putPropertyToFrameGrabBag( const OUString& sPropertyName, const css::uno::Any& aPropertyValue );
+
public:
explicit GraphicImport(::com::sun::star::uno::Reference < ::com::sun::star::uno::XComponentContext > xComponentContext,
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xTextFactory,
commit 85b7de13f8a8417a9dd642fe00569c45c5907a1a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed Mar 5 17:59:51 2014 +0100
writerfilter: add reading of wp14:anchorId
Change-Id: Iae9a45b9de4f55585daf10786947f578d895cc75
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index fe6aaf2..f10bb00 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -8196,6 +8196,11 @@
</choice>
</list>
</define>
+ <define name="ST_LongHexNumber">
+ <data type="hexBinary">
+ <param name="length">4</param>
+ </data>
+ </define>
<define name="CT_PosV">
<choice>
<element name="align">
@@ -8320,6 +8325,9 @@
</data>
<xs:documentation>Allow Objects to Overlap</xs:documentation>
</attribute>
+ <attribute name="wp14:anchorId">
+ <ref name="ST_LongHexNumber"/>
+ </attribute>
</define>
<define name="inline">
<element name="inline">
@@ -8435,6 +8443,7 @@
<element name="posOffset" tokenid="ooxml:CT_PosV_posOffset"/>
<attribute name="relativeFrom" tokenid="ooxml:CT_PosV_relativeFrom"/>
</resource>
+ <resource name="ST_LongHexNumber" resource="Hex"/>
<resource xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" name="CT_Anchor" resource="Properties" tag="shape">
<element name="simplePos" tokenid="ooxml:CT_Anchor_simplePos_elem"/>
<element name="positionH" tokenid="ooxml:CT_Anchor_positionH"/>
@@ -8456,6 +8465,7 @@
<attribute name="layoutInCell" tokenid="ooxml:CT_Anchor_layoutInCell"/>
<attribute name="hidden" tokenid="ooxml:CT_Anchor_hidden"/>
<attribute name="allowOverlap" tokenid="ooxml:CT_Anchor_allowOverlap"/>
+ <attribute name="wp14:anchorId" tokenid="ooxml:CT_Anchor_wp14_anchorId"/>
</resource>
<resource name="inline" resource="Properties" tag="shape">
<element name="inline" tokenid="ooxml:inline_inline"/>
More information about the Libreoffice-commits
mailing list