LibreOffice Module sw (master) 1
Classes | Typedefs | Functions
sw::util Namespace Reference

Classes

struct  CharRunEntry
 
class  CharStyleMapper
 Knows which writer style a given word style should be imported as. More...
 
class  CompareRedlines
 
class  FontMapExport
 Find suitable names for exporting this font. More...
 
class  HdFtDistanceGlue
 Make export a word section top/bottom values easy. More...
 
class  InsertedTableListener
 
class  InsertedTablesManager
 Handle requirements for table formatting in insert->file mode. More...
 
class  ItemSort
 
class  ParaStyleMapper
 Knows which writer style a given word style should be imported as. More...
 
class  RedlineStack
 
class  SetEndIfOpen
 
class  SetInDocAndDelete
 
class  SetLayer
 Make setting a drawing object's layer in a Writer document easy. More...
 
class  WrtRedlineAuthor
 

Typedefs

typedef std::vector< CharRunEntryCharRuns
 

Functions

SwTwips MakeSafePositioningValue (SwTwips nIn)
 Clips a value to MAX/MIN 16bit value to make it safe for use as a position value to give to writer. More...
 
void MoveAttrFieldmarkInserted (SwFltPosition &rMkPos, SwFltPosition &rPtPos, const SwPosition &rPos)
 
CharRuns GetPseudoCharRuns (const SwTextNode &rTextNd)
 Collect the ranges of Text which share. More...
 
void GetPoolItems (const SfxItemSet &rSet, ww8::PoolItems &rItems, bool bExportParentItemSet)
 Get the SfxPoolItems of a SfxItemSet. More...
 
const SfxPoolItemSearchPoolItems (const ww8::PoolItems &rItems, sal_uInt16 eType)
 
void ClearOverridesFromSet (const SwFormatCharFormat &rFormat, SfxItemSet &rSet)
 Remove properties from an SfxItemSet which a SwFormatCharFormat overrides. More...
 
ww8::ParaStyles GetParaStyles (const SwDoc &rDoc)
 Get the Paragraph Styles of a SwDoc. More...
 
SwTextFormatCollGetParaStyle (SwDoc &rDoc, const OUString &rName)
 Get a Paragraph Style which fits a given name. More...
 
SwCharFormatGetCharStyle (SwDoc &rDoc, const OUString &rName)
 Get a Character Style which fits a given name. More...
 
void SortByAssignedOutlineStyleListLevel (ww8::ParaStyles &rStyles)
 Sort sequence of Paragraph Styles by assigned outline style list level. More...
 
ww8::Frames GetFrames (const SwDoc &rDoc, SwPaM const *pPaM)
 Get the Floating elements in a SwDoc. More...
 
void UpdateFramePositions (ww8::Frames &rFrames)
 fix up frame positions, must be called after SetRedlineFlags More...
 
ww8::Frames GetFramesInNode (const ww8::Frames &rFrames, const SwNode &rNode)
 Get the Frames anchored to a given node. More...
 
const SwNumFormatGetNumFormatFromSwNumRuleLevel (const SwNumRule &rRule, int nLevel)
 Get the Numbering Format for a given level from a numbering rule. More...
 
const SwNumFormatGetNumFormatFromTextNode (const SwTextNode &rTextNode)
 Get the Numbering Format used on a paragraph. More...
 
const SwNumRuleGetNumRuleFromTextNode (const SwTextNode &rTextNode)
 
const SwNumRuleGetNormalNumRuleFromTextNode (const SwTextNode &rTextNode)
 
SwNoTextNodeGetNoTextNodeFromSwFrameFormat (const SwFrameFormat &rFormat)
 Get the SwNoTextNode associated with a SwFrameFormat if here is one. More...
 
bool HasPageBreak (const SwNode &rNode)
 Does a node have a "page break before" applied. More...
 
tools::Polygon PolygonFromPolyPolygon (const tools::PolyPolygon &rPolyPoly)
 Make a best fit Polygon from a PolyPolygon. More...
 
tools::Polygon CorrectWordWrapPolygonForExport (const tools::PolyPolygon &rPolyPoly, const SwNoTextNode *pNd, bool bCorrectCrop)
 Undo all scaling / move tricks of the wrap polygon done during import. More...
 
template<class T >
const T & item_cast (const SfxPoolItem &rItem)
 Provide a dynamic_cast style cast for SfxPoolItems. More...
 
