Kaydet (Commit) 9835a582 authored tarafından Miklos Vajna's avatar Miklos Vajna

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 9d310ecf (sw textboxes:
implement ODF import/export, 2014-06-02).

Change-Id: Id8afa6368bedcd293e578244abb58e18949bec8d
üst ad5e8b30
...@@ -97,6 +97,7 @@ void SwTextBoxHelper::create(SwFrmFmt* pShape) ...@@ -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_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_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_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));
} }
} }
......
...@@ -80,8 +80,6 @@ using namespace ::xmloff::token; ...@@ -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 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 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 } #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 // entry list for graphic properties
...@@ -290,8 +288,6 @@ const XMLPropertyMapEntry aXMLSDProperties[] = ...@@ -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( "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 ), 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() MAP_END()
}; };
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
#include <com/sun/star/presentation/AnimationSpeed.hpp> #include <com/sun/star/presentation/AnimationSpeed.hpp>
#include <com/sun/star/presentation/ClickAction.hpp> #include <com/sun/star/presentation/ClickAction.hpp>
#include <com/sun/star/style/XStyle.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/table/XColumnRowRange.hpp>
#include <com/sun/star/text/XText.hpp> #include <com/sun/star/text/XText.hpp>
#include <com/sun/star/document/XStorageBasedDocument.hpp> #include <com/sun/star/document/XStorageBasedDocument.hpp>
...@@ -354,6 +355,18 @@ void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShap ...@@ -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 // filter propset
std::vector< XMLPropertyState > xPropStates; std::vector< XMLPropertyState > xPropStates;
......
...@@ -223,15 +223,6 @@ SvXMLImportContext *SdXMLShapeContext::CreateChildContext( sal_uInt16 p_nPrefix, ...@@ -223,15 +223,6 @@ SvXMLImportContext *SdXMLShapeContext::CreateChildContext( sal_uInt16 p_nPrefix,
if( mxCursor.is() ) if( mxCursor.is() )
{ {
xTxtImport->SetCursor( mxCursor ); 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 // remember old list item and block (#91964#) and reset them
...@@ -722,6 +713,11 @@ void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */) ...@@ -722,6 +713,11 @@ void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */)
pDocStyle->FillPropertySet(xPropSet); 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); } while(false);
// try to set text auto style // try to set text auto style
...@@ -3721,6 +3717,29 @@ SdXMLCustomShapeContext::SdXMLCustomShapeContext( ...@@ -3721,6 +3717,29 @@ SdXMLCustomShapeContext::SdXMLCustomShapeContext(
bool bTemporaryShape) bool bTemporaryShape)
: SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, 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() SdXMLCustomShapeContext::~SdXMLCustomShapeContext()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment