45 #include <drawdoc.hxx>
50 #include <com/sun/star/document/XActionLockable.hpp>
51 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
52 #include <com/sun/star/text/SizeType.hpp>
53 #include <com/sun/star/text/WrapTextMode.hpp>
54 #include <com/sun/star/text/XTextDocument.hpp>
55 #include <com/sun/star/text/XTextFrame.hpp>
56 #include <com/sun/star/table/BorderLine2.hpp>
57 #include <com/sun/star/text/WritingMode.hpp>
58 #include <com/sun/star/text/WritingMode2.hpp>
59 #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
60 #include <com/sun/star/style/ParagraphAdjust.hpp>
76 OUString sCopyableText;
82 uno::Reference<text::XText> xSrcCnt(pObject->
getWeakUnoShape().get(), uno::UNO_QUERY);
83 auto xCur = xSrcCnt->createTextCursor();
84 xCur->gotoStart(
false);
86 sCopyableText = xCur->getText()->getString();
91 uno::Reference<text::XTextContent> xTextFrame(
94 uno::Reference<text::XTextDocument> xTextDocument(
96 uno::Reference<text::XTextContentAppend> xTextContentAppend(xTextDocument->getText(),
100 uno::Reference<text::XTextContent> XSourceShape(pObject->
getUnoShape(),
101 uno::UNO_QUERY_THROW);
102 xTextContentAppend->insertTextContentWithProperties(
103 xTextFrame, uno::Sequence<beans::PropertyValue>(), XSourceShape->getAnchor());
105 catch (uno::Exception&)
107 xTextContentAppend->appendTextContent(xTextFrame, uno::Sequence<beans::PropertyValue>());
110 uno::Reference<text::XTextFrame> xRealTextFrame(xTextFrame, uno::UNO_QUERY);
111 auto pTextFrame =
dynamic_cast<SwXTextFrame*
>(xRealTextFrame.get());
112 assert(
nullptr != pTextFrame);
115 assert(
nullptr != dynamic_cast<SwDrawFrameFormat*>(pShape));
116 assert(
nullptr != dynamic_cast<SwFlyFrameFormat*>(pFormat));
120 auto pTextBox = std::make_shared<SwTextBoxNode>(
SwTextBoxNode(pShape));
121 pTextBox->AddTextBox(pObject, pFormat);
128 pTextBox->AddTextBox(pObject, pFormat);
133 uno::Reference<beans::XPropertySet> xPropertySet(xTextFrame, uno::UNO_QUERY);
134 uno::Any aEmptyBorder{ table::BorderLine2() };
146 uno::Reference<container::XNamed> xNamed(xTextFrame, uno::UNO_QUERY);
150 uno::Reference<text::XTextRange> xTextBox(xTextFrame, uno::UNO_QUERY_THROW);
160 DoTextBoxZOrderCorrection(pShape, pObject);
163 uno::Reference<drawing::XShape> xShape(pObject->
getUnoShape(), uno::UNO_QUERY);
166 uno::Reference<beans::XPropertySet> xShapePropertySet(xShape, uno::UNO_QUERY);
187 text::WritingMode
eMode;
192 doTextBoxPositioning(pShape, pObject);
195 if (!bCopyText || sCopyableText.isEmpty())
200 auto pSourceText =
dynamic_cast<SdrTextObj*
>(pObject);
201 uno::Reference<text::XTextRange> xDestText(xRealTextFrame, uno::UNO_QUERY);
203 xDestText->setString(sCopyableText);
206 pSourceText->SetText(OUString());
213 uno::Reference<text::XTextFrame> xNew)
216 assert(pShapeFormat && pObj && xNew);
219 if (
auto pTextFrame = dynamic_cast<SwXTextFrame*>(xNew.get()))
220 pFormat = pTextFrame->GetFrameFormat();
223 std::vector<std::pair<beans::Property, uno::Any>> aOldProps;
228 if (pTextBoxNode->GetTextBox(pObj))
232 if (xOldFrame.hasValue())
234 uno::Reference<beans::XPropertySet> xOldprops(xOldFrame, uno::UNO_QUERY);
235 uno::Reference<beans::XPropertyState> xOldPropStates(xOldFrame, uno::UNO_QUERY);
236 for (
auto& rProp : xOldprops->getPropertySetInfo()->getProperties())
240 if (xOldPropStates->getPropertyState(rProp.Name)
241 == beans::PropertyState::PropertyState_DIRECT_VALUE)
243 std::pair(rProp, xOldprops->getPropertyValue(rProp.Name)));
250 destroy(pShapeFormat, pObj);
253 pTextBoxNode->AddTextBox(pObj, pFormat);
260 auto pTextBox = std::shared_ptr<SwTextBoxNode>(
new SwTextBoxNode(pShapeFormat));
261 pTextBox->AddTextBox(pObj, pFormat);
266 uno::Reference<beans::XPropertySet> xPropertySet(xNew, uno::UNO_QUERY);
267 uno::Any aEmptyBorder{ table::BorderLine2() };
276 uno::Reference<container::XNamed> xNamed(xNew, uno::UNO_QUERY);
279 uno::Reference<drawing::XShape> xShape(pObj->
getUnoShape(), uno::UNO_QUERY);
281 uno::Reference<beans::XPropertySet> xShapePropertySet(xShape, uno::UNO_QUERY);
298 drawing::TextVerticalAdjust aVertAdj = drawing::TextVerticalAdjust_CENTER;
299 if ((uno::Reference<beans::XPropertyState>(xShape, uno::UNO_QUERY_THROW))
301 != beans::PropertyState::PropertyState_DEFAULT_VALUE)
304 .get<drawing::TextVerticalAdjust>();
307 text::WritingMode
eMode;
310 if (aOldProps.size())
312 for (
auto& rProp : aOldProps)
316 xPropertySet->setPropertyValue(rProp.first.Name, rProp.second);
329 synchronizeGroupTextBoxProperty(&changeAnchor, pShapeFormat, pObj);
330 synchronizeGroupTextBoxProperty(&syncTextBoxSize, pShapeFormat, pObj);
332 updateTextBoxMargin(pObj);
339 if (pTextBox && pTextBox->IsTextBoxActive(pObject))
342 pTextBox->SetTextBoxInactive(pObject);
345 pTextBox->DelTextBox(pObject,
true);
354 if (!pFormat || pFormat->
Which() != nType)
364 return pTextBox->GetTextBox(pObject);
366 return pTextBox->GetTextBox(pObj);
371 return pTextBox->GetOwnerShape();
382 uno::Reference<drawing::XShape> xShape(pObj->
getWeakUnoShape().get(), uno::UNO_QUERY);
405 for (
const auto pFormat : rSpzFrameFormats)
416 throw lang::IndexOutOfBoundsException();
425 if (nCount == nIndex)
434 throw lang::IndexOutOfBoundsException();
443 sal_Int32 nOrder = 0;
444 for (std::size_t
i = 0;
i < pPage->GetObjCount(); ++
i)
455 SAL_WARN(
"sw.core",
"SwTextBoxHelper::getOrdNum: no page or page doesn't contain the object");
467 sal_uInt16 nType,
const SdrObject* pObject)
470 if (!isTextBox(pFormat, nType, pObject))
490 auto pShape =
dynamic_cast<SwXShape*
>(xShape.get());
499 uno::Reference<text::XTextFrame>
507 auto pSdrObj = pFrameFormat->FindSdrObject();
510 return { pSdrObj->getUnoShape(), uno::UNO_QUERY };
517 template <
typename T>
523 uno::Reference<T>
const xInterface(
536 lcl_queryInterface<text::XTextAppend>(pShape, aRet, pObj);
540 lcl_queryInterface<text::XText>(pShape, aRet, pObj);
544 lcl_queryInterface<text::XTextRange>(pShape, aRet, pObj);
563 uno::Reference<document::XActionLockable> xLockable(pCustomShape->getUnoShape(),
565 sal_Int16 nLocks = 0;
567 nLocks = xLockable->resetActionLocks();
570 xLockable->setActionLocks(nLocks);
583 aPoint.AdjustX(-(aSize.Width() / 2));
584 aPoint.AdjustY(-(aSize.Height() / 2));
586 aRet.
Move(-1 * aLogicRect.
Left(), -1 * aLogicRect.
Top());
593 const css::uno::Any& rValue,
SdrObject* pObj)
603 uno::Reference<text::XTextCursor> xCursor = xTextFrame->getText()->createTextCursor();
606 xCursor->gotoStart(
false);
607 xCursor->gotoEnd(
true);
608 uno::Reference<beans::XPropertySet> xFrameParaProps(xCursor, uno::UNO_QUERY);
611 const auto eValue = rValue.get<drawing::TextHorizontalAdjust>();
614 case drawing::TextHorizontalAdjust::TextHorizontalAdjust_CENTER:
615 xFrameParaProps->setPropertyValue(
617 uno::Any(style::ParagraphAdjust::ParagraphAdjust_CENTER));
619 case drawing::TextHorizontalAdjust::TextHorizontalAdjust_LEFT:
620 xFrameParaProps->setPropertyValue(
622 uno::Any(style::ParagraphAdjust::ParagraphAdjust_LEFT));
624 case drawing::TextHorizontalAdjust::TextHorizontalAdjust_RIGHT:
625 xFrameParaProps->setPropertyValue(
627 uno::Any(style::ParagraphAdjust::ParagraphAdjust_RIGHT));
631 "SwTextBoxHelper::syncProperty: unhandled TextHorizontalAdjust: "
632 << static_cast<sal_Int32>(eValue));
638 if (rPropertyName ==
u"CustomShapeGeometry")
658 auto it = aCustomShapeGeometry.
find(
"TextPreRotateAngle");
659 if (it == aCustomShapeGeometry.
end())
661 it = aCustomShapeGeometry.
find(
"TextRotateAngle");
664 if (it != aCustomShapeGeometry.
end())
666 auto nAngle = it->second.has<sal_Int32>() ? it->second.get<sal_Int32>() : 0;
669 nAngle = it->second.has<
double>() ? it->second.get<
double>() : 0;
672 sal_Int16 nDirection = 0;
676 nDirection = text::WritingMode2::TB_RL;
679 nDirection = text::WritingMode2::BT_LR;
682 SAL_WARN(
"sw.core",
"SwTextBoxHelper::syncProperty: unhandled property value: "
683 "CustomShapeGeometry:TextPreRotateAngle: "
708 text::WritingMode
eMode;
710 if (rValue >>= eMode)
712 else if (rValue >>= eMode2)
716 SAL_INFO(
"sw.core",
"SwTextBoxHelper::syncProperty: unhandled property: "
717 << static_cast<OUString>(rPropertyName));
721 css::uno::Any& rValue)
748 SAL_WARN(
"sw.core",
"SwTextBoxHelper::getProperty: unhandled member-id: "
749 << o3tl::narrowing<sal_uInt16>(nMemberID));
763 uno::Reference<beans::XPropertySet>
const xPropertySet(
766 return xPropertySet->getPropertyValue(rPropName);
770 const css::uno::Any& rValue,
SdrObject* pObj)
783 OUString aPropertyName;
784 bool bAdjustX =
false;
785 bool bAdjustY =
false;
786 bool bAdjustSize =
false;
806 SAL_WARN(
"sw.core",
"SwTextBoxHelper::syncProperty: unhandled member-id: "
807 << o3tl::narrowing<sal_uInt16>(nMemberID)
808 <<
" (which-id: " << nWID <<
")");
823 SAL_WARN(
"sw.core",
"SwTextBoxHelper::syncProperty: unhandled member-id: "
824 << o3tl::narrowing<sal_uInt16>(nMemberID)
825 <<
" (which-id: " << nWID <<
")");
847 SAL_WARN(
"sw.core",
"SwTextBoxHelper::syncProperty: unhandled member-id: "
848 << o3tl::narrowing<sal_uInt16>(nMemberID)
849 <<
" (which-id: " << nWID <<
")");
879 changeAnchor(pShape, pObj);
884 SAL_WARN(
"sw.core",
"SwTextBoxHelper::syncProperty: unhandled member-id: "
885 << o3tl::narrowing<sal_uInt16>(nMemberID)
886 <<
" (which-id: " << nWID <<
")");
892 uno::Reference<text::XTextRange> xRange;
913 SAL_WARN(
"sw.core",
"SwTextBoxHelper::syncProperty: unhandled member-id: "
914 << o3tl::narrowing<sal_uInt16>(nMemberID)
915 <<
" (which-id: " << nWID <<
")");
938 SAL_WARN(
"sw.core",
"SwTextBoxHelper::syncProperty: unhandled member-id: "
939 << o3tl::narrowing<sal_uInt16>(nMemberID)
940 <<
" (which-id: " << nWID <<
")");
957 SAL_WARN(
"sw.core",
"SwTextBoxHelper::syncProperty: unhandled member-id: "
958 << o3tl::narrowing<sal_uInt16>(nMemberID)
959 <<
" (which-id: " << nWID <<
")");
964 SAL_WARN(
"sw.core",
"SwTextBoxHelper::syncProperty: unhandled which-id: "
965 << nWID <<
" (member-id: "
966 << o3tl::narrowing<sal_uInt16>(nMemberID) <<
")");
970 if (aPropertyName.isEmpty())
974 if (bAdjustX || bAdjustY || bAdjustSize)
976 changeAnchor(pShape, pObj);
981 if (bAdjustX || bAdjustY)
984 if (aValue >>= nValue)
990 else if (bAdjustSize)
999 uno::Reference<beans::XPropertySet>
const xPropertySet(
1001 xPropertySet->setPropertyValue(aPropertyName, aValue);
1005 std::map<const SwFrameFormat*, const SwFrameFormat*>& rLinks)
1007 for (
const auto pFormat : rFormats)
1010 rLinks[pFormat] = pTextBox;
1018 for (
const auto& rIt : rOld)
1020 auto aTextBoxIt = rSavedLinks.find(rIt.GetFormat());
1021 if (aTextBoxIt != rSavedLinks.end())
1024 for (
const auto& rJt : rOld)
1026 if (rJt.GetFormat() == aTextBoxIt->second)
1027 rNew[i]->SetFormatAttr(rNew[j]->GetContent());
1037 text::TextContentAnchorType aAnchorType;
1040 case RndStdIds::FLY_AS_CHAR:
1041 aAnchorType = text::TextContentAnchorType::TextContentAnchorType_AS_CHARACTER;
1043 case RndStdIds::FLY_AT_CHAR:
1044 aAnchorType = text::TextContentAnchorType::TextContentAnchorType_AT_CHARACTER;
1046 case RndStdIds::FLY_AT_PARA:
1047 aAnchorType = text::TextContentAnchorType::TextContentAnchorType_AT_PARAGRAPH;
1049 case RndStdIds::FLY_AT_PAGE:
1050 aAnchorType = text::TextContentAnchorType::TextContentAnchorType_AT_PAGE;
1052 case RndStdIds::FLY_AT_FLY:
1053 aAnchorType = text::TextContentAnchorType::TextContentAnchorType_AT_FRAME;
1056 aAnchorType = text::TextContentAnchorType::TextContentAnchorType_AT_PARAGRAPH;
1057 SAL_WARN(
"sw.core",
"SwTextBoxHelper::mapAnchorType: Unknown AnchorType!");
1071 const bool bLayoutInCell
1081 switch (pItem->
Which())
1086 const text::TextContentAnchorType aNewAnchorType
1090 if (bInlineAnchored || bLayoutInCell)
1096 if (!aRect.IsEmpty())
1097 aOrient.
SetPos(aOrient.GetPos() + aRect.Top());
1102 aTextBoxSet.Put(aOrient);
1106 if (!aRect.IsEmpty())
1109 aTextBoxSet.Put(aSize);
1116 const text::TextContentAnchorType aNewAnchorType
1120 if (bInlineAnchored || bLayoutInCell)
1126 if (!aRect.IsEmpty())
1127 aOrient.
SetPos(aOrient.GetPos() + aRect.Left());
1132 aTextBoxSet.Put(aOrient);
1147 if (!aRect.IsEmpty())
1149 if (!bInlineAnchored)
1158 aTextBoxSet.Put(aVertOrient);
1159 aTextBoxSet.Put(aHoriOrient);
1162 aSize.SetWidth(aRect.getWidth());
1163 aSize.SetHeight(aRect.getHeight());
1164 aTextBoxSet.Put(aSize);
1173 const text::TextContentAnchorType aNewAnchorType
1180 SAL_WARN(
"sw.core",
"SwTextBoxHelper::syncFlyFrameAttr: The anchor of the "
1181 "shape different from the textframe!");
1186 SAL_WARN(
"sw.core",
"SwTextBoxHelper::syncFlyFrameAttr: unhandled which-id: "
1191 pItem = aIter.NextItem();
1192 }
while (pItem && (0 != pItem->
Which()));
1194 if (aTextBoxSet.Count())
1197 DoTextBoxZOrderCorrection(&rShape, pObj);
1204 uno::Reference<drawing::XShape> xShape(pObj->
getUnoShape(), uno::UNO_QUERY);
1207 uno::Reference<beans::XPropertySet>
const xPropertySet(xShape, uno::UNO_QUERY);
1209 auto pParentFormat = getOtherTextBoxFormat(getOtherTextBoxFormat(xShape),
RES_FLYFRMFMT);
1230 const bool bIsAutoGrow
1238 uno::Any(bIsAutoWrap ? text::SizeType::FIX : text::SizeType::MIN), pObj);
1240 changeAnchor(pParentFormat, pObj);
1241 DoTextBoxZOrderCorrection(pParentFormat, pObj);
1246 if (
auto pFormat = getOtherTextBoxFormat(pShape,
RES_DRAWFRMFMT, pObj))
1259 uno::Reference<beans::XPropertySet>
const xPropertySet(
1261 if (pOldCnt && rNewAnch.
GetAnchorId() == RndStdIds::FLY_AT_PAGE
1264 uno::Any aValue(text::TextContentAnchorType_AT_PAGE);
1270 else if (rOldAnch.
GetAnchorId() == RndStdIds::FLY_AT_PAGE && pNewCnt)
1272 if (rNewAnch.
GetAnchorId() == RndStdIds::FLY_AS_CHAR)
1274 uno::Any aValue(text::TextContentAnchorType_AT_CHARACTER);
1277 uno::Any(text::RelOrientation::CHAR));
1279 uno::Any(text::RelOrientation::PRINT_AREA));
1288 aShapeHorRelOrient);
1295 if (rNewAnch.
GetAnchorId() == RndStdIds::FLY_AS_CHAR)
1297 uno::Any aValue(text::TextContentAnchorType_AT_CHARACTER);
1300 uno::Any(text::RelOrientation::CHAR));
1302 uno::Any(text::RelOrientation::PRINT_AREA));
1310 aShapeHorRelOrient);
1315 catch (uno::Exception& e)
1317 SAL_WARN(
"sw.core",
"SwTextBoxHelper::changeAnchor(): " << e.Message);
1320 return doTextBoxPositioning(pShape, pObj) && DoTextBoxZOrderCorrection(pShape, pObj);
1330 if (
auto pFormat = getOtherTextBoxFormat(pShape,
RES_DRAWFRMFMT, pObj))
1383 case text::VertOrientation::TOP:
1384 case text::VertOrientation::CHAR_TOP:
1385 case text::VertOrientation::LINE_TOP:
1391 case text::VertOrientation::BOTTOM:
1392 case text::VertOrientation::CHAR_BOTTOM:
1393 case text::VertOrientation::LINE_BOTTOM:
1399 case text::VertOrientation::CENTER:
1400 case text::VertOrientation::CHAR_CENTER:
1401 case text::VertOrientation::LINE_CENTER:
1403 aNewVOri.SetPos(aNewVOri.GetPos()
1428 (bIsGroupObj && pObj ? pObj->
GetRelativePos().getX() : aNewHOri.GetPos())
1432 (bIsGroupObj && pObj ? pObj->
GetRelativePos().getY() : aNewVOri.GetPos())
1436 const auto& nInshapePos
1444 aNewHOri.SetRelationOrient(text::RelOrientation::PAGE_FRAME);
1452 aNewVOri.SetRelationOrient(text::RelOrientation::PAGE_FRAME);
1470 if (
auto pFlyFormat = pFly->GetFlyFormat())
1472 nTableOffset.setX(pFlyFormat->GetHoriOrient().GetPos());
1473 nTableOffset.setY(pFlyFormat->GetVertOrient().GetPos());
1481 if (
auto pTableFormat = pTableNode->GetTable().GetFrameFormat())
1483 nTableOffset.setX(pTableFormat->GetHoriOrient().GetPos());
1484 nTableOffset.setY(pTableFormat->GetVertOrient().GetPos());
1489 aNewHOri.SetPos(aNewHOri.GetPos() + nTableOffset.getX() + nLeftSpace);
1492 == text::RelOrientation::PAGE_PRINT_AREA)
1493 aNewVOri.SetPos(aNewVOri.GetPos() + nTableOffset.getY());
1507 if (!pShape || !pObj)
1510 if (
auto pTextBox = getOtherTextBoxFormat(pShape,
RES_DRAWFRMFMT, pObj))
1512 const auto& rSize = getRelativeTextRectangle(pObj).GetSize();
1513 if (!rSize.IsEmpty())
1517 return pTextBox->SetFormatAttr(aSize);
1533 auto pTextBox = getOtherTextBoxFormat(pShape,
RES_DRAWFRMFMT, pObj);
1534 SdrObject* pFrmObj = pTextBox->FindRealSdrObject();
1539 = SwXTextFrame::GetOrCreateSdrObject(*dynamic_cast<SwFlyFrameFormat*>(pTextBox));
1549 auto pPage = pDrawModel->
GetPage(0);
1553 sal_uInt16 nIterator = 0;
1565 if (pPage->GetObjCount() == pFrmObj->
GetOrdNum())
1568 if (nIterator > 300)
1571 pPage->RecalcObjOrdNums();
1574 SAL_WARN(
"sw.core",
"SwTextBoxHelper::DoTextBoxZOrderCorrection(): "
1575 "No Valid Draw model for SdrObject for the shape!");
1577 SAL_WARN(
"sw.core",
"SwTextBoxHelper::DoTextBoxZOrderCorrection(): "
1578 "No Valid SdrObject for the frame!");
1580 SAL_WARN(
"sw.core",
"SwTextBoxHelper::DoTextBoxZOrderCorrection(): "
1581 "No Valid SdrObject for the shape!");
1591 for (
size_t i = 0;
i < pChildren->GetObjCount(); ++
i)
1592 synchronizeGroupTextBoxProperty(pFunc, pFormat, pChildren->GetObj(
i));
1596 (*pFunc)(pFormat, pObj);
1603 std::vector<SwFrameFormat*> vRet;
1606 for (
size_t i = 0;
i < pChildren->GetObjCount(); ++
i)
1608 auto pChildTextBoxes = CollectTextBoxes(pChildren->GetObj(
i), pFormat);
1609 for (
auto& rChildTextBox : pChildTextBoxes)
1610 vRet.push_back(rChildTextBox);
1616 vRet.push_back(getOtherTextBoxFormat(pFormat,
RES_DRAWFRMFMT, pGroupObject));
1623 assert(pOwnerShape);
1626 m_pOwnerShapeFormat = pOwnerShape;
1627 if (!m_pTextBoxes.empty())
1628 m_pTextBoxes.clear();
1635 assert(pNewTextBox);
1638 assert(pDrawObject);
1644 auto pSwFlyDraw =
dynamic_cast<SwFlyDrawObj*
>(pDrawObject);
1649 m_pTextBoxes.push_back(aElem);
1654 assert(pDrawObject);
1655 if (m_pTextBoxes.empty())
1658 for (
auto it = m_pTextBoxes.begin(); it != m_pTextBoxes.end();)
1660 if (it->m_pDrawObject == pDrawObject)
1664 m_pOwnerShapeFormat->GetDoc()->getIDocumentLayoutAccess().DelLayoutFormat(
1665 it->m_pTextBoxFormat);
1672 it = m_pTextBoxes.erase(it);
1682 if (m_pTextBoxes.empty())
1685 for (
auto it = m_pTextBoxes.begin(); it != m_pTextBoxes.end();)
1687 if (it->m_pTextBoxFormat == pTextBox)
1691 m_pOwnerShapeFormat->GetDoc()->getIDocumentLayoutAccess().DelLayoutFormat(
1692 it->m_pTextBoxFormat);
1699 it = m_pTextBoxes.erase(it);
1709 assert(pDrawObject);
1710 if (!m_pTextBoxes.empty())
1712 for (
auto it = m_pTextBoxes.begin(); it != m_pTextBoxes.end(); it++)
1714 if (it->m_pDrawObject == pDrawObject)
1716 return it->m_pTextBoxFormat;
1725 assert(pDrawObject);
1727 if (!m_pTextBoxes.empty())
1729 for (
auto it = m_pTextBoxes.begin(); it != m_pTextBoxes.end(); it++)
1731 if (it->m_pDrawObject == pDrawObject)
1733 return it->m_bIsActive;
1742 assert(pDrawObject);
1744 if (!m_pTextBoxes.empty())
1746 for (
auto it = m_pTextBoxes.begin(); it != m_pTextBoxes.end(); it++)
1748 if (it->m_pDrawObject == pDrawObject)
1750 it->m_bIsActive =
true;
1758 assert(pDrawObject);
1760 if (!m_pTextBoxes.empty())
1762 for (
auto it = m_pTextBoxes.begin(); it != m_pTextBoxes.end(); it++)
1764 if (it->m_pDrawObject == pDrawObject)
1766 it->m_bIsActive =
false;
1776 std::map<SdrObject*, SwFrameFormat*> aRet;
1777 for (
auto& rElem : m_pTextBoxes)
1779 aRet.emplace(rElem.m_pDrawObject, rElem.m_pTextBoxFormat);
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
If we have an associated TextFrame, then return that.
void SetTextBox(bool bIsTextBox)
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
static sal_Int32 getCount(const SwDoc &rDoc)
Count number of shapes in the document, excluding TextBoxes.
SwFrameFormat * GetTextBox(const SdrObject *pDrawObject) const
static css::uno::Any getByIndex(SdrPage const *pPage, sal_Int32 nIndex)
Get a shape by index, excluding TextBoxes.
virtual const tools::Rectangle & GetCurrentBoundRect() const
void SetHeight(tools::Long n)
#define UNO_NAME_HORI_ORIENT_POSITION
constexpr OUStringLiteral UNO_NAME_TEXT_HORZADJUST
static void lcl_queryInterface(const SwFrameFormat *pShape, uno::Any &rAny, SdrObject *pObj)
SwDocShell * GetDocShell()
#define UNO_NAME_BOTTOM_BORDER
virtual SdrObjList * getChildrenOfSdrObject() const
static bool hasTextFrame(const SdrObject *pObj)
Returns true if the SdrObject has a SwTextFrame otherwise false.
#define UNO_NAME_RELATIVE_HEIGHT_RELATION
#define UNO_NAME_IS_FOLLOWING_TEXT_FLOW
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
#define UNO_NAME_ALLOW_OVERLAP
constexpr TypedWhichId< SdrTextVertAdjustItem > RES_TEXT_VERT_ADJUST(130)
SwFrameFormat * m_pTextBoxFormat
virtual void SetModified()=0
Must be called manually at changes of format.
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
virtual Point GetRelativePos() const
#define MID_VERTORIENT_RELATION
static sal_Int32 getOrdNum(const SdrObject *pObject)
Get the order of the shape, excluding TextBoxes.
SdrObject * GetObj(size_t nNum) const
const css::uno::WeakReference< css::drawing::XShape > & getWeakUnoShape() const
virtual bool IsTextBox() const
size_t GetObjCount() const
OUString GetUniqueFrameName() const
#define RIGHT_BORDER_DISTANCE
constexpr OUStringLiteral UNO_NAME_TEXT_UPPERDIST
Textboxes are basically textframe + shape pairs.
Content, content of frame (header, footer, fly).
constexpr TypedWhichId< SvxOpaqueItem > RES_OPAQUE(99)
#define UNO_NAME_WRITING_MODE
#define UNO_NAME_ANCHOR_PAGE_NO
#define UNO_NAME_VERT_ORIENT
IDocumentUndoRedo & GetIDocumentUndoRedo()
EmbeddedObjectRef * pObject
WhichRangesContainer const aFrameFormatSetRange(svl::Items< RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, XATTR_FILL_FIRST, XATTR_FILL_LAST >)
static css::uno::Any queryInterface(const SwFrameFormat *pShape, const css::uno::Type &rType, SdrObject *pObj)
Get interface of a shape's TextBox, if there is any.
const SwFrameFormats * GetSpzFrameFormats() const
std::map< const SwFrameFormat *, const SwFrameFormat * > SavedLink
Maps a draw format to a fly format.
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
void AddTextBox(SdrObject *pDrawObject, SwFrameFormat *pNewTextBox)
constexpr OUStringLiteral UNO_NAME_TEXT_VERTADJUST
constexpr OUStringLiteral UNO_NAME_TEXT_LEFTDIST
virtual const tools::Rectangle & GetSnapRect() const
constexpr auto convertTwipToMm100(N n)
static css::uno::Reference< css::text::XTextFrame > getUnoTextFrame(css::uno::Reference< css::drawing::XShape > const &xShape)
If we have an associated TextFrame, then return its XTextFrame.
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
#define UNO_NAME_RELATIVE_WIDTH_RELATION
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
#define UNO_NAME_CHAIN_NEXT_NAME
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
SdrPage * getSdrPageFromSdrObject() const
constexpr OUStringLiteral UNO_NAME_FILL_TRANSPARENCE
#define MID_FOLLOW_TEXT_FLOW
virtual css::uno::Reference< css::drawing::XShape > getUnoShape()
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
Is the frame format a text box?
#define UNO_NAME_VERT_ORIENT_RELATION
static tools::Rectangle getRelativeTextRectangle(SdrObject *pShape)
Return the textbox rectangle of a draw shape (in relative twips).
constexpr TypedWhichId< SwFormatWrapInfluenceOnObjPos > RES_WRAP_INFLUENCE_ON_OBJPOS(125)
#define LEFT_BORDER_DISTANCE
static void saveLinks(const SwFrameFormats &rFormats, std::map< const SwFrameFormat *, const SwFrameFormat * > &rLinks)
Saves the current shape -> textbox links in a map, so they can be restored later. ...
constexpr OUStringLiteral UNO_NAME_TEXT_WORDWRAP
#define UNO_NAME_HORI_ORIENT
#define MID_CHAIN_NEXTNAME
static void synchronizeGroupTextBoxProperty(bool pFunc(SwFrameFormat *, SdrObject *), SwFrameFormat *pFormat, SdrObject *pObj)
Calls the method given by pFunc with every textboxes of the group given by pFormat.
#define MID_ANCHOR_ANCHORTYPE
#define MID_HORIORIENT_POSITION
static void updateTextBoxMargin(SdrObject *pObj)
Copy shape attributes to the text frame.
#define UNO_NAME_RIGHT_BORDER
T & StaticWhichCast(TypedWhichId< T > nId)
#define MID_FRMSIZE_WIDTH_TYPE
static void set(SwFrameFormat *pShape, SdrObject *pObject, css::uno::Reference< css::text::XTextFrame > xNew)
Sets the given textframe as textbox for the given (group member) shape.
constexpr OUStringLiteral UNO_NAME_TEXT_RIGHTDIST
static void restoreLinks(std::set< ZSortFly > &rOld, std::vector< SwFrameFormat * > &rNew, SavedLink &rSavedLinks)
Undo the effect of saveLinks() + individual resetLink() calls.
#define UNO_NAME_PARA_ADJUST
constexpr OUStringLiteral UNO_NAME_TEXT_AUTOGROWHEIGHT
#define MID_VERTORIENT_POSITION
tools::Long GetLeft() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
#define BOTTOM_BORDER_DISTANCE
static bool syncTextBoxSize(SwFrameFormat *pShape, SdrObject *pObj)
Sets the correct size of textframe depending on the given SdrObject.
static css::text::TextContentAnchorType mapAnchorType(const RndStdIds &rAnchorID)
There are two types of enum of anchor type, so this function maps this.
static void getProperty(SwFrameFormat const *pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, css::uno::Any &rValue)
Get a property of the underlying TextFrame.
css::uno::Reference< css::frame::XModel3 > GetBaseModel() const
sal_uInt32 GetOrdNum() const
IDocumentState const & getIDocumentState() const
#define UNO_NAME_LEFT_BORDER
#define MID_FRMSIZE_IS_AUTO_HEIGHT
static bool changeAnchor(SwFrameFormat *pShape, SdrObject *pObj)
Sets the anchor of the associated textframe of the given shape, and returns true on success...
tools::Long GetHeight() const
#define UNO_NAME_LEFT_BORDER_DISTANCE
#define UNO_NAME_CHAIN_PREV_NAME
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange,::sw::TextRangeMode const eMode)
#define UNO_NAME_RIGHT_MARGIN
SdrObject * m_pDrawObject
#define UNO_NAME_TOP_BORDER
#define UNO_NAME_TOP_BORDER_DISTANCE
#define UNO_NAME_TEXT_VERT_ADJUST
#define UNO_NAME_SURROUND
#define MID_HORIORIENT_ORIENT
#define MID_FRMSIZE_REL_HEIGHT_RELATION
constexpr TypedWhichId< SwFormatChain > RES_CHAIN(114)
#define MID_CHAIN_PREVNAME
iterator find(const OUString &rKey)
#define UNO_NAME_LEFT_MARGIN
#define MID_VERTORIENT_ORIENT
#define UNO_NAME_BOTTOM_BORDER_DISTANCE
#define UNO_NAME_ANCHOR_TYPE
bool IsTextBoxActive(const SdrObject *pDrawObject) const
#define MID_FRMSIZE_REL_WIDTH_RELATION
#define SAL_INFO(area, stream)
void SetTextBoxActive(const SdrObject *pDrawObject)
bool IsGroupTextBox() const
static void destroy(const SwFrameFormat *pShape, const SdrObject *pObject)
Destroy a TextBox for a shape.
#define UNO_NAME_HORI_ORIENT_RELATION
static SW_DLLPUBLIC css::uno::Reference< css::text::XTextFrame > CreateXTextFrame(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
#define TOP_BORDER_DISTANCE
void SetSize(const Size &rSize)
static css::uno::Reference< css::uno::XInterface > MakeInstance(SwServiceType nObjectType, SwDoc &rDoc)
bool GetTextBounds(tools::Rectangle &rTextBound) const
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
static void syncFlyFrameAttr(SwFrameFormat &rShape, SfxItemSet const &rSet, SdrObject *pObj)
Similar to syncProperty(), but used by the internal API (e.g. for UI purposes).
constexpr TypedWhichId< SvxBoxItem > RES_BOX(106)
SdrObject * getParentSdrObjectFromSdrObject() const
SwTableNode * FindTableNode()
Search table node, in which it is.
#define UNO_NAME_FRAME_ISAUTOMATIC_HEIGHT
#define MID_HORIORIENT_RELATION
const SwStartNode * FindFlyStartNode() const
#define SAL_WARN(area, stream)
#define UNO_NAME_SIZE_TYPE
virtual const tools::Rectangle & GetLogicRect() const
static void create(SwFrameFormat *pShape, SdrObject *pObject, bool bCopyText=false)
Create a TextBox for a shape.
static bool DoTextBoxZOrderCorrection(SwFrameFormat *pShape, const SdrObject *pObj)
constexpr OUStringLiteral UNO_NAME_TEXT_LOWERDIST
#define UNO_NAME_RIGHT_BORDER_DISTANCE
#define UNO_NAME_WIDTH_TYPE
#define UNO_NAME_VERT_ORIENT_POSITION
static void syncProperty(SwFrameFormat *pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, const css::uno::Any &rValue, SdrObject *pObj=nullptr)
Sync property of TextBox with the one of the shape.
constexpr TypedWhichId< SwFormatFollowTextFlow > RES_FOLLOW_TEXT_FLOW(123)
static std::vector< SwFrameFormat * > CollectTextBoxes(const SdrObject *pGroupObject, SwFrameFormat *pFormat)
Collect all textboxes of the group given by the pGroupObj Parameter.
constexpr OUStringLiteral UNO_NAME_TEXT_WRITINGMODE
std::map< SdrObject *, SwFrameFormat * > GetAllTextBoxes() const
void SetTextBoxInactive(const SdrObject *pDrawObject)
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
const SwAttrPool & GetAttrPool() const
void DelTextBox(const SdrObject *pDrawObject, bool bDelFromDoc=false)
#define MID_ALLOW_OVERLAP
static void getShapeWrapThrough(const SwFrameFormat *pTextBox, bool &rWrapThrough)
If pTextBox is a textbox, then set rWrapThrough to the surround of its shape.
static bool doTextBoxPositioning(SwFrameFormat *pShape, SdrObject *pObj)
Does the positioning for the associated textframe of the shape, and returns true on success...