template<class T >
const T * item_cast (const SfxPoolItem *pItem)
 Provide a dynamic_cast style cast for SfxPoolItems. More...
 
template<class T >
const T * HasItem (const ww8::PoolItems &rItems, sal_uInt16 eType)
 
const SwCharFormatGetSwCharFormat (const SwFormatINetFormat &rINet, SwDoc &rDoc)
 
bool IsPlausableSingleWordSection (const SwFrameFormat &rTitleFormat, const SwFrameFormat &rFollowFormat)
 See if two page formats can be expressed as a single word section. More...
 

Typedef Documentation

◆ CharRuns

typedef std::vector<CharRunEntry> sw::util::CharRuns

Definition at line 383 of file msfilter.hxx.

Function Documentation

◆ ClearOverridesFromSet()

void sw::util::ClearOverridesFromSet ( const SwFormatCharFormat rFormat,
SfxItemSet rSet 
)

Remove properties from an SfxItemSet which a SwFormatCharFormat overrides.

Given an SfxItemSet and a SwFormatCharFormat remove from the rSet all the properties which the SwFormatCharFormat would override. An SfxItemSet contains attributes, and a SwFormatCharFormat is a "Character Style", so if the SfxItemSet contains bold and so does the character style then delete bold from the SfxItemSet

Parameters
rFormatthe SwFormatCharFormat which describes the Character Style
rSetthe SfxItemSet from which we want to remove any properties which the rFormat would override
See also
#i24291# for examples

Definition at line 416 of file writerhelper.cxx.

References SfxItemSet::ClearItem(), SwFormatCharFormat::GetCharFormat(), SfxItemIter::GetCurItem(), SfxItemIter::NextItem(), rSet, and SfxPoolItem::Which().

Referenced by SwWW8AttrIter::OutAttr().

◆ CorrectWordWrapPolygonForExport()

tools::Polygon sw::util::CorrectWordWrapPolygonForExport ( const tools::PolyPolygon rPolyPoly,
const SwNoTextNode pNd,
bool  bCorrectCrop 
)

◆ GetCharStyle()

SwCharFormat * sw::util::GetCharStyle ( SwDoc rDoc,
const OUString &  rName 
)

Get a Character Style which fits a given name.

Its surprisingly tricky to get a style when all you have is a name, but that's what this does

Parameters
rDocThe SwDoc document to search in
rNameThe name of the style to search for
Returns
A Character Style if one exists which matches the name

Definition at line 459 of file writerhelper.cxx.

References ChrFmt, SwDoc::FindCharFormatByName(), IDocumentStylePoolAccess::GetCharFormatFromPool(), SwDoc::getIDocumentStylePoolAccess(), SwStyleNameMapper::GetPoolIdFromUIName(), n, and SAL_MAX_UINT16.

Referenced by myImplHelpers::MapperImpl< SwCharFormat >::GetStyle().

◆ GetFrames()

ww8::Frames sw::util::GetFrames ( const SwDoc rDoc,
SwPaM const *  pPaM 
)

Get the Floating elements in a SwDoc.

Writer's FrameFormats may or may not be anchored to some text content, e.g. Page Anchored elements will not be. For the winword export we need them to have something to be anchored to. So this method returns all the floating elements in a document as a STL container of ww8::Frames which are guaranteed to have an appropriate anchor.

Parameters
rDocThe SwDoc document to get the styles from
pPaMThe SwPam to describe the selection in the document to get the elements from. 0 means the entire document.
Returns
A Frames containing the selections Floating elements

Definition at line 483 of file writerhelper.cxx.

References SwDoc::GetAllFlyFormats().

Referenced by MSWordExportBase::ExportDocument().

◆ GetFramesInNode()

ww8::Frames sw::util::GetFramesInNode ( const ww8::Frames rFrames,
const SwNode rNode 
)

Get the Frames anchored to a given node.

Given a container of frames, find the ones anchored to a given node

Parameters
rFramesThe container of frames to search in
rNodeThe SwNode to check for anchors to
Returns
the Frames in rFrames anchored to rNode

Definition at line 506 of file writerhelper.cxx.

Referenced by SwWW8AttrIter::SwWW8AttrIter().

◆ GetNormalNumRuleFromTextNode()

const SwNumRule * sw::util::GetNormalNumRuleFromTextNode ( const SwTextNode rTextNode)

