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  InsertedTableClient
 
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  SameOpenRedlineType
 
class  SetEndIfOpen
 
class  SetInDocAndDelete
 
class  SetLayer
 Make setting a drawing object's layer in a Writer document easy. More...
 
class  WrtRedlineAuthor
 

Typedefs

typedef std::map< sal_uInt16, std::size_t > AuthorInfos
 Redlining Authors, map word author key to writer author value. More...
 
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...
 
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)
 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 & ItemGet (const SwContentNode &rNode, sal_uInt16 eType)
 Extract a SfxPoolItem derived property from a SwContentNode. More...
 
template<class T >
const T & ItemGet (const SwFormat &rFormat, sal_uInt16 eType)
 Extract a SfxPoolItem derived property from a SwFormat. More...
 
template<class T >
const T & ItemGet (const SfxItemSet &rSet, sal_uInt16 eType)
 Extract a SfxPoolItem derived property from a SfxItemSet. More...
 
template<class T >
const T & DefaultItemGet (const SfxItemPool &rPool, sal_uInt16 eType)
 Extract a default SfxPoolItem derived property from a SfxItemPool. More...
 
template<class T >
const T & DefaultItemGet (const SwDoc &rDoc, sal_uInt16 eType)
 Extract a default SfxPoolItem derived property from a SwDoc. More...
 
template<class T >
const T * HasItem (const ww8::PoolItems &rItems, sal_uInt16 eType)
 
bool IsPlausableSingleWordSection (const SwFrameFormat &rTitleFormat, const SwFrameFormat &rFollowFormat)
 See if two page formats can be expressed as a single word section. More...
 

Typedef Documentation

typedef std::map<sal_uInt16, std::size_t> sw::util::AuthorInfos

Redlining Authors, map word author key to writer author value.

Definition at line 108 of file msfilter.hxx.

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

Definition at line 372 of file msfilter.hxx.

Function Documentation

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 427 of file writerhelper.cxx.

References SfxItemSet::ClearItem(), and SwFormatCharFormat::GetCharFormat().

Referenced by SwWW8AttrIter::OutAttr().

tools::Polygon sw::util::CorrectWordWrapPolygonForExport ( const tools::PolyPolygon rPolyPoly,
const SwNoTextNode pNd 
)
template<class T >
const T& sw::util::DefaultItemGet ( const SfxItemPool rPool,
sal_uInt16  eType 
)

Extract a default SfxPoolItem derived property from a SfxItemPool.

Writer's attributes are retrieved by passing a numeric identifier and receiving a SfxPoolItem reference which must then typically be cast back to its original type which is both tedious and verbose.

DefaultItemGet returns a reference to the default property of a given SfxItemPool for a given property id, e.g. default fontsize

DefaultItemGet uses item_cast () on the retrieved reference to test that the retrieved property is of the type that the developer thinks it is.

Parameters
rPoolThe SfxItemPool whose default property we want
eTypeThe numeric identifier of the default property to be retrieved

T A SfxPoolItem derived class of the retrieved property

Exceptions
std::bad_castThrown if the property was not a T
Returns
The T requested

Definition at line 360 of file writerhelper.hxx.

References SfxItemPool::GetDefaultItem(), and item_cast().

template<class T >
const T& sw::util::DefaultItemGet ( const SwDoc rDoc,
sal_uInt16  eType 
)

Extract a default SfxPoolItem derived property from a SwDoc.

Writer's attributes are retrieved by passing a numeric identifier and receiving a SfxPoolItem reference which must then typically be cast back to its original type which is both tedious and verbose.

DefaultItemGet returns a reference to the default property of a given SwDoc (Writer Document) for a given property id, e.g default fontsize

DefaultItemGet uses item_cast () on the retrieved reference to test that the retrieved property is of the type that the developer thinks it is.

Parameters
rPoolThe SfxItemPool whose default property we want
eTypeThe numeric identifier of the default property to be retrieved

T A SfxPoolItem derived class of the retrieved property

Exceptions
std::bad_castThrown if the property was not a T
Returns
The T requested

Definition at line 393 of file writerhelper.hxx.

References SwDoc::GetAttrPool().

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 470 of file writerhelper.cxx.

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

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

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 494 of file writerhelper.cxx.

References SwDoc::GetAllFlyFormats().

Referenced by MSWordExportBase::ExportDocument().

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 517 of file writerhelper.cxx.

References SwNode::GetIndex().

Referenced by SwWW8AttrIter::SwWW8AttrIter().

