diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-10-04 19:37:55 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-10-04 20:18:01 +0200 |
commit | 9835a5823e0f559aabbc0e15ea126c82229c4bc7 (patch) | |
tree | 12b77a17bf437e248ef02cc06634ab1dc458a99c | |
parent | ad5e8b30ac66a00d0110fcdaf4d064181247585b (diff) |
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
-rw-r--r-- | sw/qa/extras/odfexport/data/textbox-rounded-corners.odt | bin | 13260 -> 13249 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/data/fdo82191.odt | bin | 10913 -> 10888 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/data/shape-textbox-autosize.odt | bin | 12362 -> 12356 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/data/shape-textbox-vertadjust.odt | bin | 12076 -> 12049 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/data/shape-textbox.odt | bin | 10723 -> 10689 bytes | |||
-rw-r--r-- | sw/source/core/doc/textboxhelper.cxx | 1 | ||||
-rw-r--r-- | xmloff/source/draw/sdpropls.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/draw/shapeexport.cxx | 13 | ||||
-rw-r--r-- | xmloff/source/draw/ximpshap.cxx | 37 |
9 files changed, 42 insertions, 13 deletions
diff --git a/sw/qa/extras/odfexport/data/textbox-rounded-corners.odt b/sw/qa/extras/odfexport/data/textbox-rounded-corners.odt Binary files differindex 385185021ab3..add7512c6ca2 100644 --- a/sw/qa/extras/odfexport/data/textbox-rounded-corners.odt +++ b/sw/qa/extras/odfexport/data/textbox-rounded-corners.odt diff --git a/sw/qa/extras/uiwriter/data/fdo82191.odt b/sw/qa/extras/uiwriter/data/fdo82191.odt Binary files differindex d0759c04dd1c..e34105834f78 100644 --- a/sw/qa/extras/uiwriter/data/fdo82191.odt +++ b/sw/qa/extras/uiwriter/data/fdo82191.odt diff --git a/sw/qa/extras/uiwriter/data/shape-textbox-autosize.odt b/sw/qa/extras/uiwriter/data/shape-textbox-autosize.odt Binary files differindex 8877c7215426..1d2c86671fcf 100644 --- a/sw/qa/extras/uiwriter/data/shape-textbox-autosize.odt +++ b/sw/qa/extras/uiwriter/data/shape-textbox-autosize.odt diff --git a/sw/qa/extras/uiwriter/data/shape-textbox-vertadjust.odt b/sw/qa/extras/uiwriter/data/shape-textbox-vertadjust.odt Binary files differindex dfb26bfa3912..f5fabcfe8fc7 100644 --- a/sw/qa/extras/uiwriter/data/shape-textbox-vertadjust.odt +++ b/sw/qa/extras/uiwriter/data/shape-textbox-vertadjust.odt diff --git a/sw/qa/extras/uiwriter/data/shape-textbox.odt b/sw/qa/extras/uiwriter/data/shape-textbox.odt Binary files differindex 0fe0e9b9cb89..5f278af358a7 100644 --- a/sw/qa/extras/uiwriter/data/shape-textbox.odt +++ b/sw/qa/extras/uiwriter/data/shape-textbox.odt diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index d00398333812..655458863ac0 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 f24bd7e61b42..6df582717ba4 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 c5d09cdfb13c..1ef76026e5b8 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 f5595f7d68b2..c1aab2c72a88 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() |