LibreOffice Module sw (master)
1
|
A TextBox is a TextFrame, that is tied to a drawinglayer shape. More...
#include <textboxhelper.hxx>
Public Types | |
using | SavedLink = std::map< const SwFrameFormat *, const SwFrameFormat * > |
Maps a draw format to a fly format. More... | |
using | SavedContent = std::map< const SwFrameFormat *, SwFormatContent > |
Maps a draw format to content. More... | |
Static Public Member Functions | |
static void | create (SwFrameFormat *pShape, bool bCopyText=false) |
Create a TextBox for a shape. More... | |
static void | destroy (SwFrameFormat *pShape) |
Destroy a TextBox for a shape. More... | |
static css::uno::Any | queryInterface (const SwFrameFormat *pShape, const css::uno::Type &rType) |
Get interface of a shape's TextBox, if there is any. More... | |
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. More... | |
static void | syncProperty (SwFrameFormat *pShape, std::u16string_view rPropertyName, const css::uno::Any &rValue) |
Does the same, but works on properties which lack an sw-specific WID / MemberID. More... | |
static void | getProperty (SwFrameFormat const *pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, css::uno::Any &rValue) |
Get a property of the underlying TextFrame. More... | |
static css::uno::Any | getProperty (SwFrameFormat const *pShape, OUString sPropName) |
Get a property of the underlying TextFrame. More... | |
static css::text::TextContentAnchorType | mapAnchorType (const RndStdIds &rAnchorID) |
There are two types of enum of anchor type, so this function maps this. More... | |
static void | syncFlyFrameAttr (SwFrameFormat &rShape, SfxItemSet const &rSet) |
Similar to syncProperty(), but used by the internal API (e.g. for UI purposes). More... | |
static void | updateTextBoxMargin (SdrObject *pObj) |
Copy shape attributes to the text frame. More... | |
static SwFrameFormat * | getOtherTextBoxFormat (const SwFrameFormat *pFormat, sal_uInt16 nType) |
If we have an associated TextFrame, then return that. More... | |
static SwFrameFormat * | getOtherTextBoxFormat (css::uno::Reference< css::drawing::XShape > const &xShape) |
If we have an associated TextFrame, then return that. More... | |
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. More... | |
static tools::Rectangle | getTextRectangle (SwFrameFormat *pShape, bool bAbsolute=true) |
Return the textbox rectangle of a draw shape (in twips). More... | |
static bool | isTextBox (const SwFrameFormat *pFormat, sal_uInt16 nType) |
Is the frame format a text box? More... | |
static bool | hasTextFrame (const SdrObject *pObj) |
Returns true if the SdrObject has a SwTextFrame otherwise false. More... | |
static sal_Int32 | getCount (const SwDoc &rDoc) |
Count number of shapes in the document, excluding TextBoxes. More... | |
static sal_Int32 | getCount (SdrPage const *pPage) |
Count number of shapes on the page, excluding TextBoxes. More... | |
static css::uno::Any | getByIndex (SdrPage const *pPage, sal_Int32 nIndex) |
Get a shape by index, excluding TextBoxes. More... | |
static sal_Int32 | getOrdNum (const SdrObject *pObject) |
Get the order of the shape, excluding TextBoxes. More... | |
static void | getShapeWrapThrough (const SwFrameFormat *pTextBox, bool &rWrapThrough) |
If pTextBox is a textbox, then set rWrapThrough to the surround of its shape. More... | |
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. More... | |
static void | restoreLinks (std::set< ZSortFly > &rOld, std::vector< SwFrameFormat * > &rNew, SavedLink &rSavedLinks) |
Undo the effect of saveLinks() + individual resetLink() calls. More... | |
A TextBox is a TextFrame, that is tied to a drawinglayer shape.
This class provides helper methods to create, query and maintain such TextBoxes.
Definition at line 51 of file textboxhelper.hxx.
using SwTextBoxHelper::SavedContent = std::map<const SwFrameFormat*, SwFormatContent> |
Maps a draw format to content.
Definition at line 57 of file textboxhelper.hxx.
using SwTextBoxHelper::SavedLink = std::map<const SwFrameFormat*, const SwFrameFormat*> |
Maps a draw format to a fly format.
Definition at line 55 of file textboxhelper.hxx.
|
static |
Create a TextBox for a shape.
If the second parameter is true, the original text in the shape will be copied to the frame
Definition at line 57 of file textboxhelper.cxx.
References assert(), eMode, SwFrameFormat::FindRealSdrObject(), SwFormat::GetAttrSet(), SfxObjectShell::GetBaseModel(), SwFormat::GetDoc(), SwDoc::GetDocShell(), SwDoc::getIDocumentState(), SwFrameFormat::GetOtherTextBoxFormat(), SwDoc::GetUniqueFrameName(), SdrObject::getUnoShape(), SfxItemSet::HasItem(), com::sun::star::uno::makeAny(), SwXServiceProvider::MakeInstance(), MID_ANCHOR_ANCHORTYPE, MID_FOLLOW_TEXT_FLOW, MID_FRMSIZE_IS_AUTO_HEIGHT, MID_FRMSIZE_SIZE, MID_HORIORIENT_ORIENT, MID_HORIORIENT_POSITION, MID_HORIORIENT_RELATION, MID_VERTORIENT_ORIENT, MID_VERTORIENT_POSITION, MID_VERTORIENT_RELATION, RES_ANCHOR(), RES_CNTNT(), RES_FOLLOW_TEXT_FLOW(), RES_FRAMEDIR(), RES_FRM_SIZE(), RES_HORI_ORIENT(), RES_TEXT_VERT_ADJUST(), RES_VERT_ORIENT(), SwFormat::SetFormatAttr(), IDocumentState::SetModified(), SwFrameFormat::SetOtherTextBoxFormat(), TypeTextFrame, UNO_NAME_ANCHOR_TYPE, UNO_NAME_BOTTOM_BORDER, UNO_NAME_FILL_TRANSPARENCE, UNO_NAME_HORI_ORIENT, UNO_NAME_HORI_ORIENT_POSITION, UNO_NAME_HORI_ORIENT_RELATION, UNO_NAME_IS_FOLLOWING_TEXT_FLOW, UNO_NAME_LEFT_BORDER, UNO_NAME_RIGHT_BORDER, UNO_NAME_SIZE_TYPE, UNO_NAME_SURROUND, UNO_NAME_TEXT_AUTOGROWHEIGHT, UNO_NAME_TEXT_VERT_ADJUST, UNO_NAME_TEXT_WRITINGMODE, UNO_NAME_TOP_BORDER, UNO_NAME_VERT_ORIENT, UNO_NAME_VERT_ORIENT_POSITION, UNO_NAME_VERT_ORIENT_RELATION, and sw::XTextRangeToSwPaM().
Referenced by SwDrawShell::Execute(), and SwXShape::setPropertyValue().
|
static |
Destroy a TextBox for a shape.
Definition at line 189 of file textboxhelper.cxx.
References IDocumentLayoutAccess::DelLayoutFormat(), SwFormat::GetAttrSet(), SwFormat::GetDoc(), SwDoc::getIDocumentLayoutAccess(), SwFrameFormat::GetOtherTextBoxFormat(), SfxItemSet::HasItem(), RES_CNTNT(), and SwFormat::ResetFormatAttr().
Referenced by SwDrawShell::Execute(), and SwXShape::setPropertyValue().
Get a shape by index, excluding TextBoxes.
css::lang::IndexOutOfBoundsException |
Definition at line 261 of file textboxhelper.cxx.
References SdrObjList::GetObj(), SdrObjList::GetObjCount(), SdrObject::getUnoShape(), i, SdrObject::IsTextBox(), com::sun::star::uno::makeAny(), nCount, and p.
Referenced by SwXDrawPage::getByIndex().
|
static |
Count number of shapes in the document, excluding TextBoxes.
Definition at line 249 of file textboxhelper.cxx.
References SwDoc::GetSpzFrameFormats(), and RES_FLYFRMFMT().
Referenced by SwXDrawPage::getCount().
|
static |
Count number of shapes on the page, excluding TextBoxes.
Definition at line 236 of file textboxhelper.cxx.
References SdrObjList::GetObj(), SdrObjList::GetObjCount(), i, SdrObject::IsTextBox(), and p.
|
static |
Get the order of the shape, excluding TextBoxes.
Definition at line 287 of file textboxhelper.cxx.
References SdrObject::GetOrdNum(), SdrObject::getSdrPageFromSdrObject(), i, SdrObject::IsTextBox(), p, and SAL_WARN.
Referenced by SwXShape::getPropertyValue().
|
static |
If we have an associated TextFrame, then return that.
nType | Expected frame format type. Valid types are RES_DRAWFRMFMT and RES_FLYFRMFMT. |
Definition at line 314 of file textboxhelper.cxx.
References SwFrameFormat::GetOtherTextBoxFormat().
Referenced by objectpositioning::SwToContentAnchoredObjectPosition::CalcOverlap(), SwDoc::ChgAnchor(), SwFEShell::CopyDrawSel(), sw::DocumentLayoutManager::CopyLayoutFormat(), SwDrawView::DeleteMarked(), SwFEShell::FindAnchorPos(), SwFlyFrame::Format(), SwFrame::GetBackgroundBrush(), getShapeWrapThrough(), getUnoTextFrame(), hasTextFrame(), lcl_goIntoTextBox(), lcl_queryInterface(), SwFlyAtContentFrame::MakeAll(), SwEditWin::MouseButtonUp(), SwFEShell::SelectObj(), SwTextFlyCnt::SetAnchor(), SwFlyCntPortion::SetBase(), RtfSdrExport::StartShape(), DocxAttributeOutput::WriteTextBox(), and DocxAttributeOutput::WriteVMLTextBox().
|
static |
If we have an associated TextFrame, then return that.
|
static |
Get a property of the underlying TextFrame.
Definition at line 551 of file textboxhelper.cxx.
References CONVERT_TWIPS, SwFormat::GetChain(), SwFormat::GetName(), MID_CHAIN_NAME, MID_CHAIN_NEXTNAME, MID_CHAIN_PREVNAME, SwFormatChain::QueryValue(), RES_CHAIN(), RES_DRAWFRMFMT(), and SAL_WARN.
Referenced by SwXShape::getPropertyValue(), and SwFlyAtContentFrame::MakeAll().
|
static |
Get a property of the underlying TextFrame.
Definition at line 585 of file textboxhelper.cxx.
References SwXTextFrame::CreateXTextFrame(), SwFormat::GetDoc(), and RES_DRAWFRMFMT().
|
static |
If pTextBox is a textbox, then set rWrapThrough to the surround of its shape.
Definition at line 307 of file textboxhelper.cxx.
References getOtherTextBoxFormat(), SwFormatSurround::GetSurround(), SwFormat::GetSurround(), and RES_FLYFRMFMT().
Referenced by objectpositioning::SwAnchoredObjectPosition::GetHoriAlignmentValues(), and objectpositioning::SwAnchoredObjectPosition::GetTopForObjPos().
|
static |
Return the textbox rectangle of a draw shape (in twips).
Definition at line 381 of file textboxhelper.cxx.
References SwFrameFormat::FindRealSdrObject(), SdrObjCustomShape::GetTextBounds(), tools::Rectangle::Left(), tools::Rectangle::Move(), Point, tools::Rectangle::SetEmpty(), and tools::Rectangle::Top().
Referenced by SwFlyAtContentFrame::MakeAll(), and SwFlyCntPortion::SetBase().
|
static |
If we have an associated TextFrame, then return its XTextFrame.
Definition at line 333 of file textboxhelper.cxx.
References getOtherTextBoxFormat().
Referenced by DocxAttributeOutput::GetUnoTextFrame(), and SwXDrawPage::remove().
|
static |
Returns true if the SdrObject has a SwTextFrame otherwise false.
Definition at line 225 of file textboxhelper.cxx.
References getOtherTextBoxFormat(), and SdrObject::getWeakUnoShape().
Referenced by SwDrawShell::ExecDrawDlg(), and SwDrawBaseShell::Execute().
|
static |
Is the frame format a text box?
A text box consists of a coupled fly and draw format. Most times you just want to check for a single type, otherwise you get duplicate results.
nType | Expected frame format input type. Valid types are RES_DRAWFRMFMT and RES_FLYFRMFMT. |
Definition at line 205 of file textboxhelper.cxx.
References assert(), SwFormat::GetAttrSet(), SwFormat::GetContent(), SwFrameFormat::GetOtherTextBoxFormat(), SfxItemSet::HasItem(), RES_CNTNT(), RES_DRAWFRMFMT(), RES_FLYFRMFMT(), and SwFormat::Which().
Referenced by objectpositioning::SwToContentAnchoredObjectPosition::CalcOverlap(), sw::DocumentContentOperationsManager::CopyFlyInFlyImpl(), SwXMLExport::ExportTable(), SwFEShell::FindAnchorPos(), SwDoc::GetFlyCount(), SwDoc::GetFlyFrameFormats(), SwDoc::GetFlyNum(), objectpositioning::SwAnchoredObjectPosition::GetInfoAboutObj(), SwAnchoredDrawObject::GetObjBoundRect(), SwXShape::getPropertyStates(), SwXShape::getPropertyValue(), SwDrawShell::GetState(), RtfSdrExport::isTextBox(), DocxSdrExport::isTextBox(), SwVirtFlyDrawObj::IsTextBox(), lcl_ExportHints(), lcl_isTextBox(), lcl_textBoxSizeNotify(), SwFEShell::Paste(), and SwXFrame::setPropertyValue().
|
static |
There are two types of enum of anchor type, so this function maps this.
Definition at line 916 of file textboxhelper.cxx.
References SAL_WARN.
|
static |
Get interface of a shape's TextBox, if there is any.
Definition at line 361 of file textboxhelper.cxx.
Referenced by SwXShape::queryInterface().
|
static |
Undo the effect of saveLinks() + individual resetLink() calls.
Definition at line 895 of file textboxhelper.cxx.
References i.
Referenced by sw::DocumentContentOperationsManager::CopyFlyInFlyImpl().
|
static |
Saves the current shape -> textbox links in a map, so they can be restored later.
Definition at line 885 of file textboxhelper.cxx.
References RES_DRAWFRMFMT().
Referenced by sw::DocumentContentOperationsManager::CopyFlyInFlyImpl().
|
static |
Similar to syncProperty(), but used by the internal API (e.g. for UI purposes).
Definition at line 944 of file textboxhelper.cxx.
References aFrameFormatSetRange, SwFormat::GetAnchor(), SwFormatAnchor::GetAnchorId(), SwDoc::GetAttrPool(), SwFormat::GetDoc(), SwFormat::GetFrameSize(), tools::Rectangle::getHeight(), SwFormat::GetHoriOrient(), SwFormatAnchor::GetPageNum(), SwFormatVertOrient::GetPos(), SwFormatHoriOrient::GetPos(), SwFormatVertOrient::GetRelationOrient(), SwFormatHoriOrient::GetRelationOrient(), SwFormat::GetVertOrient(), tools::Rectangle::getX(), tools::Rectangle::getY(), tools::Rectangle::IsEmpty(), MID_ANCHOR_ANCHORTYPE, RES_ANCHOR(), RES_DRAWFRMFMT(), RES_FRM_SIZE(), RES_HORI_ORIENT(), RES_VERT_ORIENT(), SAL_WARN, SwDoc::SetFlyFrameAttr(), SvxSizeItem::SetHeight(), SwFormatVertOrient::SetPos(), SwFormatHoriOrient::SetPos(), SwFormatVertOrient::SetRelationOrient(), SwFormatHoriOrient::SetRelationOrient(), and SfxPoolItem::Which().
Referenced by SwDrawContact::Changed_(), SwDoc::ChgAnchor(), SwFEShell::CopyDrawSel(), SwFEShell::FindAnchorPos(), lcl_textBoxSizeNotify(), and SwDoc::SetFlyFrameAttr().
|
static |
Sync property of TextBox with the one of the shape.
Definition at line 600 of file textboxhelper.cxx.
References BOTTOM_BORDER_DISTANCE, CONVERT_TWIPS, convertTwipToMm100(), SwXTextFrame::CreateXTextFrame(), FN_TEXT_RANGE, SwFormat::GetAnchor(), SwFormatAnchor::GetContentAnchor(), SwFormat::GetDoc(), tools::Rectangle::getHeight(), SwFormat::GetHoriOrient(), SwFormatAnchor::GetPageNum(), SwFormat::GetVertOrient(), tools::Rectangle::getWidth(), tools::Rectangle::getX(), tools::Rectangle::getY(), tools::Rectangle::IsEmpty(), LEFT_BORDER_DISTANCE, com::sun::star::uno::makeAny(), MID_ALLOW_OVERLAP, MID_ANCHOR_ANCHORTYPE, MID_CHAIN_NEXTNAME, MID_CHAIN_PREVNAME, MID_FRMSIZE_IS_AUTO_HEIGHT, MID_FRMSIZE_REL_HEIGHT_RELATION, MID_FRMSIZE_REL_WIDTH_RELATION, MID_FRMSIZE_WIDTH_TYPE, MID_HORIORIENT_ORIENT, MID_HORIORIENT_POSITION, MID_HORIORIENT_RELATION, MID_L_MARGIN, MID_R_MARGIN, MID_VERTORIENT_ORIENT, MID_VERTORIENT_POSITION, MID_VERTORIENT_RELATION, nValue, RES_ANCHOR(), RES_BOX(), RES_CHAIN(), RES_DRAWFRMFMT(), RES_FRAMEDIR(), RES_FRM_SIZE(), RES_HORI_ORIENT(), RES_LR_SPACE(), RES_OPAQUE(), RES_TEXT_VERT_ADJUST(), RES_VERT_ORIENT(), RES_WRAP_INFLUENCE_ON_OBJPOS(), RIGHT_BORDER_DISTANCE, SAL_WARN, SwFormatAnchor::SetAnchor(), SwFormat::SetFormatAttr(), SwFormatVertOrient::SetPos(), SwFormatHoriOrient::SetPos(), TOP_BORDER_DISTANCE, UNO_NAME_ALLOW_OVERLAP, UNO_NAME_ANCHOR_PAGE_NO, UNO_NAME_ANCHOR_TYPE, UNO_NAME_BOTTOM_BORDER_DISTANCE, UNO_NAME_CHAIN_NEXT_NAME, UNO_NAME_CHAIN_PREV_NAME, UNO_NAME_FRAME_ISAUTOMATIC_HEIGHT, UNO_NAME_HORI_ORIENT, UNO_NAME_HORI_ORIENT_POSITION, UNO_NAME_HORI_ORIENT_RELATION, UNO_NAME_LEFT_BORDER_DISTANCE, UNO_NAME_LEFT_MARGIN, UNO_NAME_OPAQUE, UNO_NAME_RELATIVE_HEIGHT_RELATION, UNO_NAME_RELATIVE_WIDTH_RELATION, UNO_NAME_RIGHT_BORDER_DISTANCE, UNO_NAME_RIGHT_MARGIN, UNO_NAME_SIZE, UNO_NAME_SURROUND, UNO_NAME_TEXT_VERT_ADJUST, UNO_NAME_TOP_BORDER_DISTANCE, UNO_NAME_VERT_ORIENT, UNO_NAME_VERT_ORIENT_POSITION, UNO_NAME_VERT_ORIENT_RELATION, UNO_NAME_WIDTH_TYPE, UNO_NAME_WRITING_MODE, and sw::XTextRangeToSwPaM().
Referenced by SwAnchoredDrawObject::GetObjBoundRect(), SwXShape::setPropertyValue(), and SwXShape::setSize().
|
static |
Does the same, but works on properties which lack an sw-specific WID / MemberID.
Definition at line 421 of file textboxhelper.cxx.
References BOTTOM_BORDER_DISTANCE, convertTwipToMm100(), SwXTextFrame::CreateXTextFrame(), eMode, comphelper::SequenceAsHashMap::end(), comphelper::SequenceAsHashMap::find(), SwFrameFormat::FindRealSdrObject(), SwFormat::GetDoc(), SdrObject::GetSnapRect(), LEFT_BORDER_DISTANCE, com::sun::star::uno::makeAny(), MID_FRMSIZE_IS_AUTO_HEIGHT, MID_FRMSIZE_SIZE, MID_HORIORIENT_POSITION, MID_VERTORIENT_POSITION, pObject, RES_BOX(), RES_DRAWFRMFMT(), RES_FRAMEDIR(), RES_FRM_SIZE(), RES_HORI_ORIENT(), RES_TEXT_VERT_ADJUST(), RES_VERT_ORIENT(), RIGHT_BORDER_DISTANCE, SAL_WARN, TOP_BORDER_DISTANCE, u, UNO_NAME_PARA_ADJUST, UNO_NAME_TEXT_AUTOGROWHEIGHT, UNO_NAME_TEXT_HORZADJUST, UNO_NAME_TEXT_LEFTDIST, UNO_NAME_TEXT_LOWERDIST, UNO_NAME_TEXT_RIGHTDIST, UNO_NAME_TEXT_UPPERDIST, UNO_NAME_TEXT_VERT_ADJUST, and UNO_NAME_TEXT_WRITINGMODE.
Copy shape attributes to the text frame.
Definition at line 1061 of file textboxhelper.cxx.
References SdrObject::getUnoShape(), MID_FRMSIZE_IS_AUTO_HEIGHT, MID_FRMSIZE_WIDTH_TYPE, RES_FLYFRMFMT(), RES_FRM_SIZE(), UNO_NAME_TEXT_AUTOGROWHEIGHT, UNO_NAME_TEXT_HORZADJUST, UNO_NAME_TEXT_LEFTDIST, UNO_NAME_TEXT_LOWERDIST, UNO_NAME_TEXT_RIGHTDIST, UNO_NAME_TEXT_UPPERDIST, UNO_NAME_TEXT_VERTADJUST, and UNO_NAME_TEXT_WORDWRAP.
Referenced by SwDrawShell::ExecDrawDlg().