LibreOffice Module sw (master)  1
textboxhelper.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #include <textboxhelper.hxx>
11 #include <fmtcntnt.hxx>
12 #include <fmtanchr.hxx>
13 #include <fmtcnct.hxx>
14 #include <fmtornt.hxx>
15 #include <fmtfsize.hxx>
16 #include <doc.hxx>
18 #include <IDocumentState.hxx>
19 #include <docsh.hxx>
20 #include <unocoll.hxx>
21 #include <unoframe.hxx>
22 #include <unodraw.hxx>
23 #include <unotextrange.hxx>
24 #include <cmdid.h>
25 #include <unomid.h>
26 #include <unoprnms.hxx>
27 #include <mvsave.hxx>
28 #include <fmtsrnd.hxx>
29 #include <frmfmt.hxx>
30 #include <frameformats.hxx>
31 
32 #include <editeng/unoprnms.hxx>
33 #include <editeng/memberids.h>
34 #include <svx/svdoashp.hxx>
35 #include <svx/svdpage.hxx>
36 #include <svl/itemiter.hxx>
38 #include <sal/log.hxx>
39 #include <tools/UnitConversion.hxx>
40 
41 #include <com/sun/star/document/XActionLockable.hpp>
42 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
43 #include <com/sun/star/text/SizeType.hpp>
44 #include <com/sun/star/text/TextContentAnchorType.hpp>
45 #include <com/sun/star/text/WrapTextMode.hpp>
46 #include <com/sun/star/text/XTextDocument.hpp>
47 #include <com/sun/star/table/BorderLine2.hpp>
48 #include <com/sun/star/text/WritingMode.hpp>
49 #include <com/sun/star/text/WritingMode2.hpp>
50 #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
51 #include <com/sun/star/style/ParagraphAdjust.hpp>
52 
53 using namespace com::sun::star;
54 
55 void SwTextBoxHelper::create(SwFrameFormat* pShape, bool bCopyText)
56 {
57  // If TextBox wasn't enabled previously
58  if (pShape->GetAttrSet().HasItem(RES_CNTNT) && pShape->GetOtherTextBoxFormat())
59  return;
60 
61  // Store the current text content of the shape
62  OUString sCopyableText;
63 
64  if (bCopyText)
65  {
66  if (auto pSdrShape = pShape->FindRealSdrObject())
67  {
68  uno::Reference<text::XText> xSrcCnt(pSdrShape->getWeakUnoShape(), uno::UNO_QUERY);
69  auto xCur = xSrcCnt->createTextCursor();
70  xCur->gotoStart(false);
71  xCur->gotoEnd(true);
72  sCopyableText = xCur->getText()->getString();
73  }
74  }
75 
76  // Create the associated TextFrame and insert it into the document.
77  uno::Reference<text::XTextContent> xTextFrame(
79  uno::UNO_QUERY);
80  uno::Reference<text::XTextDocument> xTextDocument(
81  pShape->GetDoc()->GetDocShell()->GetBaseModel(), uno::UNO_QUERY);
82  uno::Reference<text::XTextContentAppend> xTextContentAppend(xTextDocument->getText(),
83  uno::UNO_QUERY);
84  try
85  {
86  SdrObject* pSourceSDRShape = pShape->FindRealSdrObject();
87  uno::Reference<text::XTextContent> XSourceShape(pSourceSDRShape->getUnoShape(),
88  uno::UNO_QUERY_THROW);
89  xTextContentAppend->insertTextContentWithProperties(
90  xTextFrame, uno::Sequence<beans::PropertyValue>(), XSourceShape->getAnchor());
91  }
92  catch (uno::Exception&)
93  {
94  // Before the textframe was appended now it is inserted to the begin of the doc in order
95  // to prevent crash when someone removes the para where the textframe anchored:
96  uno::Reference<text::XTextCursor> xCursor = xTextDocument->getText()->createTextCursor();
97  xCursor->gotoStart(false);
98  xTextContentAppend->insertTextContentWithProperties(
99  xTextFrame, uno::Sequence<beans::PropertyValue>(), xCursor->getStart());
100  }
101  // Link FLY and DRAW formats, so it becomes a text box (needed for syncProperty calls).
102  uno::Reference<text::XTextFrame> xRealTextFrame(xTextFrame, uno::UNO_QUERY);
103  auto pTextFrame = dynamic_cast<SwXTextFrame*>(xRealTextFrame.get());
104  assert(nullptr != pTextFrame);
105  SwFrameFormat* pFormat = pTextFrame->GetFrameFormat();
106 
107  assert(nullptr != dynamic_cast<SwDrawFrameFormat*>(pShape));
108  assert(nullptr != dynamic_cast<SwFlyFrameFormat*>(pFormat));
109 
110  pShape->SetOtherTextBoxFormat(pFormat);
111  pFormat->SetOtherTextBoxFormat(pShape);
112 
113  // Initialize properties.
114  uno::Reference<beans::XPropertySet> xPropertySet(xTextFrame, uno::UNO_QUERY);
115  uno::Any aEmptyBorder = uno::makeAny(table::BorderLine2());
116  xPropertySet->setPropertyValue(UNO_NAME_TOP_BORDER, aEmptyBorder);
117  xPropertySet->setPropertyValue(UNO_NAME_BOTTOM_BORDER, aEmptyBorder);
118  xPropertySet->setPropertyValue(UNO_NAME_LEFT_BORDER, aEmptyBorder);
119  xPropertySet->setPropertyValue(UNO_NAME_RIGHT_BORDER, aEmptyBorder);
120 
121  xPropertySet->setPropertyValue(UNO_NAME_FILL_TRANSPARENCE, uno::makeAny(sal_Int32(100)));
122 
123  xPropertySet->setPropertyValue(UNO_NAME_SIZE_TYPE, uno::makeAny(text::SizeType::FIX));
124 
125  xPropertySet->setPropertyValue(UNO_NAME_SURROUND, uno::makeAny(text::WrapTextMode_THROUGH));
126 
127  uno::Reference<container::XNamed> xNamed(xTextFrame, uno::UNO_QUERY);
128  xNamed->setName(pShape->GetDoc()->GetUniqueFrameName());
129 
130  // Link its text range to the original shape.
131  uno::Reference<text::XTextRange> xTextBox(xTextFrame, uno::UNO_QUERY_THROW);
132  SwUnoInternalPaM aInternalPaM(*pShape->GetDoc());
133  if (sw::XTextRangeToSwPaM(aInternalPaM, xTextBox))
134  {
135  SwAttrSet aSet(pShape->GetAttrSet());
136  SwFormatContent aContent(aInternalPaM.GetNode().StartOfSectionNode());
137  aSet.Put(aContent);
138  pShape->SetFormatAttr(aSet);
139  }
140 
141  // Also initialize the properties, which are not constant, but inherited from the shape's ones.
142  uno::Reference<drawing::XShape> xShape(pShape->FindRealSdrObject()->getUnoShape(),
143  uno::UNO_QUERY);
144  syncProperty(pShape, RES_FRM_SIZE, MID_FRMSIZE_SIZE, uno::makeAny(xShape->getSize()));
145 
146  uno::Reference<beans::XPropertySet> xShapePropertySet(xShape, uno::UNO_QUERY);
147  syncProperty(pShape, RES_FOLLOW_TEXT_FLOW, MID_FOLLOW_TEXT_FLOW,
148  xShapePropertySet->getPropertyValue(UNO_NAME_IS_FOLLOWING_TEXT_FLOW));
149  syncProperty(pShape, RES_ANCHOR, MID_ANCHOR_ANCHORTYPE,
150  xShapePropertySet->getPropertyValue(UNO_NAME_ANCHOR_TYPE));
151  syncProperty(pShape, RES_HORI_ORIENT, MID_HORIORIENT_ORIENT,
152  xShapePropertySet->getPropertyValue(UNO_NAME_HORI_ORIENT));
153  syncProperty(pShape, RES_HORI_ORIENT, MID_HORIORIENT_RELATION,
154  xShapePropertySet->getPropertyValue(UNO_NAME_HORI_ORIENT_RELATION));
155  syncProperty(pShape, RES_VERT_ORIENT, MID_VERTORIENT_ORIENT,
156  xShapePropertySet->getPropertyValue(UNO_NAME_VERT_ORIENT));
157  syncProperty(pShape, RES_VERT_ORIENT, MID_VERTORIENT_RELATION,
158  xShapePropertySet->getPropertyValue(UNO_NAME_VERT_ORIENT_RELATION));
159  syncProperty(pShape, RES_HORI_ORIENT, MID_HORIORIENT_POSITION,
160  xShapePropertySet->getPropertyValue(UNO_NAME_HORI_ORIENT_POSITION));
161  syncProperty(pShape, RES_VERT_ORIENT, MID_VERTORIENT_POSITION,
162  xShapePropertySet->getPropertyValue(UNO_NAME_VERT_ORIENT_POSITION));
163  syncProperty(pShape, RES_FRM_SIZE, MID_FRMSIZE_IS_AUTO_HEIGHT,
164  xShapePropertySet->getPropertyValue(UNO_NAME_TEXT_AUTOGROWHEIGHT));
165  syncProperty(pShape, RES_TEXT_VERT_ADJUST, 0,
166  xShapePropertySet->getPropertyValue(UNO_NAME_TEXT_VERT_ADJUST));
167  text::WritingMode eMode;
168  if (xShapePropertySet->getPropertyValue(UNO_NAME_TEXT_WRITINGMODE) >>= eMode)
169  syncProperty(pShape, RES_FRAMEDIR, 0, uno::makeAny(sal_Int16(eMode)));
170 
171  // TODO: Text dialog attr setting to frame
172 
173  const SwFormatAnchor& rAnch = pShape->GetAnchor();
174  if (!((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PAGE && rAnch.GetPageNum() != 0)
175  || ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PARA
176  || rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR)
177  && rAnch.GetContentAnchor())))
178  return;
179 
180  SfxItemSet aTxFrmSet(pFormat->GetDoc()->GetAttrPool(), aFrameFormatSetRange);
181 
182  if (rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR
183  || rAnch.GetAnchorId() == RndStdIds::FLY_AT_PARA)
184  aTxFrmSet.Put(rAnch);
185 
186  SwFormatVertOrient aVOri(pFormat->GetVertOrient());
187  SwFormatHoriOrient aHOri(pFormat->GetHoriOrient());
188  aVOri.SetVertOrient(pShape->GetVertOrient().GetVertOrient());
189  aHOri.SetHoriOrient(pShape->GetHoriOrient().GetHoriOrient());
190  aVOri.SetRelationOrient(pShape->GetVertOrient().GetRelationOrient());
191  aHOri.SetRelationOrient(pShape->GetHoriOrient().GetRelationOrient());
192  aTxFrmSet.Put(aVOri);
193  aTxFrmSet.Put(aHOri);
194 
195  if (aTxFrmSet.Count())
196  pFormat->SetFormatAttr(aTxFrmSet);
197 
198  // Check if the shape had text before and move it to the new textframe
199  if (bCopyText && !sCopyableText.isEmpty())
200  {
201  auto pSdrShape = pShape->FindRealSdrObject();
202  if (pSdrShape)
203  {
204  auto pSourceText = dynamic_cast<SdrTextObj*>(pSdrShape);
205  uno::Reference<text::XTextRange> xDestText(xRealTextFrame, uno::UNO_QUERY);
206 
207  xDestText->setString(sCopyableText);
208 
209  if (pSourceText)
210  pSourceText->SetText(OUString());
211 
212  pShape->GetDoc()->getIDocumentState().SetModified();
213  }
214  }
215 }
216 
218 {
219  // If a TextBox was enabled previously
220  if (pShape->GetAttrSet().HasItem(RES_CNTNT))
221  {
222  SwFrameFormat* pFormat = pShape->GetOtherTextBoxFormat();
223 
224  // Unlink the TextBox's text range from the original shape.
225  pShape->ResetFormatAttr(RES_CNTNT);
226 
227  // Delete the associated TextFrame.
228  if (pFormat)
229  pShape->GetDoc()->getIDocumentLayoutAccess().DelLayoutFormat(pFormat);
230  }
231 }
232 
233 bool SwTextBoxHelper::isTextBox(const SwFrameFormat* pFormat, sal_uInt16 nType)
234 {
235  assert(nType == RES_FLYFRMFMT || nType == RES_DRAWFRMFMT);
236  if (!pFormat || pFormat->Which() != nType || !pFormat->GetAttrSet().HasItem(RES_CNTNT))
237  return false;
238 
239  sal_uInt16 nOtherType = (pFormat->Which() == RES_FLYFRMFMT) ? sal_uInt16(RES_DRAWFRMFMT)
240  : sal_uInt16(RES_FLYFRMFMT);
241  SwFrameFormat* pOtherFormat = pFormat->GetOtherTextBoxFormat();
242  if (!pOtherFormat)
243  return false;
244 
245  assert(pOtherFormat->Which() == nOtherType);
246  if (pOtherFormat->Which() != nOtherType)
247  return false;
248 
249  const SwFormatContent& rContent = pFormat->GetContent();
250  return pOtherFormat->GetAttrSet().HasItem(RES_CNTNT) && pOtherFormat->GetContent() == rContent;
251 }
252 
254 {
255  if (!pObj)
256  return false;
257 
258  uno::Reference<drawing::XShape> xShape(pObj->getWeakUnoShape(), uno::UNO_QUERY);
259  if (!xShape)
260  return false;
262 }
263 
264 sal_Int32 SwTextBoxHelper::getCount(SdrPage const* pPage)
265 {
266  sal_Int32 nRet = 0;
267  for (std::size_t i = 0; i < pPage->GetObjCount(); ++i)
268  {
269  SdrObject* p = pPage->GetObj(i);
270  if (p && p->IsTextBox())
271  continue;
272  ++nRet;
273  }
274  return nRet;
275 }
276 
277 sal_Int32 SwTextBoxHelper::getCount(const SwDoc& rDoc)
278 {
279  sal_Int32 nRet = 0;
280  const SwFrameFormats& rSpzFrameFormats = *rDoc.GetSpzFrameFormats();
281  for (const auto pFormat : rSpzFrameFormats)
282  {
283  if (isTextBox(pFormat, RES_FLYFRMFMT))
284  ++nRet;
285  }
286  return nRet;
287 }
288 
289 uno::Any SwTextBoxHelper::getByIndex(SdrPage const* pPage, sal_Int32 nIndex)
290 {
291  if (nIndex < 0)
292  throw lang::IndexOutOfBoundsException();
293 
294  SdrObject* pRet = nullptr;
295  sal_Int32 nCount = 0; // Current logical index.
296  for (std::size_t i = 0; i < pPage->GetObjCount(); ++i)
297  {
298  SdrObject* p = pPage->GetObj(i);
299  if (p && p->IsTextBox())
300  continue;
301  if (nCount == nIndex)
302  {
303  pRet = p;
304  break;
305  }
306  ++nCount;
307  }
308 
309  if (!pRet)
310  throw lang::IndexOutOfBoundsException();
311 
312  return uno::makeAny(uno::Reference<drawing::XShape>(pRet->getUnoShape(), uno::UNO_QUERY));
313 }
314 
315 sal_Int32 SwTextBoxHelper::getOrdNum(const SdrObject* pObject)
316 {
317  if (const SdrPage* pPage = pObject->getSdrPageFromSdrObject())
318  {
319  sal_Int32 nOrder = 0; // Current logical order.
320  for (std::size_t i = 0; i < pPage->GetObjCount(); ++i)
321  {
322  SdrObject* p = pPage->GetObj(i);
323  if (p && p->IsTextBox())
324  continue;
325  if (p == pObject)
326  return nOrder;
327  ++nOrder;
328  }
329  }
330 
331  SAL_WARN("sw.core", "SwTextBoxHelper::getOrdNum: no page or page doesn't contain the object");
332  return pObject->GetOrdNum();
333 }
334 
335 void SwTextBoxHelper::getShapeWrapThrough(const SwFrameFormat* pTextBox, bool& rWrapThrough)
336 {
338  if (pShape)
339  rWrapThrough = pShape->GetSurround().GetSurround() == css::text::WrapTextMode_THROUGH;
340 }
341 
343  sal_uInt16 nType)
344 {
345  if (!isTextBox(pFormat, nType))
346  return nullptr;
347  return pFormat->GetOtherTextBoxFormat();
348 }
349 
350 SwFrameFormat* SwTextBoxHelper::getOtherTextBoxFormat(uno::Reference<drawing::XShape> const& xShape)
351 {
352  auto pShape = dynamic_cast<SwXShape*>(xShape.get());
353  if (!pShape)
354  return nullptr;
355 
356  SwFrameFormat* pFormat = pShape->GetFrameFormat();
357  return getOtherTextBoxFormat(pFormat, RES_DRAWFRMFMT);
358 }
359 
360 template <typename T> static void lcl_queryInterface(const SwFrameFormat* pShape, uno::Any& rAny)
361 {
363  {
364  uno::Reference<T> const xInterface(
365  SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), pFormat), uno::UNO_QUERY);
366  rAny <<= xInterface;
367  }
368 }
369 
371 {
372  uno::Any aRet;
373 
375  {
376  lcl_queryInterface<text::XTextAppend>(pShape, aRet);
377  }
378  else if (rType == cppu::UnoType<css::text::XText>::get())
379  {
380  lcl_queryInterface<text::XText>(pShape, aRet);
381  }
382  else if (rType == cppu::UnoType<css::text::XTextRange>::get())
383  {
384  lcl_queryInterface<text::XTextRange>(pShape, aRet);
385  }
386 
387  return aRet;
388 }
389 
391 {
392  tools::Rectangle aRet;
393  aRet.SetEmpty();
394  auto pSdrShape = pShape->FindRealSdrObject();
395  auto pCustomShape = dynamic_cast<SdrObjCustomShape*>(pSdrShape);
396  if (pCustomShape)
397  {
398  // Need to temporarily release the lock acquired in
399  // SdXMLShapeContext::AddShape(), otherwise we get an empty rectangle,
400  // see EnhancedCustomShapeEngine::getTextBounds().
401  uno::Reference<document::XActionLockable> xLockable(pCustomShape->getUnoShape(),
402  uno::UNO_QUERY);
403  sal_Int16 nLocks = 0;
404  if (xLockable.is())
405  nLocks = xLockable->resetActionLocks();
406  pCustomShape->GetTextBounds(aRet);
407  if (nLocks)
408  xLockable->setActionLocks(nLocks);
409  }
410  else if (pSdrShape)
411  {
412  // fallback - get *any* bound rect we can possibly get hold of
413  aRet = pSdrShape->GetCurrentBoundRect();
414  }
415 
416  if (!bAbsolute && pSdrShape)
417  {
418  // Relative, so count the logic (reference) rectangle, see the EnhancedCustomShape2d ctor.
419  Point aPoint(pSdrShape->GetSnapRect().Center());
420  Size aSize(pSdrShape->GetLogicRect().GetSize());
421  aPoint.AdjustX(-(aSize.Width() / 2));
422  aPoint.AdjustY(-(aSize.Height() / 2));
423  tools::Rectangle aLogicRect(aPoint, aSize);
424  aRet.Move(-1 * aLogicRect.Left(), -1 * aLogicRect.Top());
425  }
426 
427  return aRet;
428 }
429 
430 void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, std::u16string_view rPropertyName,
431  const css::uno::Any& rValue)
432 {
433  // Textframes does not have valid horizontal adjust property, so map it to paragraph adjust property
434  if (rPropertyName == UNO_NAME_TEXT_HORZADJUST)
435  {
436  SwFrameFormat* pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT);
437  if (!pFormat)
438  return;
439 
440  auto xTextFrame = SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), pFormat);
441  uno::Reference<text::XTextCursor> xCursor = xTextFrame->getText()->createTextCursor();
442 
443  // Select all paragraphs in the textframe
444  xCursor->gotoStart(false);
445  xCursor->gotoEnd(true);
446  uno::Reference<beans::XPropertySet> xFrameParaProps(xCursor, uno::UNO_QUERY);
447 
448  // And simply map the property
449  switch (rValue.get<drawing::TextHorizontalAdjust>())
450  {
451  case drawing::TextHorizontalAdjust::TextHorizontalAdjust_CENTER:
452  xFrameParaProps->setPropertyValue(
454  uno::makeAny(style::ParagraphAdjust::ParagraphAdjust_CENTER)); //3
455  break;
456  case drawing::TextHorizontalAdjust::TextHorizontalAdjust_LEFT:
457  xFrameParaProps->setPropertyValue(
459  uno::makeAny(style::ParagraphAdjust::ParagraphAdjust_LEFT)); //0
460  break;
461  case drawing::TextHorizontalAdjust::TextHorizontalAdjust_RIGHT:
462  xFrameParaProps->setPropertyValue(
464  uno::makeAny(style::ParagraphAdjust::ParagraphAdjust_RIGHT)); //1
465  break;
466  default:
467  break;
468  }
469  return;
470  }
471 
472  if (rPropertyName == u"CustomShapeGeometry")
473  {
474  // CustomShapeGeometry changes the textbox position offset and size, so adjust both.
475  syncProperty(pShape, RES_FRM_SIZE, MID_FRMSIZE_SIZE, uno::Any());
476 
477  SdrObject* pObject = pShape->FindRealSdrObject();
478  if (pObject)
479  {
480  tools::Rectangle aRectangle(pObject->GetSnapRect());
481  syncProperty(
483  uno::makeAny(static_cast<sal_Int32>(convertTwipToMm100(aRectangle.Left()))));
484  syncProperty(
486  uno::makeAny(static_cast<sal_Int32>(convertTwipToMm100(aRectangle.Top()))));
487  }
488 
489  SwFrameFormat* pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT);
490  if (!pFormat)
491  return;
492 
493  comphelper::SequenceAsHashMap aCustomShapeGeometry(rValue);
494  auto it = aCustomShapeGeometry.find("TextPreRotateAngle");
495  if (it == aCustomShapeGeometry.end())
496  {
497  it = aCustomShapeGeometry.find("TextRotateAngle");
498  }
499 
500  if (it != aCustomShapeGeometry.end())
501  {
502  auto nAngle = it->second.has<sal_Int32>() ? it->second.get<sal_Int32>() : 0;
503  if (nAngle == 0)
504  {
505  nAngle = it->second.has<double>() ? it->second.get<double>() : 0;
506  }
507 
508  sal_Int16 nDirection = 0;
509  switch (nAngle)
510  {
511  case -90:
512  nDirection = text::WritingMode2::TB_RL;
513  break;
514  case -270:
515  nDirection = text::WritingMode2::BT_LR;
516  break;
517  }
518 
519  if (nDirection)
520  {
521  syncProperty(pShape, RES_FRAMEDIR, 0, uno::makeAny(nDirection));
522  }
523  }
524  }
525  else if (rPropertyName == UNO_NAME_TEXT_VERT_ADJUST)
526  syncProperty(pShape, RES_TEXT_VERT_ADJUST, 0, rValue);
527  else if (rPropertyName == UNO_NAME_TEXT_AUTOGROWHEIGHT)
528  syncProperty(pShape, RES_FRM_SIZE, MID_FRMSIZE_IS_AUTO_HEIGHT, rValue);
529  else if (rPropertyName == UNO_NAME_TEXT_LEFTDIST)
530  syncProperty(pShape, RES_BOX, LEFT_BORDER_DISTANCE, rValue);
531  else if (rPropertyName == UNO_NAME_TEXT_RIGHTDIST)
532  syncProperty(pShape, RES_BOX, RIGHT_BORDER_DISTANCE, rValue);
533  else if (rPropertyName == UNO_NAME_TEXT_UPPERDIST)
534  syncProperty(pShape, RES_BOX, TOP_BORDER_DISTANCE, rValue);
535  else if (rPropertyName == UNO_NAME_TEXT_LOWERDIST)
536  syncProperty(pShape, RES_BOX, BOTTOM_BORDER_DISTANCE, rValue);
537  else if (rPropertyName == UNO_NAME_TEXT_WRITINGMODE)
538  {
539  text::WritingMode eMode;
540  if (rValue >>= eMode)
541  syncProperty(pShape, RES_FRAMEDIR, 0, uno::makeAny(sal_Int16(eMode)));
542  }
543 }
544 
545 void SwTextBoxHelper::getProperty(SwFrameFormat const* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID,
546  css::uno::Any& rValue)
547 {
548  if (!pShape)
549  return;
550 
551  nMemberID &= ~CONVERT_TWIPS;
552 
553  SwFrameFormat* pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT);
554  if (!pFormat)
555  return;
556 
557  if (nWID != RES_CHAIN)
558  return;
559 
560  switch (nMemberID)
561  {
562  case MID_CHAIN_PREVNAME:
563  case MID_CHAIN_NEXTNAME:
564  {
565  const SwFormatChain& rChain = pFormat->GetChain();
566  rChain.QueryValue(rValue, nMemberID);
567  }
568  break;
569  case MID_CHAIN_NAME:
570  rValue <<= pFormat->GetName();
571  break;
572  }
573 }
574 
575 void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID,
576  const css::uno::Any& rValue)
577 {
578  // No shape yet? Then nothing to do, initial properties are set by create().
579  if (!pShape)
580  return;
581 
582  uno::Any aValue(rValue);
583  nMemberID &= ~CONVERT_TWIPS;
584 
585  SwFrameFormat* pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT);
586  if (!pFormat)
587  return;
588 
589  OUString aPropertyName;
590  bool bAdjustX = false;
591  bool bAdjustY = false;
592  bool bAdjustSize = false;
593  switch (nWID)
594  {
595  case RES_HORI_ORIENT:
596  switch (nMemberID)
597  {
599  aPropertyName = UNO_NAME_HORI_ORIENT;
600  break;
602  aPropertyName = UNO_NAME_HORI_ORIENT_RELATION;
603  break;
605  aPropertyName = UNO_NAME_HORI_ORIENT_POSITION;
606  bAdjustX = true;
607  break;
608  }
609  break;
610  case RES_LR_SPACE:
611  {
612  switch (nMemberID)
613  {
614  case MID_L_MARGIN:
615  aPropertyName = UNO_NAME_LEFT_MARGIN;
616  break;
617  case MID_R_MARGIN:
618  aPropertyName = UNO_NAME_RIGHT_MARGIN;
619  break;
620  }
621  break;
622  }
623  case RES_VERT_ORIENT:
624  switch (nMemberID)
625  {
627  aPropertyName = UNO_NAME_VERT_ORIENT;
628  break;
630  aPropertyName = UNO_NAME_VERT_ORIENT_RELATION;
631  break;
633  aPropertyName = UNO_NAME_VERT_ORIENT_POSITION;
634  bAdjustY = true;
635  break;
636  }
637  break;
638  case RES_FRM_SIZE:
639  switch (nMemberID)
640  {
642  aPropertyName = UNO_NAME_FRAME_ISAUTOMATIC_HEIGHT;
643  break;
645  aPropertyName = UNO_NAME_RELATIVE_HEIGHT_RELATION;
646  break;
648  aPropertyName = UNO_NAME_RELATIVE_WIDTH_RELATION;
649  break;
650  default:
651  aPropertyName = UNO_NAME_SIZE;
652  bAdjustSize = true;
653  break;
654  }
655  break;
656  case RES_ANCHOR:
657  switch (nMemberID)
658  {
660  {
661  uno::Reference<beans::XPropertySet> const xPropertySet(
662  SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), pFormat),
663  uno::UNO_QUERY);
664  // Surround (Wrap) has to be THROUGH always:
665  xPropertySet->setPropertyValue(UNO_NAME_SURROUND,
666  uno::makeAny(text::WrapTextMode_THROUGH));
667  // Use At_Char anchor instead of As_Char anchoring:
668  if (aValue.get<text::TextContentAnchorType>()
669  == text::TextContentAnchorType::TextContentAnchorType_AS_CHARACTER)
670  {
671  xPropertySet->setPropertyValue(
673  uno::makeAny(
674  text::TextContentAnchorType::TextContentAnchorType_AT_CHARACTER));
675  }
676  else // Otherwise copy the anchor type of the shape
677  {
678  xPropertySet->setPropertyValue(UNO_NAME_ANCHOR_TYPE, aValue);
679  }
680  // After anchoring the position must be set as well:
681  if (aValue.get<text::TextContentAnchorType>()
682  == text::TextContentAnchorType::TextContentAnchorType_AT_PAGE)
683  {
684  xPropertySet->setPropertyValue(
686  uno::makeAny(pShape->GetAnchor().GetPageNum()));
687  }
688 
689  return;
690  }
691  break;
692  }
693  break;
694  case FN_TEXT_RANGE:
695  {
696  uno::Reference<text::XTextRange> xRange;
697  rValue >>= xRange;
698  SwUnoInternalPaM aInternalPaM(*pFormat->GetDoc());
699  if (sw::XTextRangeToSwPaM(aInternalPaM, xRange))
700  {
701  SwFormatAnchor aAnchor(pFormat->GetAnchor());
702  aAnchor.SetAnchor(aInternalPaM.Start());
703  pFormat->SetFormatAttr(aAnchor);
704  }
705  }
706  break;
707  case RES_CHAIN:
708  switch (nMemberID)
709  {
710  case MID_CHAIN_PREVNAME:
711  aPropertyName = UNO_NAME_CHAIN_PREV_NAME;
712  break;
713  case MID_CHAIN_NEXTNAME:
714  aPropertyName = UNO_NAME_CHAIN_NEXT_NAME;
715  break;
716  }
717  break;
719  aPropertyName = UNO_NAME_TEXT_VERT_ADJUST;
720  break;
721  case RES_BOX:
722  switch (nMemberID)
723  {
725  aPropertyName = UNO_NAME_LEFT_BORDER_DISTANCE;
726  break;
728  aPropertyName = UNO_NAME_RIGHT_BORDER_DISTANCE;
729  break;
730  case TOP_BORDER_DISTANCE:
731  aPropertyName = UNO_NAME_TOP_BORDER_DISTANCE;
732  break;
734  aPropertyName = UNO_NAME_BOTTOM_BORDER_DISTANCE;
735  break;
736  }
737  break;
738  case RES_OPAQUE:
739  aPropertyName = UNO_NAME_OPAQUE;
740  break;
741  case RES_FRAMEDIR:
742  aPropertyName = UNO_NAME_WRITING_MODE;
743  break;
745  switch (nMemberID)
746  {
747  case MID_ALLOW_OVERLAP:
748  aPropertyName = UNO_NAME_ALLOW_OVERLAP;
749  break;
750  }
751  break;
752  }
753 
754  if (aPropertyName.isEmpty())
755  return;
756 
757  // Position/size should be the text position/size, not the shape one as-is.
758  if (bAdjustX || bAdjustY || bAdjustSize)
759  {
760  tools::Rectangle aRect = getTextRectangle(pShape, /*bAbsolute=*/false);
761  if (!aRect.IsEmpty())
762  {
763  if (bAdjustX || bAdjustY)
764  {
765  sal_Int32 nValue;
766  if (aValue >>= nValue)
767  {
768  if (bAdjustX)
769  nValue += TWIPS_TO_MM(aRect.getX());
770  else if (bAdjustY)
771  nValue += TWIPS_TO_MM(aRect.getY());
772  aValue <<= nValue;
773  }
774  }
775  else if (bAdjustSize)
776  {
777  awt::Size aSize(TWIPS_TO_MM(aRect.getWidth()), TWIPS_TO_MM(aRect.getHeight()));
778  aValue <<= aSize;
779  }
780  }
781  }
782 
783  uno::Reference<beans::XPropertySet> const xPropertySet(
784  SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), pFormat), uno::UNO_QUERY);
785  xPropertySet->setPropertyValue(aPropertyName, aValue);
786 }
787 
789  std::map<const SwFrameFormat*, const SwFrameFormat*>& rLinks)
790 {
791  for (const auto pFormat : rFormats)
792  {
793  if (SwFrameFormat* pTextBox = getOtherTextBoxFormat(pFormat, RES_DRAWFRMFMT))
794  rLinks[pFormat] = pTextBox;
795  }
796 }
797 
798 void SwTextBoxHelper::restoreLinks(std::set<ZSortFly>& rOld, std::vector<SwFrameFormat*>& rNew,
799  SavedLink& rSavedLinks)
800 {
801  std::size_t i = 0;
802  for (const auto& rIt : rOld)
803  {
804  auto aTextBoxIt = rSavedLinks.find(rIt.GetFormat());
805  if (aTextBoxIt != rSavedLinks.end())
806  {
807  std::size_t j = 0;
808  for (const auto& rJt : rOld)
809  {
810  if (rJt.GetFormat() == aTextBoxIt->second)
811  rNew[i]->SetFormatAttr(rNew[j]->GetContent());
812  ++j;
813  }
814  }
815  ++i;
816  }
817 }
818 
820 {
821  SwFrameFormat* pFormat = getOtherTextBoxFormat(&rShape, RES_DRAWFRMFMT);
822  if (!pFormat)
823  return;
824 
825  SfxItemSet aTextBoxSet(pFormat->GetDoc()->GetAttrPool(), aFrameFormatSetRange);
826 
827  SfxItemIter aIter(rSet);
828  const SfxPoolItem* pItem = aIter.GetCurItem();
829 
830  const RndStdIds aAnchId = rShape.GetAnchor().GetAnchorId();
831  if ((aAnchId == RndStdIds::FLY_AT_PAGE && rShape.GetAnchor().GetPageNum() != 0)
832  || ((aAnchId == RndStdIds::FLY_AT_PARA || aAnchId == RndStdIds::FLY_AT_CHAR)
833  && rShape.GetAnchor().GetContentAnchor()))
834  {
835  SwFormatAnchor aNewAnch = pFormat->GetAnchor();
836  if (rShape.GetAnchor().GetContentAnchor())
837  aNewAnch.SetAnchor(rShape.GetAnchor().GetContentAnchor());
838  if (rShape.GetAnchor().GetPageNum() > 0)
839  aNewAnch.SetPageNum(rShape.GetAnchor().GetPageNum());
840  aNewAnch.SetType(rShape.GetAnchor().GetAnchorId());
841  aTextBoxSet.Put(aNewAnch);
842  }
843  do
844  {
845  switch (pItem->Which())
846  {
847  case RES_VERT_ORIENT:
848  {
849  auto& rOrient = static_cast<const SwFormatVertOrient&>(*pItem);
850  SwFormatVertOrient aOrient(rOrient);
851 
852  tools::Rectangle aRect = getTextRectangle(&rShape, /*bAbsolute=*/false);
853  if (!aRect.IsEmpty())
854  aOrient.SetPos(aOrient.GetPos() + aRect.getY());
855 
856  if (rShape.GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE
857  && rShape.GetAnchor().GetPageNum() != 0)
859  aTextBoxSet.Put(aOrient);
860 
861  // restore height (shrunk for extending beyond the page bottom - tdf#91260)
862  SwFormatFrameSize aSize(pFormat->GetFrameSize());
863  if (!aRect.IsEmpty())
864  {
865  aSize.SetHeight(aRect.getHeight());
866  aTextBoxSet.Put(aSize);
867  }
868  }
869  break;
870  case RES_HORI_ORIENT:
871  {
872  auto& rOrient = static_cast<const SwFormatHoriOrient&>(*pItem);
873  SwFormatHoriOrient aOrient(rOrient);
874 
875  tools::Rectangle aRect = getTextRectangle(&rShape, /*bAbsolute=*/false);
876  if (!aRect.IsEmpty())
877  aOrient.SetPos(aOrient.GetPos() + aRect.getX());
878 
879  if (rShape.GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE
880  && rShape.GetAnchor().GetPageNum() != 0)
882  aTextBoxSet.Put(aOrient);
883  }
884  break;
885  case RES_FRM_SIZE:
886  {
887  // In case the shape got resized, then we need to adjust both
888  // the position and the size of the textbox (e.g. larger
889  // rounded edges of a rectangle -> need to push right/down the
890  // textbox).
891  SwFormatVertOrient aVertOrient(rShape.GetVertOrient());
892  SwFormatHoriOrient aHoriOrient(rShape.GetHoriOrient());
893  SwFormatFrameSize aSize(pFormat->GetFrameSize());
894 
895  tools::Rectangle aRect = getTextRectangle(&rShape, /*bAbsolute=*/false);
896  if (!aRect.IsEmpty())
897  {
898  aVertOrient.SetPos(aVertOrient.GetPos() + aRect.getY());
899  aTextBoxSet.Put(aVertOrient);
900 
901  aHoriOrient.SetPos(aHoriOrient.GetPos() + aRect.getX());
902  aTextBoxSet.Put(aHoriOrient);
903 
904  aSize.SetWidth(aRect.getWidth());
905  aSize.SetHeight(aRect.getHeight());
906  aTextBoxSet.Put(aSize);
907  }
908  }
909  break;
910  default:
911  SAL_WARN("sw.core", "SwTextBoxHelper::syncFlyFrameAttr: unhandled which-id: "
912  << pItem->Which());
913  break;
914  }
915 
916  pItem = aIter.NextItem();
917  } while (pItem && (0 != pItem->Which()));
918 
919  if (aTextBoxSet.Count())
920  pFormat->GetDoc()->SetFlyFrameAttr(*pFormat, aTextBoxSet);
921 }
922 
924 {
925  if (!pObj)
926  return;
927  uno::Reference<drawing::XShape> xShape(pObj->getUnoShape(), uno::UNO_QUERY);
928  if (!xShape)
929  return;
930  uno::Reference<beans::XPropertySet> const xPropertySet(xShape, uno::UNO_QUERY);
931 
932  auto pParentFormat = getOtherTextBoxFormat(getOtherTextBoxFormat(xShape), RES_FLYFRMFMT);
933  if (!pParentFormat)
934  return;
935 
936  // Sync the padding
937  syncProperty(pParentFormat, UNO_NAME_TEXT_LEFTDIST,
938  xPropertySet->getPropertyValue(UNO_NAME_TEXT_LEFTDIST));
939  syncProperty(pParentFormat, UNO_NAME_TEXT_RIGHTDIST,
940  xPropertySet->getPropertyValue(UNO_NAME_TEXT_RIGHTDIST));
941  syncProperty(pParentFormat, UNO_NAME_TEXT_UPPERDIST,
942  xPropertySet->getPropertyValue(UNO_NAME_TEXT_UPPERDIST));
943  syncProperty(pParentFormat, UNO_NAME_TEXT_LOWERDIST,
944  xPropertySet->getPropertyValue(UNO_NAME_TEXT_LOWERDIST));
945 
946  // Sync the text aligning
947  syncProperty(pParentFormat, UNO_NAME_TEXT_VERTADJUST,
948  xPropertySet->getPropertyValue(UNO_NAME_TEXT_VERTADJUST));
949  syncProperty(pParentFormat, UNO_NAME_TEXT_HORZADJUST,
950  xPropertySet->getPropertyValue(UNO_NAME_TEXT_HORZADJUST));
951 
952  //FIXME: Sync autogrow: needs repositioning after sync
953  //syncProperty(pParentFormat, RES_FRM_SIZE, MID_FRMSIZE_IS_AUTO_HEIGHT,
954  // xPropertySet->getPropertyValue(UNO_NAME_TEXT_AUTOGROWHEIGHT));
955 }
956 
957 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
#define MID_CHAIN_NAME
Definition: unomid.h:58
const css::uno::WeakReference< css::uno::XInterface > & getWeakUnoShape() const
static sal_Int32 getCount(const SwDoc &rDoc)
Count number of shapes in the document, excluding TextBoxes.
static css::uno::Any getByIndex(SdrPage const *pPage, sal_Int32 nIndex)
Get a shape by index, excluding TextBoxes.
void SetHeight(tools::Long n)
#define UNO_NAME_HORI_ORIENT_POSITION
Definition: unoprnms.hxx:263
#define UNO_NAME_TEXT_RIGHTDIST
SwDocShell * GetDocShell()
Definition: doc.hxx:1350
#define UNO_NAME_BOTTOM_BORDER
Definition: unoprnms.hxx:356
tools::Long getWidth() const
static bool hasTextFrame(const SdrObject *pObj)
Returns true if the SdrObject has a SwTextFrame otherwise false.
#define UNO_NAME_RELATIVE_HEIGHT_RELATION
Definition: unoprnms.hxx:189
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Definition: atrfrm.cxx:2080
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:106
#define UNO_NAME_IS_FOLLOWING_TEXT_FLOW
Definition: unoprnms.hxx:739
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
static void destroy(SwFrameFormat *pShape)
Destroy a TextBox for a shape.
#define UNO_NAME_ALLOW_OVERLAP
Definition: unoprnms.hxx:865
constexpr TypedWhichId< SdrTextVertAdjustItem > RES_TEXT_VERT_ADJUST(130)
sal_uInt16 GetPageNum() const
Definition: fmtanchr.hxx:66
SwTwips GetPos() const
Definition: fmtornt.hxx:92
virtual void SetModified()=0
Must be called manually at changes of format.
#define MID_VERTORIENT_RELATION
Definition: unomid.h:35
static sal_Int32 getOrdNum(const SdrObject *pObject)
Get the order of the shape, excluding TextBoxes.
#define UNO_NAME_TEXT_LOWERDIST
SdrObject * GetObj(size_t nNum) const
Definition: doc.hxx:186
virtual bool IsTextBox() const
size_t GetObjCount() const
OUString GetUniqueFrameName() const
Definition: doclay.cxx:1377
tools::Long getY() const
#define RIGHT_BORDER_DISTANCE
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:31
constexpr TypedWhichId< SvxOpaqueItem > RES_OPAQUE(99)
#define UNO_NAME_WRITING_MODE
Definition: unoprnms.hxx:690
#define UNO_NAME_ANCHOR_PAGE_NO
Definition: unoprnms.hxx:226
#define UNO_NAME_VERT_ORIENT
Definition: unoprnms.hxx:328
#define UNO_NAME_TEXT_UPPERDIST
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:55
void SetPageNum(sal_uInt16 nNew)
Definition: fmtanchr.hxx:72
EmbeddedObjectRef * pObject
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType)
If we have an associated TextFrame, then return that.
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:741
std::map< const SwFrameFormat *, const SwFrameFormat * > SavedLink
Maps a draw format to a fly format.
static css::uno::Any queryInterface(const SwFrameFormat *pShape, const css::uno::Type &rType)
Get interface of a shape's TextBox, if there is any.
virtual const tools::Rectangle & GetSnapRect() const
bool IsEmpty() const
tools::Long getHeight() const
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
#define UNO_NAME_RELATIVE_WIDTH_RELATION
Definition: unoprnms.hxx:187
#define UNO_NAME_CHAIN_NEXT_NAME
Definition: unoprnms.hxx:230
void SetHoriOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:89
virtual css::uno::Reference< css::uno::XInterface > getUnoShape()
#define MID_FRMSIZE_SIZE
Definition: unomid.h:70
tools::Long Left() const
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
SdrPage * getSdrPageFromSdrObject() const
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
#define MID_FOLLOW_TEXT_FLOW
Definition: unomid.h:152
void SetOtherTextBoxFormat(SwFrameFormat *pFormat)
Definition: atrfrm.cxx:2517
const OUString & GetName() const
Definition: format.hxx:111
int nCount
#define UNO_NAME_SIZE
Definition: unoprnms.hxx:302
virtual void DelLayoutFormat(SwFrameFormat *pFormat)=0
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType)
Is the frame format a text box?
Mode eMode
const SwFormatSurround & GetSurround(bool=true) const
Definition: fmtsrnd.hxx:66
#define UNO_NAME_VERT_ORIENT_RELATION
Definition: unoprnms.hxx:331
tools::Long getX() const
#define UNO_NAME_TEXT_WRITINGMODE
#define FN_TEXT_RANGE
Definition: cmdid.h:805
css::uno::Reference< css::frame::XModel > GetBaseModel() const
constexpr TypedWhichId< SwFormatWrapInfluenceOnObjPos > RES_WRAP_INFLUENCE_ON_OBJPOS(125)
Specific frame formats (frames, DrawObjects).
#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. ...
static void lcl_queryInterface(const SwFrameFormat *pShape, uno::Any &rAny)
#define UNO_NAME_HORI_ORIENT
Definition: unoprnms.hxx:259
#define MID_CHAIN_NEXTNAME
Definition: unomid.h:57
#define MID_L_MARGIN
static void create(SwFrameFormat *pShape, bool bCopyText=false)
Create a TextBox for a shape.
#define MID_ANCHOR_ANCHORTYPE
Definition: unomid.h:43
Style of a layout element.
Definition: frmfmt.hxx:58
#define MID_HORIORIENT_POSITION
Definition: unomid.h:40
static void updateTextBoxMargin(SdrObject *pObj)
Copy shape attributes to the text frame.
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
#define UNO_NAME_RIGHT_BORDER
Definition: unoprnms.hxx:354
#define UNO_NAME_FILL_TRANSPARENCE
SwFrameFormat * GetOtherTextBoxFormat() const
Definition: frmfmt.hxx:102
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
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
Definition: unoprnms.hxx:169
#define MID_VERTORIENT_POSITION
Definition: unomid.h:36
void SetPos(SwTwips nNew)
Definition: fmtornt.hxx:60
FlyAnchors.
Definition: fmtanchr.hxx:34
void SetRelationOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:90
float u
#define BOTTOM_BORDER_DISTANCE
static void getProperty(SwFrameFormat const *pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, css::uno::Any &rValue)
Get a property of the underlying TextFrame.
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:87
sal_uInt32 GetOrdNum() const
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:394
css::text::WrapTextMode GetSurround() const
Definition: fmtsrnd.hxx:51
#define UNO_NAME_LEFT_BORDER
Definition: unoprnms.hxx:353
Connection (text flow) between two FlyFrames.
Definition: fmtcnct.hxx:31
#define MID_R_MARGIN
#define MID_FRMSIZE_IS_AUTO_HEIGHT
Definition: unomid.h:77
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
tools::Long Top() const
#define UNO_NAME_LEFT_BORDER_DISTANCE
Definition: unoprnms.hxx:358
#define UNO_NAME_CHAIN_PREV_NAME
Definition: unoprnms.hxx:231
bool SetFlyFrameAttr(SwFrameFormat &rFlyFormat, SfxItemSet &rSet)
Definition: docfly.cxx:557
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
constexpr TypedWhichId< SwFormatContent > RES_CNTNT(95)
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange,::sw::TextRangeMode const eMode)
Definition: unoobj2.cxx:1099
#define UNO_NAME_RIGHT_MARGIN
Definition: unoprnms.hxx:68
#define UNO_NAME_TOP_BORDER
Definition: unoprnms.hxx:355
sal_uInt16 const aFrameFormatSetRange[]
Definition: init.cxx:233
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:462
#define UNO_NAME_TOP_BORDER_DISTANCE
Definition: unoprnms.hxx:360
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:78
#define UNO_NAME_TEXT_VERT_ADJUST
Definition: unoprnms.hxx:854
#define UNO_NAME_SURROUND
Definition: unoprnms.hxx:309
#define MID_HORIORIENT_ORIENT
Definition: unomid.h:38
#define MID_FRMSIZE_REL_HEIGHT_RELATION
Definition: unomid.h:88
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:642
constexpr TypedWhichId< SwFormatChain > RES_CHAIN(114)
constexpr sal_Int64 convertTwipToMm100(sal_Int64 n)
#define MID_CHAIN_PREVNAME
Definition: unomid.h:56
const SwFormatChain & GetChain(bool=true) const
Definition: fmtcnct.hxx:70
iterator find(const OUString &rKey)
Any makeAny(Color const &value)
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:88
#define UNO_NAME_LEFT_MARGIN
Definition: unoprnms.hxx:67
#define MID_VERTORIENT_ORIENT
Definition: unomid.h:34
unsigned char sal_uInt8
#define UNO_NAME_BOTTOM_BORDER_DISTANCE
Definition: unoprnms.hxx:361
#define UNO_NAME_ANCHOR_TYPE
Definition: unoprnms.hxx:224
SwTwips GetPos() const
Definition: fmtornt.hxx:59
#define UNO_NAME_TEXT_LEFTDIST
#define MID_FRMSIZE_REL_WIDTH_RELATION
Definition: unomid.h:87
#define TWIPS_TO_MM(val)
#define UNO_NAME_HORI_ORIENT_RELATION
Definition: unoprnms.hxx:262
static SW_DLLPUBLIC css::uno::Reference< css::text::XTextFrame > CreateXTextFrame(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
Definition: unoframe.cxx:3193
#define TOP_BORDER_DISTANCE
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
#define UNO_NAME_TEXT_AUTOGROWHEIGHT
void * p
static css::uno::Reference< css::uno::XInterface > MakeInstance(SwServiceType nObjectType, SwDoc &rDoc)
Definition: unocoll.cxx:512
bool GetTextBounds(tools::Rectangle &rTextBound) const
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
static tools::Rectangle getTextRectangle(SwFrameFormat *pShape, bool bAbsolute=true)
Return the textbox rectangle of a draw shape (in twips).
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(157)
sal_Int16 GetVertOrient() const
Definition: fmtornt.hxx:54
void SetRelationOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:57
constexpr TypedWhichId< SvxBoxItem > RES_BOX(106)
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(154)
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
void SetPos(SwTwips nNew)
Definition: fmtornt.hxx:93
#define UNO_NAME_FRAME_ISAUTOMATIC_HEIGHT
Definition: unoprnms.hxx:590
#define MID_HORIORIENT_RELATION
Definition: unomid.h:39
void SetType(RndStdIds nRndId)
Definition: fmtanchr.hxx:71
#define UNO_NAME_TEXT_HORZADJUST
static void syncFlyFrameAttr(SwFrameFormat &rShape, SfxItemSet const &rSet)
Similar to syncProperty(), but used by the internal API (e.g. for UI purposes).
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
#define SAL_WARN(area, stream)
static void syncProperty(SwFrameFormat *pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, const css::uno::Any &rValue)
Sync property of TextBox with the one of the shape.
RndStdIds
#define UNO_NAME_SIZE_TYPE
Definition: unoprnms.hxx:257
#define UNO_NAME_RIGHT_BORDER_DISTANCE
Definition: unoprnms.hxx:359
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
#define UNO_NAME_VERT_ORIENT_POSITION
Definition: unoprnms.hxx:330
constexpr TypedWhichId< SwFormatFollowTextFlow > RES_FOLLOW_TEXT_FLOW(123)
#define UNO_NAME_OPAQUE
Definition: unoprnms.hxx:281
sal_uInt16 Which() const
SdrObject * FindRealSdrObject()
Definition: atrfrm.cxx:2740
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1317
sal_Int16 nValue
#define MID_ALLOW_OVERLAP
Definition: unomid.h:149
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1517
#define CONVERT_TWIPS
static void getShapeWrapThrough(const SwFrameFormat *pTextBox, bool &rWrapThrough)
If pTextBox is a textbox, then set rWrapThrough to the surround of its shape.
#define UNO_NAME_TEXT_VERTADJUST