◆ GetNoTextNodeFromSwFrameFormat()

SwNoTextNode * sw::util::GetNoTextNodeFromSwFrameFormat ( const SwFrameFormat rFormat)

Get the SwNoTextNode associated with a SwFrameFormat if here is one.

There are two differing types of numbering formats that may be on a paragraph, normal and outline. The outline is that numbering you see in tools->outline numbering. There's no difference in the numbering itself, just how you get it from the SwTextNode. Needless to say the filter generally couldn't care less what type of numbering is in use.

Parameters
rFormatThe SwFrameFormat that may describe a graphic
Returns
A SwNoTextNode pointer that describes the graphic of this frame if there is one, or 0 if there is none.

Definition at line 568 of file writerhelper.cxx.

References SwFormat::GetContent(), SwFormatContent::GetContentIdx(), SwNodeIndex::GetNode(), and SwNode::GetNoTextNode().

Referenced by RtfAttributeOutput::FlyFrameGraphic(), SwWW8ImplReader::MapWrapIntoFlyFormat(), DocxSdrExport::startDMLAnchorInline(), SwEscherEx::WriteFlyFrameAttr(), and SwBasicEscherEx::WriteGrfFlyFrame().

◆ GetNumFormatFromSwNumRuleLevel()

const SwNumFormat * sw::util::GetNumFormatFromSwNumRuleLevel ( const SwNumRule rRule,
int  nLevel 
)

Get the Numbering Format for a given level from a numbering rule.

Parameters
rRuleThe numbering rule
nLevelThe numbering level
Returns
A SwNumFormat pointer that describes the numbering level or 0 if the nLevel is out of range

Definition at line 514 of file writerhelper.cxx.

References SwNumRule::Get(), and MAXLEVEL.

Referenced by SwWW8FltControlStack::GetNumFormatFromStack(), and GetNumFormatFromTextNode().

◆ GetNumFormatFromTextNode()

const SwNumFormat * sw::util::GetNumFormatFromTextNode ( const SwTextNode rTextNode)

Get the Numbering Format used on a paragraph.

There are two differing types of numbering formats that may be on a paragraph, normal and outline. The outline is that numbering you see in tools->outline numbering. There's no difference in the numbering itself, just how you get it from the SwTextNode. Needless to say the filter generally couldn't care less what type of numbering is in use.

Parameters
rTextNodeThe SwTextNode that is the paragraph
Returns
A SwNumFormat pointer that describes the numbering level on this paragraph, or 0 if there is none.

Definition at line 525 of file writerhelper.cxx.

References SwTextNode::GetActualListLevel(), SwNode::GetDoc(), GetNumFormatFromSwNumRuleLevel(), SwTextNode::GetNumRule(), SwDoc::GetOutlineNumRule(), SwTextNode::IsCountedInList(), and SwTextNode::IsNumbered().

Referenced by SwWW8ImplReader::Read_LR(), and SwWW8FltControlStack::SetAttrInDoc().

◆ GetNumRuleFromTextNode()

const SwNumRule * sw::util::GetNumRuleFromTextNode ( const SwTextNode rTextNode)

Definition at line 549 of file writerhelper.cxx.

References GetNormalNumRuleFromTextNode().

Referenced by SwWW8ImplReader::AppendTextNode().

◆ GetParaStyle()

SwTextFormatColl * sw::util::GetParaStyle ( SwDoc rDoc,
const OUString &  rName 
)

Get a Paragraph Style which fits a given name.

Its surprisingly tricky to get a style when all you have is a name, but that's what this does

Parameters
rDocThe SwDoc document to search in
rNameThe name of the style to search for
Returns
A Paragraph Style if one exists which matches the name

Definition at line 444 of file writerhelper.cxx.

References SwDoc::FindTextFormatCollByName(), SwDoc::getIDocumentStylePoolAccess(), SwStyleNameMapper::GetPoolIdFromUIName(), IDocumentStylePoolAccess::GetTextCollFromPool(), n, SAL_MAX_UINT16, and TxtColl.

Referenced by myImplHelpers::MapperImpl< SwTextFormatColl >::GetStyle().

◆ GetParaStyles()

ww8::ParaStyles sw::util::GetParaStyles ( const SwDoc rDoc)

Get the Paragraph Styles of a SwDoc.

Writer's styles are in one of those dreaded macro based pre-STL containers. Give me an STL container of the paragraph styles instead.

Parameters
rDocThe SwDoc document to get the styles from
Returns
A ParaStyles containing the SwDoc's Paragraph Styles

Definition at line 431 of file writerhelper.cxx.

References SwDoc::GetTextFormatColls(), nCount, and SwVectorModifyBase< Value >::size().

Referenced by SwWW8ImplReader::SetOutlineStyles().

◆ GetPoolItems()

void sw::util::GetPoolItems ( const SfxItemSet rSet,
ww8::PoolItems rItems,
bool  bExportParentItemSet 
)

Get the SfxPoolItems of a SfxItemSet.

Writer's SfxPoolItems (attributes) are in one of those dreaded macro based pre-STL containers. Give me an STL container of the items instead.

Parameters
rSetThe SfxItemSet to get the items from
rItemsThe sw::PoolItems to put the items into

Definition at line 380 of file writerhelper.cxx.

References SfxItemSet::Count(), SfxItemIter::GetCurItem(), SfxItemSet::GetItemState(), SfxItemSet::GetWhichByPos(), SfxItemIter::NextItem(), rSet, SfxItemSet::TotalCount(), and SfxPoolItem::Which().

Referenced by MSWordExportBase::ExportPoolItemsToCHP(), SwWW8AttrIter::OutAttr(), and MSWordExportBase::OutputItemSet().

◆ GetPseudoCharRuns()

CharRuns sw::util::GetPseudoCharRuns ( const SwTextNode rTextNd)

Collect the ranges of Text which share.

Word generally requires characters which share the same direction, the same script, and occasionally (depending on the format) the same charset to be exported in independent chunks.

So this function finds these ranges and returns a STL container of CharRuns

Parameters
rTextNdThe TextNode we want to ranges from
Returns
STL container of CharRuns which describe the shared direction, script and optionally script of the contiguous sequences of characters
See also
#i22537# for example

Definition at line 531 of file writerwordglue.cxx.

References g_pBreakIt, SwTextNode::GetAttr(), SwBreakIt::GetBreakIter(), SwNode::GetDoc(), GetExtendedTextEncoding(), SwTextNode::GetText(), SwDoc::GetTextDirection(), GetWhichOfScript(), nCount, nPos, and RES_CHRATR_FONT().

◆ GetSwCharFormat()

const SwCharFormat * sw::util::GetSwCharFormat ( const SwFormatINetFormat rINet,
SwDoc rDoc 
)

◆ HasItem()

template<class T >
const T * sw::util::HasItem ( const ww8::PoolItems rItems,
sal_uInt16  eType 
)

◆ HasPageBreak()

bool sw::util::HasPageBreak ( const SwNode rNode)

Does a node have a "page break before" applied.

Both text nodes and tables in writer can have "page break before" This function gives a unified view to both entities

Parameters
rNodeThe SwNode to query the page break of
Returns
true if there is a page break, false otherwise

Definition at line 578 of file writerhelper.cxx.

References SvxFormatBreakItem::GetBreak(), SwNode::GetContentNode(), SwFormat::GetFormatAttr(), SwTable::GetFrameFormat(), SwTableNode::GetTable(), SwNode::GetTableNode(), SwNode::IsTableNode(), and RES_BREAK().

Referenced by wwSectionManager::InsertSegments().

◆ IsPlausableSingleWordSection()

bool sw::util::IsPlausableSingleWordSection ( const SwFrameFormat rTitleFormat,
const SwFrameFormat rFollowFormat 
)

See if two page formats can be expressed as a single word section.

Word doesn't have the idea of page descriptors and follow styles like writer does, the only thing it has is a section with a different title page. The only difference of the title page from the rest of the section is different headers/footers, everything else is the same.

So this function compares two writer page fmts and sees if the follow frame and the title frame are the same from word perspective except for the content of their headers.

Returns
true if the rTitleFormat followed by rFollowFormat could be expressed in word as a single word Section with different title page enabled.
See also
#i4320#/#i14509#/#i11717# for examples

Definition at line 376 of file writerwordglue.cxx.

References SwFormat::GetAttrSet(), SwFormat::GetCol(), SwFormatCol::GetColumns(), SwFormat::GetFrameSize(), lcl_getWordLRSpace(), and sw::util::HdFtDistanceGlue::StrictEqualTopBottom().

