Message info
 
To:libreoffice-commits@lists.freedesktop.org From:Lubos Lunak Subject:[Libreoffice-commits] .: 7 commits - sax/source sw/source writerfilter/source Date:Thu, 12 Apr 2012 08:11:54 -0700 (PDT)
 

sax/source/tools/fastserializer.cxx | 2 +
sw/source/filter/ww8/docxattributeoutput.cxx | 35 ++++++++++++++++----------
sw/source/filter/ww8/docxattributeoutput.hxx | 1
writerfilter/source/dmapper/GraphicImport.cxx | 9 +++++-
writerfilter/source/ooxml/model.xml | 9 ++++++
5 files changed, 42 insertions(+), 14 deletions(-)

New commits:
commit b950cf552f794a154f4576ec534513fe696d6e65
Author: Luboš Luňák <l.lunak@suse.cz>
Date: Wed Apr 11 16:43:40 2012 +0200

write out unique id for wp:docPr

"If multiple objects within the same document share the same id attribute value, then the
document shall be considered non-conformant." . Although it apparently does not matter
much in practice.

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 32773cc..4b918fd 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2104,7 +2104,7 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size
}
// picture description
::sax_fastparser::FastAttributeList* attrList = m_pSerializer->createAttrList();
- attrList->add( XML_id, "1" );
+ attrList->add( XML_id, OString::valueOf( m_anchorId++ ).getStr());
attrList->add( XML_name, "Picture" );
attrList->add( XML_descr, OUStringToOString( rGrfNode.GetDescription(), RTL_TEXTENCODING_UTF8 ).getStr());
if( GetExport().GetFilter().getVersion( ) != oox::core::ECMA_DIALECT )
@@ -4369,7 +4369,8 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri
m_closeHyperlinkInPreviousRun( false ),
m_postponedGraphic( NULL ),
m_postponedMath( NULL ),
- m_postitFieldsMaxId( 0 )
+ m_postitFieldsMaxId( 0 ),
+ m_anchorId( 0 )
{
}

diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 79c8b02..11b8cee 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -601,6 +601,7 @@ private:
const SwOLENode* m_postponedMath;
std::vector< const SwPostItField* > m_postitFields;
unsigned int m_postitFieldsMaxId;
+ int m_anchorId;

public:
DocxAttributeOutput( DocxExport &rExport, ::sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML );
commit 1820f9f272bc478f79819767ddeb34644e334405
Author: Luboš Luňák <l.lunak@suse.cz>
Date: Wed Apr 11 16:37:41 2012 +0200