const SwNumRule * sw::util::GetNormalNumRuleFromTextNode ( const SwTextNode rTextNode)
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 583 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().

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 525 of file writerhelper.cxx.

References SwNumRule::Get(), and MAXLEVEL.

Referenced by SwWW8FltControlStack::GetNumFormatFromStack(), and 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 536 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().

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

Definition at line 564 of file writerhelper.cxx.

References GetNormalNumRuleFromTextNode().

Referenced by SwWW8ImplReader::AppendTextNode().

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 455 of file writerhelper.cxx.

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

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

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 442 of file writerhelper.cxx.

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

Referenced by SwWW8ImplReader::SetOutlineStyles().

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 392 of file writerhelper.cxx.

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

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

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 515 of file writerwordglue.cxx.

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

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

Definition at line 473 of file writerhelper.hxx.

References item_cast(), and SearchPoolItems().

Referenced by IMPL_LINK().

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 593 of file writerhelper.cxx.

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

Referenced by wwSectionManager::InsertSegments().

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 360 of file writerwordglue.cxx.

References SwFormat::GetAttrSet(), SwFormat::GetCol(), SwFormatCol::GetColumns(), SwFormat::GetFrameSize(), and lcl_getWordLRSpace().

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

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

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 225 of file writerhelper.hxx.

Referenced by DefaultItemGet(), HasItem(), ItemGet(), and SwWW8AttrIter::OutAttr().

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 errorprone. 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

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 247 of file writerhelper.hxx.

template<class T >
const T& sw::util::ItemGet ( const SwContentNode rNode,
sal_uInt16  eType 
)

Extract a SfxPoolItem derived property from a SwContentNode.

Writer's attributes are retrieved by passing a numeric identifier and receiving a SfxPoolItem reference which must then typically be cast back to its original type which is both tedious and verbose.

ItemGet uses item_cast () on the retrieved reference to test that the retrieved property is of the type that the developer thinks it is.

Parameters
rNodeThe SwContentNode to retrieve the property from
eTypeThe numeric identifier of the property to be retrieved

T A SfxPoolItem derived class of the retrieved property

Exceptions
std::bad_castThrown if the property was not a T
Returns
The T requested

Definition at line 274 of file writerhelper.hxx.

References SwContentNode::GetAttr(), and item_cast().

template<class T >
const T& sw::util::ItemGet ( const SwFormat rFormat,
sal_uInt16  eType 
)

Extract a SfxPoolItem derived property from a SwFormat.

Writer's attributes are retrieved by passing a numeric identifier and receiving a SfxPoolItem reference which must then typically be cast back to its original type which is both tedious and verbose.

ItemGet uses item_cast () on the retrieved reference to test that the retrieved property is of the type that the developer thinks it is.

Parameters
rFormatThe SwFormat to retrieve the property from
eTypeThe numeric identifier of the property to be retrieved

T A SfxPoolItem derived class of the retrieved property

Exceptions
std::bad_castThrown if the property was not a T

Definition at line 300 of file writerhelper.hxx.

References SwFormat::GetFormatAttr(), and item_cast().

template<class T >
const T& sw::util::ItemGet ( const SfxItemSet rSet,
sal_uInt16  eType 
)

Extract a SfxPoolItem derived property from a SfxItemSet.

Writer's attributes are retrieved by passing a numeric identifier and receiving a SfxPoolItem reference which must then typically be cast back to its original type which is both tedious and verbose.

ItemGet uses item_cast () on the retrieved reference to test that the retrieved property is of the type that the developer thinks it is.

Parameters
rSetThe SfxItemSet to retrieve the property from
eTypeThe numeric identifier of the property to be retrieved

T A SfxPoolItem derived class of the retrieved property

Exceptions
std::bad_castThrown if the property was not a T
Returns
The T requested

Definition at line 328 of file writerhelper.hxx.

References SfxItemSet::Get(), and item_cast().

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 344 of file writerhelper.cxx.

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

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 610 of file writerhelper.cxx.

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

Referenced by CorrectWordWrapPolygonForExport().

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

Definition at line 418 of file writerhelper.cxx.

Referenced by HasItem().

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 485 of file writerhelper.cxx.

Referenced by SwWW8ImplReader::SetOutlineStyles().

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

fix up frame positions, must be called after SetRedlineFlags

Definition at line 501 of file writerhelper.cxx.

References SwFormat::GetAnchor(), SwFormatAnchor::GetAnchorId(), SwFormatAnchor::GetContentAnchor(), ww8::Frame::GetFrameFormat(), and ww8::Frame::SetPosition().

Referenced by MSWordExportBase::ExportDocument().