[Libreoffice-commits] core.git: 3 commits - include/oox oox/source sw/inc sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Jun 6 05:25:42 PDT 2014
include/oox/export/drawingml.hxx | 4
oox/source/export/shapes.cxx | 15 +
sw/inc/textboxhelper.hxx | 6
sw/source/core/doc/textboxhelper.cxx | 10 +
sw/source/filter/ww8/docxattributeoutput.cxx | 11 +
sw/source/filter/ww8/docxattributeoutput.hxx | 2
sw/source/filter/ww8/docxsdrexport.cxx | 228 +++++++++++++--------------
sw/source/filter/ww8/docxsdrexport.hxx | 2
8 files changed, 166 insertions(+), 112 deletions(-)
New commits:
commit 049f30c37f6c5bbc1f4dfd1f33005b9623f74f0a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Jun 6 14:16:47 2014 +0200
DOCX drawingML export: avoid duplicated <wps:spPr> for textboxes
It's valid to have multiple ones from these, but the first one was
generated from the shape, the second from the textbox. Given that we use
the textbox only as a container, don't write its properties, it's not
necessary and may cause problems.
Change-Id: Id1f8bb92c587fe8c1437e412b41510803595dd80
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index ae6445e..5aaeb2e 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -1188,6 +1188,23 @@ void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId, bo
// to lots of contents, this size contains the real size.
const Size aSize = pParentFrame->GetSize();
+ uno::Reference< drawing::XShape > xShape;
+ const SdrObject* pSdrObj = rFrmFmt.FindRealSdrObject();
+ if (pSdrObj)
+ xShape = uno::Reference< drawing::XShape >(const_cast<SdrObject*>(pSdrObj)->getUnoShape(), uno::UNO_QUERY);
+ uno::Reference< beans::XPropertySet > xPropertySet(xShape, uno::UNO_QUERY);
+ uno::Reference< beans::XPropertySetInfo > xPropSetInfo;
+ if (xPropertySet.is())
+ xPropSetInfo = xPropertySet->getPropertySetInfo();
+
+ m_pImpl->m_pBodyPrAttrList = pFS->createAttrList();
+ {
+ drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP;
+ if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("TextVerticalAdjust"))
+ xPropertySet->getPropertyValue("TextVerticalAdjust") >>= eAdjust;
+ m_pImpl->m_pBodyPrAttrList->add(XML_anchor, oox::drawingml::GetTextVerticalAdjust(eAdjust));
+ }
+
if (!bTextBoxOnly)
{
startDMLAnchorInline(&rFrmFmt, aSize);
@@ -1205,94 +1222,79 @@ void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId, bo
XML_uri, "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
FSEND);
pFS->startElementNS(XML_wps, XML_wsp, FSEND);
- }
- pFS->singleElementNS(XML_wps, XML_cNvSpPr,
- XML_txBox, "1",
- FSEND);
+ pFS->singleElementNS(XML_wps, XML_cNvSpPr,
+ XML_txBox, "1",
+ FSEND);
- uno::Any aRotation ;
- uno::Reference< drawing::XShape > xShape;
- const SdrObject* pSdrObj = rFrmFmt.FindRealSdrObject();
- if (pSdrObj)
- xShape = uno::Reference< drawing::XShape >(const_cast<SdrObject*>(pSdrObj)->getUnoShape(), uno::UNO_QUERY);
- uno::Reference< beans::XPropertySet > xPropertySet(xShape, uno::UNO_QUERY);
- uno::Reference< beans::XPropertySetInfo > xPropSetInfo;
- if (xPropertySet.is())
- xPropSetInfo = xPropertySet->getPropertySetInfo();
- sal_Int32 nRotation = 0;
- if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("FrameInteropGrabBag"))
- {
- uno::Sequence< beans::PropertyValue > propList;
- xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList;
- for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp)
+ uno::Any aRotation ;
+ sal_Int32 nRotation = 0;
+ if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("FrameInteropGrabBag"))
{
- OUString propName = propList[nProp].Name;
- if (propName == "mso-rotation-angle")
+ uno::Sequence< beans::PropertyValue > propList;
+ xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList;
+ for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp)
{
- aRotation = propList[nProp].Value ;
- break;
+ OUString propName = propList[nProp].Name;
+ if (propName == "mso-rotation-angle")
+ {
+ aRotation = propList[nProp].Value ;
+ break;
+ }
}
}
- }
- aRotation >>= nRotation ;
- OString sRotation(OString::number(nRotation));
- // Shape properties
- pFS->startElementNS(XML_wps, XML_spPr, FSEND);
- if (nRotation)
- {
- pFS->startElementNS(XML_a, XML_xfrm,
- XML_rot, sRotation.getStr(),
- FSEND);
- }
- else
- {
- pFS->startElementNS(XML_a, XML_xfrm, FSEND);
- }
- pFS->singleElementNS(XML_a, XML_off,
- XML_x, "0",
- XML_y, "0",
- FSEND);
- OString aWidth(OString::number(TwipsToEMU(aSize.Width())));
- OString aHeight(OString::number(TwipsToEMU(aSize.Height())));
- pFS->singleElementNS(XML_a, XML_ext,
- XML_cx, aWidth.getStr(),
- XML_cy, aHeight.getStr(),
- FSEND);
- pFS->endElementNS(XML_a, XML_xfrm);
- OUString shapeType = "rect";
- if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("FrameInteropGrabBag"))
- {
- uno::Sequence< beans::PropertyValue > propList;
- xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList;
- for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp)
+ aRotation >>= nRotation ;
+ OString sRotation(OString::number(nRotation));
+ // Shape properties
+ pFS->startElementNS(XML_wps, XML_spPr, FSEND);
+ if (nRotation)
+ {
+ pFS->startElementNS(XML_a, XML_xfrm,
+ XML_rot, sRotation.getStr(),
+ FSEND);
+ }
+ else
{
- OUString propName = propList[nProp].Name;
- if (propName == "mso-orig-shape-type")
+ pFS->startElementNS(XML_a, XML_xfrm, FSEND);
+ }
+ pFS->singleElementNS(XML_a, XML_off,
+ XML_x, "0",
+ XML_y, "0",
+ FSEND);
+ OString aWidth(OString::number(TwipsToEMU(aSize.Width())));
+ OString aHeight(OString::number(TwipsToEMU(aSize.Height())));
+ pFS->singleElementNS(XML_a, XML_ext,
+ XML_cx, aWidth.getStr(),
+ XML_cy, aHeight.getStr(),
+ FSEND);
+ pFS->endElementNS(XML_a, XML_xfrm);
+ OUString shapeType = "rect";
+ if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("FrameInteropGrabBag"))
+ {
+ uno::Sequence< beans::PropertyValue > propList;
+ xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList;
+ for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp)
{
- propList[nProp].Value >>= shapeType;
- break;
+ OUString propName = propList[nProp].Name;
+ if (propName == "mso-orig-shape-type")
+ {
+ propList[nProp].Value >>= shapeType;
+ break;
+ }
}
}
+ //Empty shapeType will lead to corruption so to avoid that shapeType is set to default i.e. "rect"
+ if (shapeType.isEmpty())
+ shapeType = "rect";
+
+ pFS->singleElementNS(XML_a, XML_prstGeom,
+ XML_prst, OUStringToOString(shapeType, RTL_TEXTENCODING_UTF8).getStr(),
+ FSEND);
+ m_pImpl->m_bDMLTextFrameSyntax = true;
+ m_pImpl->m_rExport.OutputFormat(pParentFrame->GetFrmFmt(), false, false, true);
+ m_pImpl->m_bDMLTextFrameSyntax = false;
+ writeDMLEffectLst(rFrmFmt);
+ pFS->endElementNS(XML_wps, XML_spPr);
}
- //Empty shapeType will lead to corruption so to avoid that shapeType is set to default i.e. "rect"
- if (shapeType.isEmpty())
- shapeType = "rect";
-
- pFS->singleElementNS(XML_a, XML_prstGeom,
- XML_prst, OUStringToOString(shapeType, RTL_TEXTENCODING_UTF8).getStr(),
- FSEND);
- m_pImpl->m_bDMLTextFrameSyntax = true;
- m_pImpl->m_pBodyPrAttrList = pFS->createAttrList();
- {
- drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP;
- if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("TextVerticalAdjust"))
- xPropertySet->getPropertyValue("TextVerticalAdjust") >>= eAdjust;
- m_pImpl->m_pBodyPrAttrList->add(XML_anchor, oox::drawingml::GetTextVerticalAdjust(eAdjust));
- }
- m_pImpl->m_rExport.OutputFormat(pParentFrame->GetFrmFmt(), false, false, true);
- m_pImpl->m_bDMLTextFrameSyntax = false;
- writeDMLEffectLst(rFrmFmt);
- pFS->endElementNS(XML_wps, XML_spPr);
m_pImpl->m_rExport.mpParentFrame = NULL;
bool skipTxBxContent = false ;
commit 8c677716c4707ccd86b152ae504841affb393cc0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Jun 6 14:01:21 2014 +0200
DOCX drawingML export: if shape has textbox, export its contents as shape text
Change-Id: I54a51189e1c595841b8b02f3b4436da4a29f1dac
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index e97f05d..6f64fcf 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -71,6 +71,8 @@ class OOX_DLLPUBLIC DMLTextExport
{
public:
virtual void WriteOutliner(const OutlinerParaObject& rParaObj) = 0;
+ /// Write the contents of the textbox that is associated to this shape.
+ virtual void WriteTextBox(css::uno::Reference<css::drawing::XShape> xShape) = 0;
protected:
DMLTextExport() {}
virtual ~DMLTextExport() {}
@@ -120,6 +122,8 @@ public:
::sax_fastparser::FSHelperPtr GetFS() { return mpFS; }
::oox::core::XmlFilterBase* GetFB() { return mpFB; }
DocumentType GetDocumentType() { return meDocumentType; }
+ /// The application-specific text exporter callback, if there is one.
+ DMLTextExport* GetTextExport() { return mpTextExport; }
/// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship
OUString WriteImage( const Graphic &rGraphic , bool bRelPathToMedia = false);
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 82d2b5e..7c3627e 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -812,6 +812,21 @@ ShapeExport& ShapeExport::WriteShape( Reference< XShape > xShape )
ShapeExport& ShapeExport::WriteTextBox( Reference< XInterface > xIface, sal_Int32 nXmlNamespace )
{
+ // In case this shape has an associated textbox, then export that, and we're done.
+ if (GetDocumentType() == DOCUMENT_DOCX && GetTextExport())
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(xIface, uno::UNO_QUERY);
+ if (xPropertySet.is())
+ {
+ uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
+ if (xPropertySetInfo->hasPropertyByName("TextBox") && xPropertySet->getPropertyValue("TextBox").get<bool>())
+ {
+ GetTextExport()->WriteTextBox(uno::Reference<drawing::XShape>(xIface, uno::UNO_QUERY_THROW));
+ return *this;
+ }
+ }
+ }
+
if( NonEmptyText( xIface ) )
{
FSHelperPtr pFS = GetFS();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index d3cfad8..41630d4 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -29,10 +29,13 @@
#include "fchrfmt.hxx"
#include "tgrditem.hxx"
#include "fmtruby.hxx"
+#include "fmtanchr.hxx"
#include "breakit.hxx"
#include "redline.hxx"
#include "unocoll.hxx"
#include "unoframe.hxx"
+#include "unodraw.hxx"
+#include "textboxhelper.hxx"
#include "wrtww8.hxx"
#include "wrtww8.hxx"
@@ -4549,6 +4552,14 @@ void DocxAttributeOutput::WriteOutliner(const OutlinerParaObject& rParaObj)
m_pSerializer->endElementNS( XML_w, XML_txbxContent );
}
+void DocxAttributeOutput::WriteTextBox(uno::Reference<drawing::XShape> xShape)
+{
+ SwFrmFmt* pTextBox = SwTextBoxHelper::findTextBox(xShape);
+ const SwPosition* pAnchor = pTextBox->GetAnchor().GetCntntAnchor();
+ sw::Frame aFrame(*pTextBox, *pAnchor);
+ m_rExport.SdrExporter().writeDMLTextFrame(&aFrame, m_anchorId++, /*bTextBoxOnly=*/true);
+}
+
oox::drawingml::DrawingML& DocxAttributeOutput::GetDrawingML()
{
return m_rDrawingML;
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 9e01511..7990ed8 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -918,6 +918,8 @@ public:
/// VMLTextExport
virtual void WriteOutliner(const OutlinerParaObject& rParaObj) SAL_OVERRIDE;
+ /// DMLTextExport
+ virtual void WriteTextBox(css::uno::Reference<css::drawing::XShape> xShape) SAL_OVERRIDE;
virtual oox::drawingml::DrawingML& GetDrawingML() SAL_OVERRIDE;
virtual void switchHeaderFooter(bool isHeaderFooter, sal_Int32 index);
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index c389d75..ae6445e 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -1172,7 +1172,7 @@ void DocxSdrExport::writeDiagram(const SdrObject* sdrObject, const SwFrmFmt& rFr
}
}
-void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId)
+void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId, bool bTextBoxOnly)
{
sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer;
const SwFrmFmt& rFrmFmt = pParentFrame->GetFrmFmt();
@@ -1188,21 +1188,24 @@ void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId)
// to lots of contents, this size contains the real size.
const Size aSize = pParentFrame->GetSize();
- startDMLAnchorInline(&rFrmFmt, aSize);
+ if (!bTextBoxOnly)
+ {
+ startDMLAnchorInline(&rFrmFmt, aSize);
- sax_fastparser::FastAttributeList* pDocPrAttrList = pFS->createAttrList();
- pDocPrAttrList->add(XML_id, OString::number(nAnchorId).getStr());
- pDocPrAttrList->add(XML_name, OUStringToOString(rFrmFmt.GetName(), RTL_TEXTENCODING_UTF8).getStr());
- sax_fastparser::XFastAttributeListRef xDocPrAttrListRef(pDocPrAttrList);
- pFS->singleElementNS(XML_wp, XML_docPr, xDocPrAttrListRef);
+ sax_fastparser::FastAttributeList* pDocPrAttrList = pFS->createAttrList();
+ pDocPrAttrList->add(XML_id, OString::number(nAnchorId).getStr());
+ pDocPrAttrList->add(XML_name, OUStringToOString(rFrmFmt.GetName(), RTL_TEXTENCODING_UTF8).getStr());
+ sax_fastparser::XFastAttributeListRef xDocPrAttrListRef(pDocPrAttrList);
+ pFS->singleElementNS(XML_wp, XML_docPr, xDocPrAttrListRef);
- pFS->startElementNS(XML_a, XML_graphic,
- FSNS(XML_xmlns, XML_a), "http://schemas.openxmlformats.org/drawingml/2006/main",
- FSEND);
- pFS->startElementNS(XML_a, XML_graphicData,
- XML_uri, "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
- FSEND);
- pFS->startElementNS(XML_wps, XML_wsp, FSEND);
+ pFS->startElementNS(XML_a, XML_graphic,
+ FSNS(XML_xmlns, XML_a), "http://schemas.openxmlformats.org/drawingml/2006/main",
+ FSEND);
+ pFS->startElementNS(XML_a, XML_graphicData,
+ XML_uri, "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
+ FSEND);
+ pFS->startElementNS(XML_wps, XML_wsp, FSEND);
+ }
pFS->singleElementNS(XML_wps, XML_cNvSpPr,
XML_txBox, "1",
FSEND);
@@ -1362,33 +1365,36 @@ void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId)
pFS->singleElementNS(XML_a, (rSize.GetHeightSizeType() == ATT_VAR_SIZE ? XML_spAutoFit : XML_noAutofit), FSEND);
pFS->endElementNS(XML_wps, XML_bodyPr);
- pFS->endElementNS(XML_wps, XML_wsp);
- pFS->endElementNS(XML_a, XML_graphicData);
- pFS->endElementNS(XML_a, XML_graphic);
-
- // Relative size of the Text Frame.
- if (rSize.GetWidthPercent())
+ if (!bTextBoxOnly)
{
- pFS->startElementNS(XML_wp14, XML_sizeRelH,
- XML_relativeFrom, (rSize.GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME ? "page" : "margin"),
- FSEND);
- pFS->startElementNS(XML_wp14, XML_pctWidth, FSEND);
- pFS->writeEscaped(OUString::number(rSize.GetWidthPercent() * oox::drawingml::PER_PERCENT));
- pFS->endElementNS(XML_wp14, XML_pctWidth);
- pFS->endElementNS(XML_wp14, XML_sizeRelH);
- }
- if (rSize.GetHeightPercent())
- {
- pFS->startElementNS(XML_wp14, XML_sizeRelV,
- XML_relativeFrom, (rSize.GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME ? "page" : "margin"),
- FSEND);
- pFS->startElementNS(XML_wp14, XML_pctHeight, FSEND);
- pFS->writeEscaped(OUString::number(rSize.GetHeightPercent() * oox::drawingml::PER_PERCENT));
- pFS->endElementNS(XML_wp14, XML_pctHeight);
- pFS->endElementNS(XML_wp14, XML_sizeRelV);
- }
+ pFS->endElementNS(XML_wps, XML_wsp);
+ pFS->endElementNS(XML_a, XML_graphicData);
+ pFS->endElementNS(XML_a, XML_graphic);
- endDMLAnchorInline(&rFrmFmt);
+ // Relative size of the Text Frame.
+ if (rSize.GetWidthPercent())
+ {
+ pFS->startElementNS(XML_wp14, XML_sizeRelH,
+ XML_relativeFrom, (rSize.GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME ? "page" : "margin"),
+ FSEND);
+ pFS->startElementNS(XML_wp14, XML_pctWidth, FSEND);
+ pFS->writeEscaped(OUString::number(rSize.GetWidthPercent() * oox::drawingml::PER_PERCENT));
+ pFS->endElementNS(XML_wp14, XML_pctWidth);
+ pFS->endElementNS(XML_wp14, XML_sizeRelH);
+ }
+ if (rSize.GetHeightPercent())
+ {
+ pFS->startElementNS(XML_wp14, XML_sizeRelV,
+ XML_relativeFrom, (rSize.GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME ? "page" : "margin"),
+ FSEND);
+ pFS->startElementNS(XML_wp14, XML_pctHeight, FSEND);
+ pFS->writeEscaped(OUString::number(rSize.GetHeightPercent() * oox::drawingml::PER_PERCENT));
+ pFS->endElementNS(XML_wp14, XML_pctHeight);
+ pFS->endElementNS(XML_wp14, XML_sizeRelV);
+ }
+
+ endDMLAnchorInline(&rFrmFmt);
+ }
}
void DocxSdrExport::writeVMLTextFrame(sw::Frame* pParentFrame)
diff --git a/sw/source/filter/ww8/docxsdrexport.hxx b/sw/source/filter/ww8/docxsdrexport.hxx
index 8760a6b..c05979f 100644
--- a/sw/source/filter/ww8/docxsdrexport.hxx
+++ b/sw/source/filter/ww8/docxsdrexport.hxx
@@ -92,7 +92,7 @@ public:
com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > xOutStream, const OUString& sGrabBagProperyName,
int nAnchorId);
/// Writes text frame in DML format.
- void writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId);
+ void writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId, bool bTextBoxOnly = false);
/// Writes text frame in VML format.
void writeVMLTextFrame(sw::Frame* pParentFrame);
/// Undo the text direction mangling done by the frame btLr handler in writerfilter::dmapper::DomainMapper::lcl_startCharacterGroup()
commit ff1c74f53a66695f20906fe3a0aebd15b6b0cd51
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Jun 6 11:44:15 2014 +0200
SwTextBoxHelper::findTextBox: add an UNO version
Export filters don't have access to SwXShape, and it's probably good to
have that way.
Change-Id: I039bafec10d2fde7c7acdcfad5b07068a2a519f1
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 75d2fac..2bb791f 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -12,10 +12,13 @@
#include <list>
+#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/uno/Any.h>
#include <com/sun/star/uno/Type.h>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <swdllapi.h>
+
class SdrPage;
class SwFrmFmt;
class SwDoc;
@@ -27,7 +30,7 @@ class Rectangle;
* This class provides helper methods to create, query and maintain such
* TextBoxes.
*/
-class SwTextBoxHelper
+class SW_DLLPUBLIC SwTextBoxHelper
{
public:
/// Create a TextBox for a shape.
@@ -44,6 +47,7 @@ public:
/// If we have an associated TextFrame, then return that.
static SwFrmFmt* findTextBox(SwFrmFmt* pShape);
+ static SwFrmFmt* findTextBox(css::uno::Reference<css::drawing::XShape> xShape);
/// Return the textbox rectangle of a draw shape (in twips).
static Rectangle getTextRectangle(SwFrmFmt* pShape, bool bAbsolute = true);
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 0741dd8..598d4b8 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -15,6 +15,7 @@
#include <docary.hxx>
#include <unocoll.hxx>
#include <unoframe.hxx>
+#include <unodraw.hxx>
#include <unotextbodyhf.hxx>
#include <unotextrange.hxx>
#include <unomid.h>
@@ -156,6 +157,15 @@ uno::Any SwTextBoxHelper::getByIndex(SdrPage* pPage, sal_Int32 nIndex, std::list
return pRet ? uno::makeAny(uno::Reference<drawing::XShape>(pRet->getUnoShape(), uno::UNO_QUERY)) : uno::Any();
}
+SwFrmFmt* SwTextBoxHelper::findTextBox(uno::Reference<drawing::XShape> xShape)
+{
+ SwXShape* pShape = dynamic_cast<SwXShape*>(xShape.get());
+ if (!pShape)
+ return 0;
+
+ return findTextBox(pShape->GetFrmFmt());
+}
+
SwFrmFmt* SwTextBoxHelper::findTextBox(SwFrmFmt* pShape)
{
SwFrmFmt* pRet = 0;
More information about the Libreoffice-commits
mailing list