[Libreoffice-commits] core.git: sw/qa sw/source xmloff/source

Miklos Vajna vmiklos at collabora.co.uk
Sat Oct 4 11:18:38 PDT 2014


 sw/qa/extras/odfexport/data/textbox-rounded-corners.odt |binary
 sw/qa/extras/uiwriter/data/fdo82191.odt                 |binary
 sw/qa/extras/uiwriter/data/shape-textbox-autosize.odt   |binary
 sw/qa/extras/uiwriter/data/shape-textbox-vertadjust.odt |binary
 sw/qa/extras/uiwriter/data/shape-textbox.odt            |binary
 sw/source/core/doc/textboxhelper.cxx                    |    1 
 xmloff/source/draw/sdpropls.cxx                         |    4 -
 xmloff/source/draw/shapeexport.cxx                      |   13 +++++
 xmloff/source/draw/ximpshap.cxx                         |   37 ++++++++++++----
 9 files changed, 42 insertions(+), 13 deletions(-)

New commits:
commit 9835a5823e0f559aabbc0e15ea126c82229c4bc7
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Sat Oct 4 19:37:55 2014 +0200

    sw textboxes: reimplement ODF import/export
    
    Turns out that for normal TextFrames and rectangular drawinglayer
    shapes, the engine is written in ODF implicitly. Use the same trick to
    describe if the shape content should be rendered by SW or editeng.
    
    This reverts 9d310ecfce3c2fc481b125e1493a534e2107a68e (sw textboxes:
    implement ODF import/export, 2014-06-02).
    
    Change-Id: Id8afa6368bedcd293e578244abb58e18949bec8d

diff --git a/sw/qa/extras/odfexport/data/textbox-rounded-corners.odt b/sw/qa/extras/odfexport/data/textbox-rounded-corners.odt
index 3851850..add7512 100644
Binary files a/sw/qa/extras/odfexport/data/textbox-rounded-corners.odt and b/sw/qa/extras/odfexport/data/textbox-rounded-corners.odt differ
diff --git a/sw/qa/extras/uiwriter/data/fdo82191.odt b/sw/qa/extras/uiwriter/data/fdo82191.odt
index d0759c0..e341058 100644
Binary files a/sw/qa/extras/uiwriter/data/fdo82191.odt and b/sw/qa/extras/uiwriter/data/fdo82191.odt differ
diff --git a/sw/qa/extras/uiwriter/data/shape-textbox-autosize.odt b/sw/qa/extras/uiwriter/data/shape-textbox-autosize.odt
index 8877c72..1d2c866 100644
Binary files a/sw/qa/extras/uiwriter/data/shape-textbox-autosize.odt and b/sw/qa/extras/uiwriter/data/shape-textbox-autosize.odt differ
diff --git a/sw/qa/extras/uiwriter/data/shape-textbox-vertadjust.odt b/sw/qa/extras/uiwriter/data/shape-textbox-vertadjust.odt
index dfb26bf..f5fabcf 100644
Binary files a/sw/qa/extras/uiwriter/data/shape-textbox-vertadjust.odt and b/sw/qa/extras/uiwriter/data/shape-textbox-vertadjust.odt differ
diff --git a/sw/qa/extras/uiwriter/data/shape-textbox.odt b/sw/qa/extras/uiwriter/data/shape-textbox.odt
index 0fe0e9b..5f278af 100644
Binary files a/sw/qa/extras/uiwriter/data/shape-textbox.odt and b/sw/qa/extras/uiwriter/data/shape-textbox.odt differ
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index d003983..6554588 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -97,6 +97,7 @@ void SwTextBoxHelper::create(SwFrmFmt* pShape)
         syncProperty(pShape, RES_HORI_ORIENT, MID_HORIORIENT_POSITION, xShapePropertySet->getPropertyValue(UNO_NAME_HORI_ORIENT_POSITION));
         syncProperty(pShape, RES_VERT_ORIENT, MID_VERTORIENT_POSITION, xShapePropertySet->getPropertyValue(UNO_NAME_VERT_ORIENT_POSITION));
         syncProperty(pShape, RES_FRM_SIZE, MID_FRMSIZE_IS_AUTO_HEIGHT, xShapePropertySet->getPropertyValue(UNO_NAME_TEXT_AUTOGROWHEIGHT));
+        syncProperty(pShape, RES_TEXT_VERT_ADJUST, 0, xShapePropertySet->getPropertyValue(UNO_NAME_TEXT_VERT_ADJUST));
     }
 }
 
diff --git a/xmloff/source/draw/sdpropls.cxx b/xmloff/source/draw/sdpropls.cxx
index f24bd7e6..6df5827 100644
--- a/xmloff/source/draw/sdpropls.cxx
+++ b/xmloff/source/draw/sdpropls.cxx
@@ -80,8 +80,6 @@ using namespace ::xmloff::token;
 #define TMAP(name,prefix,token,type,context) _MAP(name,prefix,token,type|XML_TYPE_PROP_TEXT,context)
 #define PMAP(name,prefix,token,type,context) _MAP(name,prefix,token,type|XML_TYPE_PROP_PARAGRAPH,context)
 #define MAP_END() { 0L, 0, 0, XML_EMPTY, 0 ,0, SvtSaveOptions::ODFVER_010, false }
