[Libreoffice-commits] .: oox/inc oox/source writerfilter/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Thu Jun 21 06:08:26 PDT 2012


 oox/inc/oox/vml/vmlshape.hxx                          |    2 ++
 oox/source/vml/vmlshape.cxx                           |   14 ++++++++++----
 oox/source/vml/vmlshapecontext.cxx                    |    7 +++++++
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |    7 ++++++-
 4 files changed, 25 insertions(+), 5 deletions(-)

New commits:
commit f837c4288cdae4921b3fb6747ba2e2cd5ce2dcd2
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Jun 21 15:02:47 2012 +0200

    n#758883 oox: anchor vml shapes without anchor info as at-character
    
    w10:wrap was originally arrived to
    writerfilter::dmapper::WrapHandler::lcl_attribute(), but
    writerfilter::dmapper::DomainMapper_Impl::PushShapeContext() was called
    already and set the anchor type. Fix this, then we can set a a suitable
    anchor type in lcl_SetAnchorType() based on the type model.
    
    Change-Id: Ib411450b10f29f814bc13d81eaec434971b2e52a

diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx
index abd91b6..0400964 100644
--- a/oox/inc/oox/vml/vmlshape.hxx
+++ b/oox/inc/oox/vml/vmlshape.hxx
@@ -92,6 +92,8 @@ struct ShapeTypeModel
 
     OptValue< ::rtl::OUString > moGraphicPath;  ///< Path to a graphic for this shape.
     OptValue< ::rtl::OUString > moGraphicTitle; ///< Title of the graphic.
+    OptValue< ::rtl::OUString > moWrapAnchorX;  ///< The base object from which our horizontal positioning should be calculated.
+    OptValue< ::rtl::OUString > moWrapAnchorY;  ///< The base object from which our vertical positioning should be calculated.
 
     explicit            ShapeTypeModel();
 
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 4f0f952..3637385 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -385,10 +385,16 @@ void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel)
 {
     if ( rTypeModel.maPosition == "absolute" )
     {
-        // I'm not sure if AT_PAGE is always correct here (not sure what the parent that
-        // the spec talks about can be), but with Writer SwXDrawPage::add()
-        // always in practice uses this because of pDoc->GetCurrentLayout() being NULL at this point.
-        rPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AT_PAGE);
+        if (rTypeModel.moWrapAnchorX.get() == "page" && rTypeModel.moWrapAnchorY.get() == "page")
+        {
+            // I'm not sure if AT_PAGE is always correct here (not sure what the parent that
+            // the spec talks about can be), but with Writer SwXDrawPage::add()
+            // always in practice uses this because of pDoc->GetCurrentLayout() being NULL at this point.
+            rPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AT_PAGE);
+        }
+        else
+            // Map to as-character by default, that fixes vertical position of some textframes.
+            rPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AT_CHARACTER);
     }
     else if( rTypeModel.maPosition == "relative" )
     {   // I'm not very sure this is correct either.
diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx
index 290a737..98e759d 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -322,11 +322,18 @@ ContextHandlerRef ShapeTypeContext::onCreateContext( sal_Int32 nElement, const A
             mrTypeModel.maFillModel.moRotate = lclDecodeBool( rAttribs, XML_rotate );
         break;
         case VML_TOKEN( imagedata ):
+        {
             // shapes in docx use r:id for the relationship id
             // in xlsx it they use o:relid
             bool bHasORelId = rAttribs.hasAttribute( O_TOKEN( relid ) );
             mrTypeModel.moGraphicPath = decodeFragmentPath( rAttribs, bHasORelId ? O_TOKEN( relid ) : R_TOKEN( id ) );
             mrTypeModel.moGraphicTitle = rAttribs.getString( O_TOKEN( title ) );
+        }
+        break;
+        case NMSP_vmlWord | XML_wrap:
+            mrTypeModel.moWrapAnchorX = rAttribs.getString(XML_anchorx);
+            mrTypeModel.moWrapAnchorY = rAttribs.getString(XML_anchory);
+        break;
         break;
     }
     return 0;
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 0724c65..6efa44c 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -2241,7 +2241,12 @@ OOXMLFastContextHandlerWrapper::lcl_createFastChildContext
 
     bool bInNamespaces = mMyNamespaces.find(nNameSpace) != mMyNamespaces.end();
     bool bInTokens = mMyTokens.find( Element ) != mMyTokens.end( );
-    if ( bInNamespaces )
+
+    // We have methods to _add_ individual tokens or whole namespaces to be
+    // processed by writerfilter (instead of oox), but we have no method to
+    // filter out a single token. Just hardwire the wrap token here till we
+    // need a more generic solution.
+    if ( bInNamespaces && Element != static_cast<sal_Int32>(NS_vml_wordprocessingDrawing | OOXML_wrap) )
         xResult.set(OOXMLFactory::getInstance()->createFastChildContextFromStart(this, Element));
     else if (mxContext.is())
     {


More information about the Libreoffice-commits mailing list