wp:anchor attributes do not have w: prefix

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index f4899fa..32773cc 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2016,17 +2016,17 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size
if( isAnchor )
{
::sax_fastparser::FastAttributeList* attrList = m_pSerializer->createAttrList();
- attrList->add( FSNS( XML_w, XML_behindDoc ), rGrfNode.GetFlyFmt()->GetOpaque().GetValue() ? "0" : "1" );
- attrList->add( FSNS( XML_w, XML_distT ), "0" );
- attrList->add( FSNS( XML_w, XML_distB ), "0" );
- attrList->add( FSNS( XML_w, XML_distL ), "0" );
- attrList->add( FSNS( XML_w, XML_distR ), "0" );
- attrList->add( FSNS( XML_w, XML_simplePos ), "0" );
- attrList->add( FSNS( XML_w, XML_locked ), "0" );
- attrList->add( FSNS( XML_w, XML_layoutInCell ), "1" );
- attrList->add( FSNS( XML_w, XML_allowOverlap ), "1" ); // TODO
+ attrList->add( XML_behindDoc, rGrfNode.GetFlyFmt()->GetOpaque().GetValue() ? "0" : "1" );
+ attrList->add( XML_distT, "0" );
+ attrList->add( XML_distB, "0" );
+ attrList->add( XML_distL, "0" );
+ attrList->add( XML_distR, "0" );
+ attrList->add( XML_simplePos, "0" );
+ attrList->add( XML_locked, "0" );
+ attrList->add( XML_layoutInCell, "1" );
+ attrList->add( XML_allowOverlap, "1" ); // TODO
if( const SdrObject* pObj = rGrfNode.GetFlyFmt()->FindRealSdrObject())
- attrList->add( FSNS( XML_w, XML_relativeHeight ), OString::valueOf( sal_Int32( pObj->GetOrdNum())));
+ attrList->add( XML_relativeHeight, OString::valueOf( sal_Int32( pObj->GetOrdNum())));
m_pSerializer->startElementNS( XML_wp, XML_anchor, XFastAttributeListRef( attrList ));
m_pSerializer->singleElementNS( XML_wp, XML_simplePos, XML_x, "0", XML_y, "0", FSEND ); // required, unused
const char* relativeFromH;
commit 57951b30df91d36fb0d0a4abae2573201554e716
Author: Luboš Luňák <l.lunak@suse.cz>
Date: Wed Apr 11 16:37:17 2012 +0200

wp:docPr title is not in ecma

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 30d24b8..f4899fa 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2103,12 +2103,13 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size
}
}
// picture description
- m_pSerializer->startElementNS( XML_wp, XML_docPr,
- XML_id, "1",
- XML_name, "Picture",
- XML_title, OUStringToOString( rGrfNode.GetTitle(), RTL_TEXTENCODING_UTF8 ).getStr(),
- XML_descr, OUStringToOString( rGrfNode.GetDescription(), RTL_TEXTENCODING_UTF8 ).getStr(),
- FSEND );
+ ::sax_fastparser::FastAttributeList* attrList = m_pSerializer->createAttrList();
+ attrList->add( XML_id, "1" );
+ attrList->add( XML_name, "Picture" );
+ attrList->add( XML_descr, OUStringToOString( rGrfNode.GetDescription(), RTL_TEXTENCODING_UTF8 ).getStr());
+ if( GetExport().GetFilter().getVersion( ) != oox::core::ECMA_DIALECT )
+ attrList->add( XML_title, OUStringToOString( rGrfNode.GetTitle(), RTL_TEXTENCODING_UTF8 ).getStr());
+ m_pSerializer->startElementNS( XML_wp, XML_docPr, XFastAttributeListRef( attrList ));
// TODO hyperlink
// m_pSerializer->singleElementNS( XML_a, XML_hlinkClick,
// FSNS( XML_xmlns, XML_a ), "http://schemas.openxmlformats.org/drawingml/2006/main",
commit 1018d69bdada22e5cd8d9fa246c54fcd9feb7c6c
Author: Luboš Luňák <l.lunak@suse.cz>
Date: Wed Apr 11 16:14:35 2012 +0200

escape \n and \r too in escapeXml()

diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx
index e3d7e91..b5bc636 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -105,6 +105,8 @@ namespace sax_fastparser {
case '&': sBuf.appendAscii( "&" ); break;
case '\'': sBuf.appendAscii( "'" ); break;
case '"': sBuf.appendAscii( """ ); break;
+ case '\n': sBuf.appendAscii( " " ); break;
+ case '\r': sBuf.appendAscii( " " ); break;
default: sBuf.append( c ); break;
}
}
commit c4fbb0360889ded44ccbade8bb893eac5f1fbd2f
Author: Luboš Luňák <l.lunak@suse.cz>
Date: Wed Apr 11 16:05:00 2012 +0200

implement wp:docPr title and fix descr

diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 959f521..1d7d632 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -256,6 +256,7 @@ public:

::rtl::OUString sName;
::rtl::OUString sAlternativeText;
+ ::rtl::OUString title;

GraphicImport_Impl(GraphicImportType eImportType, DomainMapper& rDMapper) :
nXSize(0)
@@ -791,6 +792,10 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
//alternative text
m_pImpl->sAlternativeText = val.getString();
break;
+ case NS_ooxml::LN_CT_NonVisualDrawingProps_title:
+ //alternative text
+ m_pImpl->title = val.getString();
+ break;
case NS_ooxml::LN_CT_GraphicalObjectFrameLocking_noChangeAspect://90644;
//disallow aspect ratio change - ignored
break;
@@ -1318,8 +1323,10 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b
}

// setting properties for all types
- xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_TITLE ),
+ xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_DESCRIPTION ),
uno::makeAny( m_pImpl->sAlternativeText ));
+ xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_TITLE ),
+ uno::makeAny( m_pImpl->title ));
if( m_pImpl->bPositionProtected )
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_POSITION_PROTECTED ),
uno::makeAny(true));
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 98f35a1..f95112e 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -5009,6 +5009,14 @@
<xs:documentation>Hidden</xs:documentation>
</attribute>
</optional>
+ <optional>
+ <attribute name="title">
+ <data type="string">
+ <xs:documentation>Title</xs:documentation>
+ </data>
+ <xs:documentation>Title</xs:documentation>
+ </attribute>
+ </optional>
</define>
<define name="CT_NonVisualDrawingShapeProps">
<group>
@@ -5118,6 +5126,7 @@
<attribute name="name" tokenid="ooxml:CT_NonVisualDrawingProps_name"/>
<attribute name="descr" tokenid="ooxml:CT_NonVisualDrawingProps_descr"/>
<attribute name="hidden" tokenid="ooxml:CT_NonVisualDrawingProps_hidden"/>
+ <attribute name="title" tokenid="ooxml:CT_NonVisualDrawingProps_title"/>
</resource>
<resource name="CT_NonVisualPictureProperties" resource="Properties" tag="shape">
<element name="picLocks" tokenid="ooxml:CT_NonVisualPictureProperties_picLocks"/>
commit 835cea6bea0b4a1783d8e50f9b0ca1abe5cd3701
Author: Luboš Luňák <l.lunak@suse.cz>
Date: Wed Apr 11 15:55:18 2012 +0200

write proper title and description for wp:docPr

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index ae25879..30d24b8 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2103,11 +2103,11 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size
}
}
// picture description
- // TODO the right image description
m_pSerializer->startElementNS( XML_wp, XML_docPr,
XML_id, "1",
XML_name, "Picture",
- XML_descr, "A description...",
+ XML_title, OUStringToOString( rGrfNode.GetTitle(), RTL_TEXTENCODING_UTF8 ).getStr(),
+ XML_descr, OUStringToOString( rGrfNode.GetDescription(), RTL_TEXTENCODING_UTF8 ).getStr(),
FSEND );
// TODO hyperlink
// m_pSerializer->singleElementNS( XML_a, XML_hlinkClick,
commit 88a8c0891474a4936a67bcd119ff968369a93869
Author: Luboš Luňák <l.lunak@suse.cz>
Date: Wed Apr 11 12:05:34 2012 +0200

write w:relativeHeight

the z-order is actually already implied by the order the items are written,
but why not

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index ba2420f..ae25879 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2015,12 +2015,19 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size
bool isAnchor = rGrfNode.GetFlyFmt()->GetAnchor().GetAnchorId() != FLY_AS_CHAR;
if( isAnchor )
{
- m_pSerializer->startElementNS( XML_wp, XML_anchor,
- XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0", XML_simplePos, "0",
- XML_relativeHeight, "0", // TODO
- XML_behindDoc, rGrfNode.GetFlyFmt()->GetOpaque().GetValue() ? "0" : "1",
- XML_locked, "0", XML_layoutInCell, "1", XML_allowOverlap, "1", // TODO
- FSEND );
+ ::sax_fastparser::FastAttributeList* attrList = m_pSerializer->createAttrList();
+ attrList->add( FSNS( XML_w, XML_behindDoc ), rGrfNode.GetFlyFmt()->GetOpaque().GetValue() ? "0" : "1" );
+ attrList->add( FSNS( XML_w, XML_distT ), "0" );
+ attrList->add( FSNS( XML_w, XML_distB ), "0" );
+ attrList->add( FSNS( XML_w, XML_distL ), "0" );
+ attrList->add( FSNS( XML_w, XML_distR ), "0" );
+ attrList->add( FSNS( XML_w, XML_simplePos ), "0" );
+ attrList->add( FSNS( XML_w, XML_locked ), "0" );
+ attrList->add( FSNS( XML_w, XML_layoutInCell ), "1" );
+ attrList->add( FSNS( XML_w, XML_allowOverlap ), "1" ); // TODO
+ if( const SdrObject* pObj = rGrfNode.GetFlyFmt()->FindRealSdrObject())
+ attrList->add( FSNS( XML_w, XML_relativeHeight ), OString::valueOf( sal_Int32( pObj->GetOrdNum())));
+ m_pSerializer->startElementNS( XML_wp, XML_anchor, XFastAttributeListRef( attrList ));
m_pSerializer->singleElementNS( XML_wp, XML_simplePos, XML_x, "0", XML_y, "0", FSEND ); // required, unused
const char* relativeFromH;
const char* relativeFromV;