-// extensions import/export
-#define MAP_EXT(name,prefix,token,type,context)  _MAPV(name,prefix,token,type,context,SvtSaveOptions::ODFVER_012_EXT_COMPAT)
 
 // entry list for graphic properties
 
@@ -290,8 +288,6 @@ const XMLPropertyMapEntry aXMLSDProperties[] =
     GMAP( "MoveProtect",                    XML_NAMESPACE_STYLE, XML_PROTECT,               XML_SD_TYPE_MOVE_PROTECT|MID_FLAG_MULTI_PROPERTY|MID_FLAG_MERGE_ATTRIBUTE, CTF_SD_MOVE_PROTECT ),
     GMAP( "SizeProtect",                    XML_NAMESPACE_STYLE, XML_PROTECT,               XML_SD_TYPE_SIZE_PROTECT|MID_FLAG_MULTI_PROPERTY|MID_FLAG_MERGE_ATTRIBUTE, CTF_SD_SIZE_PROTECT ),
 
-    MAP_EXT("TextBox", XML_NAMESPACE_LO_EXT, XML_TEXT_BOX, XML_TYPE_BOOL|XML_TYPE_PROP_GRAPHIC, 0),
-
     MAP_END()
 };
 
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index c5d09cd..1ef7602 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -76,6 +76,7 @@
 #include <com/sun/star/presentation/AnimationSpeed.hpp>
 #include <com/sun/star/presentation/ClickAction.hpp>
 #include <com/sun/star/style/XStyle.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
 #include <com/sun/star/table/XColumnRowRange.hpp>
 #include <com/sun/star/text/XText.hpp>
 #include <com/sun/star/document/XStorageBasedDocument.hpp>
@@ -354,6 +355,18 @@ void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShap
             }
         }
 
+        if (aParentName.isEmpty() && xPropertySetInfo->hasPropertyByName("TextBox") && xPropSet->getPropertyValue("TextBox").get<bool>())
+        {
+            // Shapes with a Writer TextBox always have a parent style.
+            // If there would be none, then just assign the first available.
+            uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(GetExport().GetModel(), uno::UNO_QUERY);
+            uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies();
+            uno::Reference<container::XNameAccess> xFrameStyles = xStyleFamilies->getByName("FrameStyles").get< uno::Reference<container::XNameAccess> >();
+            uno::Sequence<OUString> aFrameStyles = xFrameStyles->getElementNames();
+            if (aFrameStyles.hasElements())
+                aParentName = aFrameStyles[0];
+        }
+
         // filter propset
         std::vector< XMLPropertyState > xPropStates;
 
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index f5595f7..c1aab2c 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -223,15 +223,6 @@ SvXMLImportContext *SdXMLShapeContext::CreateChildContext( sal_uInt16 p_nPrefix,
                 if( mxCursor.is() )
                 {
                     xTxtImport->SetCursor( mxCursor );
-
-                    // Check if this shape has a TextBox, so we can pass the right context type.
-                    uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
-                    if (xPropertySet.is())
-                    {
-                        uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
-                        if (xPropertySetInfo->hasPropertyByName("TextBox"))
-                            xPropertySet->getPropertyValue("TextBox") >>= mbTextBox;
-                    }
                 }
 
                 // remember old list item and block (#91964#) and reset them
@@ -722,6 +713,11 @@ void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */)
                 pDocStyle->FillPropertySet(xPropSet);
             }
 
+            // Writer shapes: if this one has a TextBox, set it here.
+            uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropSet->getPropertySetInfo();
+            if (xPropertySetInfo->hasPropertyByName("TextBox"))
+                xPropSet->setPropertyValue("TextBox", uno::makeAny(mbTextBox));
+
         } while(false);
 
         // try to set text auto style
@@ -3721,6 +3717,29 @@ SdXMLCustomShapeContext::SdXMLCustomShapeContext(
     bool bTemporaryShape)
 :   SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
 {
+    // See the XMLTextFrameContext ctor, a frame has Writer content (and not
+    // editeng) if its autostyle has a parent style. Do the same for shapes as well.
+    sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+    for (sal_Int16 i=0; i < nAttrCount; ++i)
+    {
+        const OUString& rAttrName = xAttrList->getNameByIndex(i);
+        OUString aLocalName;
+        sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
+        if (nPrefix == XML_NAMESPACE_DRAW && IsXMLToken(aLocalName, XML_STYLE_NAME))
+        {
+            OUString aStyleName = xAttrList->getValueByIndex(i);
+            if(!aStyleName.isEmpty())
+            {
+                rtl::Reference<XMLTextImportHelper> xTxtImport = GetImport().GetTextImport();
+                XMLPropStyleContext* pStyle = xTxtImport->FindAutoFrameStyle(aStyleName);
+                if (pStyle && !pStyle->GetParentName().isEmpty())
+                {
+                    mbTextBox = true;
+                    break;
+                }
+            }
+        }
+    }
 }
 
 SdXMLCustomShapeContext::~SdXMLCustomShapeContext()


More information about the Libreoffice-commits mailing list