Referenced by MSWordExportBase::NeedSectionBreak(), MSWordExportBase::OutputSectionBreaks(), MSWordExportBase::SectionProperties(), and MSWordExportBase::SetCurrentPageDescFromNode().

◆ item_cast() [1/2]

template<class T >
const T & sw::util::item_cast ( const SfxPoolItem rItem)

Provide a dynamic_cast style cast for SfxPoolItems.

A SfxPoolItem generally need to be cast back to its original type to be useful, which is both tedious and error prone. So item_cast is a helper template to aid the process and test if the cast is correct.

Parameters
rItemThe SfxPoolItem which is to be casted

@tplparam T A SfxPoolItem derived class to cast rItem to

Returns
A rItem upcasted back to a T
Exceptions
std::bad_castThrown if the rItem was not a T

Definition at line 223 of file writerhelper.hxx.

◆ item_cast() [2/2]

template<class T >
const T * sw::util::item_cast ( const SfxPoolItem pItem)

Provide a dynamic_cast style cast for SfxPoolItems.

A SfxPoolItem generally need to be cast back to its original type to be useful, which is both tedious and error prone. So item_cast is a helper template to aid the process and test if the cast is correct.

Parameters
pItemThe SfxPoolItem which is to be casted

@tplparam T A SfxPoolItem derived class to cast pItem to

Returns
A pItem upcasted back to a T or 0 if pItem was not a T

Definition at line 244 of file writerhelper.hxx.

◆ MakeSafePositioningValue()

SwTwips sw::util::MakeSafePositioningValue ( SwTwips  nIn)

Clips a value to MAX/MIN 16bit value to make it safe for use as a position value to give to writer.

i.e. +-57.8cm. Sometimes we see ridiculous values for positioning in rtf and word document, this captures such ones and clips them to values which are still outside the document, but of a value that doesn't cause problems for writer's layout, e.g. see https://bz.apache.org/ooo/show_bug.cgi?id=i9245

Parameters
nIn
Returns
nIn clipped to min/max 16bit value

Definition at line 332 of file writerhelper.cxx.

Referenced by SwWW8ImplReader::MatchSdrItemsIntoFlySet(), and SwWW8ImplReader::ProcessEscherAlign().

◆ MoveAttrFieldmarkInserted()

void sw::util::MoveAttrFieldmarkInserted ( SwFltPosition rMkPos,
SwFltPosition rPtPos,
const SwPosition rPos 
)

◆ PolygonFromPolyPolygon()

tools::Polygon sw::util::PolygonFromPolyPolygon ( const tools::PolyPolygon rPolyPoly)

Make a best fit Polygon from a PolyPolygon.

For custom contours in writer we use a PolyPolygon, while word uses a simple polygon, so we need to try and make the best polygon from a PolyPolygon

Parameters
rPolyPolyThe tools::PolyPolygon to try and turn into a Polygon
Returns
best fit Polygon from rPolyPoly

Definition at line 595 of file writerhelper.cxx.

References a, tools::PolyPolygon::Count(), and tools::Polygon::GetSize().

Referenced by CorrectWordWrapPolygonForExport().

◆ SearchPoolItems()

const SfxPoolItem * sw::util::SearchPoolItems ( const ww8::PoolItems rItems,
sal_uInt16  eType 
)

Definition at line 407 of file writerhelper.cxx.

References eType.

Referenced by MSWordExportBase::ExportPoolItemsToCHP(), and HasItem().

◆ SortByAssignedOutlineStyleListLevel()

void sw::util::SortByAssignedOutlineStyleListLevel ( ww8::ParaStyles rStyles)

Sort sequence of Paragraph Styles by assigned outline style list level.

Sort ParaStyles in ascending order of assigned outline style list level, e.g. given Normal/Heading1/Heading2/.../Heading10 at their default assigned outline style list levels of body level/level 1/level 2/.../level 10

#i98791# adjust the sorting algorithm due to introduced outline level attribute

Parameters
rStylesThe ParaStyles to sort

Definition at line 474 of file writerhelper.cxx.

Referenced by SwWW8ImplReader::SetOutlineStyles().

◆ UpdateFramePositions()

void sw::util::UpdateFramePositions ( ww8::Frames rFrames)

fix up frame positions, must be called after SetRedlineFlags

Definition at line 490 of file writerhelper.cxx.

References SwFormatAnchor::GetAnchorId(), and SwFormatAnchor::GetContentAnchor().

Referenced by MSWordExportBase::ExportDocument().