C# Class SIL.FieldWorks.Common.Controls.XmlViewsUtils

Utility functions for XmlViews. Some of these may eventually migrate to a more general Utils if relevant.
Mostrar archivo Open project: sillsdev/FieldWorks

Protected Properties

Property Type Description
s_cwsMulti int
s_fMultiFirst bool
s_qwsCurrent IWritingSystem
s_sMultiSep string

Public Methods

Method Description
AlphaCompNumberString ( int val ) : string

Return a string such that ICU alphabetic comparison of the strings will produce the same results as numberic comparison of the values. For positive integers the string is a recognizeable representation of the number (with extra leading zeros); for negative, it is not recognizeable but works.

AlphaCompPosNumString ( int val ) : string

Alphas the comp pos num string.

Assemble ( string items ) : string[]

Return the concatenation of all the input strings as a single string.

CollectBrowseItems ( int hvo, XmlNode colSpec, ArrayList collector, IFwMetaDataCache mdc, ISilDataAccess sda, LayoutCache layouts ) : void

Given one of the original list items, and the spec of the column we want to sort by, add to collector whatever ManyOnePathSortItems are appropriate.

CopyReplacingParamDefault ( XmlNode input, string paramId, string val ) : XmlNode

Copies the replacing param default.

CopyWithParamDefaults ( XmlNode input ) : XmlNode

If any attributes of input (or its children) are of the form "$param=default", generate a complete copy of input in which "$param=default" is replaced with "default", and return it. Otherwise just return input.

CorrespondingItems ( List sourceNodes, List selectNodes, string attName ) : List

Answer a list containing, for each node in selectNodes, the item in sourceNodes that has the same value for the attribute attName.

DateTimeCompString ( System.DateTime dt ) : string

Return a string such that ICU alphabetic comparison of the strings will produce the same results as DateTime.Compare of the values.

FindIndexOfAttrVal ( List nodes, string attName, string attVal, SIL.Utils.StringTable tbl ) : int

Find the index of the node in nodes that has value attVal for attribute attName. Return -1 if not found.

FindIndexOfMatchingNode ( IEnumerable nodes, XmlNode target ) : int

Find the index of the node in nodes that 'matches' the target node. Return -1 if not found.

FindNodeWithAttrVal ( List nodes, string attName, string attVal, SIL.Utils.StringTable tbl ) : XmlNode

Finds the node with attr val.

FindParams ( XmlNode input ) : string[]

Finds the params.

FindWsParam ( XmlNode node ) : string

Search the node for an element with an attribute that has a value that looks like "$ws=..." and return the "...".

GetDisplayCommandForColumn ( IManyOnePathSortItem bvi, XmlNode colSpec, IFwMetaDataCache mdc, ISilDataAccess sda, LayoutCache layouts, int &hvo, List collectOuterStructParts ) : NodeDisplayCommand

This returns a NodeDisplayCommand containing thd node for GetNodeToUseForColumn. However, it distinguishes whether to display the children of this node or the node itself by returning the appropriate kind of NodeDisplayCommand.

GetGuidForUnspecifiedComplexFormType ( ) : System.Guid

Returns a 'fake' Guid used to filter unspecified Complex Form types in XmlVc. Setup in configuration files by XmlDocConfigureDlg.

GetGuidForUnspecifiedVariantType ( ) : System.Guid

Returns a 'fake' Guid used to filter unspecified Variant types in XmlVc. Setup in configuration files by XmlDocConfigureDlg.

GetNodeToUseForColumn ( IManyOnePathSortItem bvi, XmlNode colSpec, IFwMetaDataCache mdc, ISilDataAccess sda, LayoutCache layouts, int &hvo, List collectOuterStructParts ) : XmlNode

We want to display the object bvi.KeyObject, or one of its pathobjects, in a column specified by colSpec. Determine the hvo and XmlNode that we should use as the root for the cell. By default, we display the first object in the path, using the base node derived from the colSpec. However, if the colSpec begins with a path compatible with bvi.PathFlid(0), we can use bvi.PathObject(1) and the appropriate derived node. If all flids match we can use bvi.KeyObject itself. If collectOuterStructParts is non-null, it accumulates containing parts that are structural, like para, span, div.

GetWsFromString ( string wsParam, SIL.FieldWorks.FDO.FdoCache cache ) : int

Convert the string found for a writing system to the appropriate integer code (hvo).

GetWsRequiresObject ( XmlNode frag ) : bool

Return true if the specified fragment requires an hvo (and possibly flid) for its interpretation. Currently this assumes just the "ws" attribute, since smartws is obsolete.

GetWsRequiresObject ( string wsSpec ) : bool

Return true if the specified fragment requires an hvo (and possibly flid) for its interpretation. Currently this assumes just the "ws" attribute, since smartws is obsolete.

HasParam ( XmlNode input ) : bool

Find the value of the first parameter-like attribute value "$param=default"

StringsFor ( SIL.FieldWorks.FDO.FdoCache fdoCache, ISilDataAccess sda, XmlNode layout, int hvo, LayoutCache layoutCache, XmlNode caller, SIL.Utils.StringTable stringTbl, int wsForce ) : string[]

Returns an array of string values (keys) for the objects under this layout node.

TryFindPluralFormFromClassId ( IFwMetaDataCache mdc, SIL.Utils.StringTable tbl, int clsId, string &titleStr ) : bool

TryFindPluralFormFromFlid ( IFwMetaDataCache mdc, SIL.Utils.StringTable tbl, int owningFlid, string &titleStr ) : bool

looks up plural form alternative first for given flid, secondly for its destination class.

TryFindString ( SIL.Utils.StringTable tbl, string group, string key, string &result ) : bool

TryMatchExistingAttributes ( XmlNode colSpec1, XmlNode colSpec2, Queue &possibleAttributesToMatch ) : bool

go through possible attributes to match, and return true when the ones that exist match the same attributes in another node.

Private Methods

Method Description
AddMultipleAlternatives ( SIL.FieldWorks.FDO.FdoCache cache, ISilDataAccess sda, IEnumerable wsIds, int hvo, int flid, XmlNode frag ) : string
AddSeparator ( string &item, int ichInsert, XmlNode layout ) : void
AddStringFromOtherObj ( XmlNode frag, int hvoTarget, SIL.FieldWorks.FDO.FdoCache cache, ISilDataAccess sda ) : string[]
AppendInt ( int sofar, int add ) : int[]
AssembleChildKeys ( SIL.FieldWorks.FDO.FdoCache fdoCache, ISilDataAccess sda, XmlNode layout, int hvo, LayoutCache layoutCache, XmlNode caller, SIL.Utils.StringTable stringTbl, int wsForce ) : string[]
ChildKeys ( SIL.FieldWorks.FDO.FdoCache fdoCache, ISilDataAccess sda, XmlNode layout, int hvo, LayoutCache layoutCache, XmlNode caller, SIL.Utils.StringTable stringTbl, int wsForce ) : string[]

Returns an array of string values (keys) for the objects under the layout child nodes.

CollectBrowseItems ( int hvo, XmlNode node, ArrayList collector, IFwMetaDataCache mdc, ISilDataAccess sda, LayoutCache layouts, XmlNode caller, int hvos, int flids ) : void

Main (recursive) part of CollectBrowseItems. Given that hvo is to be displayed using node, figure what objects to put in the list.

Concatenate ( string first, string second ) : string[]
DisplayMultiSep ( XmlNode frag ) : string
DisplayWsLabel ( IWritingSystem ws, SIL.FieldWorks.FDO.FdoCache cache ) : string
FindMainChild ( XmlNode node ) : XmlNode

Finds the main child.

FoundStringTableString ( string key, string result ) : bool

determine if string table query gave a significant result (i.e. not *{key}* format).

GetArrayLength ( string items ) : int
GetDisplayCommandForColumn1 ( IManyOnePathSortItem bvi, XmlNode node, IFwMetaDataCache mdc, ISilDataAccess sda, LayoutCache layouts, int depth, int &hvo, List collectOuterStructParts ) : NodeDisplayCommand

Recursive implementation method for GetDisplayCommandForColumn.

GetFlid ( ISilDataAccess sda, XmlNode frag, int hvo ) : int

This is a simplified version of XmlVc.GetFlid. It does not look for a flid attr, nor try to cache the result. It looks for a "field" property, and optionally a "class" one, and uses them (or the class of hvo, if "class" is missing) to figure the flid. Virtual properties are assumed already created.

GetLayoutNodeForChild ( ISilDataAccess sda, int hvoTarget, int flid, string targetLayoutName, XmlNode layout, LayoutCache layoutCache ) : XmlNode
GetNodeForRelatedObject ( int hvoDst, XmlNode caller, XmlNode node, LayoutCache layouts, ISilDataAccess sda ) : XmlNode

The node argument is an "obj" or "seq" element, and caller (if not null) is a part element that invoked the node and may override its "layout" attribute. Apply the same logic used by XmlVc to determine the node that will be used to display the destination object hvoDst

ProcessMultiLingualChildren ( SIL.FieldWorks.FDO.FdoCache fdoCache, ISilDataAccess sda, XmlNode frag, int hvo, LayoutCache layoutCache, XmlNode caller, SIL.Utils.StringTable stringTbl, int wsForce ) : string[]

Process a fragment's children against multiple writing systems.

XmlViewsUtils ( ) : System

Method Details

AlphaCompNumberString() public static method

Return a string such that ICU alphabetic comparison of the strings will produce the same results as numberic comparison of the values. For positive integers the string is a recognizeable representation of the number (with extra leading zeros); for negative, it is not recognizeable but works.
public static AlphaCompNumberString ( int val ) : string
val int
return string

AlphaCompPosNumString() public static method

Alphas the comp pos num string.
public static AlphaCompPosNumString ( int val ) : string
val int The val.
return string

Assemble() static public method

Return the concatenation of all the input strings as a single string.
static public Assemble ( string items ) : string[]
items string
return string[]

CollectBrowseItems() public static method

Given one of the original list items, and the spec of the column we want to sort by, add to collector whatever ManyOnePathSortItems are appropriate.
public static CollectBrowseItems ( int hvo, XmlNode colSpec, ArrayList collector, IFwMetaDataCache mdc, ISilDataAccess sda, LayoutCache layouts ) : void
hvo int The hvo.
colSpec System.Xml.XmlNode The col spec.
collector System.Collections.ArrayList The collector.
mdc IFwMetaDataCache The MDC.
sda ISilDataAccess The sda.
layouts LayoutCache The layouts.
return void

CopyReplacingParamDefault() public static method

Copies the replacing param default.
public static CopyReplacingParamDefault ( XmlNode input, string paramId, string val ) : XmlNode
input System.Xml.XmlNode The input.
paramId string The param id.
val string The val.
return System.Xml.XmlNode

CopyWithParamDefaults() public static method

If any attributes of input (or its children) are of the form "$param=default", generate a complete copy of input in which "$param=default" is replaced with "default", and return it. Otherwise just return input.
public static CopyWithParamDefaults ( XmlNode input ) : XmlNode
input System.Xml.XmlNode
return System.Xml.XmlNode

CorrespondingItems() public static method

Answer a list containing, for each node in selectNodes, the item in sourceNodes that has the same value for the attribute attName.
public static CorrespondingItems ( List sourceNodes, List selectNodes, string attName ) : List
sourceNodes List
selectNodes List
attName string
return List

DateTimeCompString() public static method

Return a string such that ICU alphabetic comparison of the strings will produce the same results as DateTime.Compare of the values.
public static DateTimeCompString ( System.DateTime dt ) : string
dt System.DateTime
return string

FindIndexOfAttrVal() public static method

Find the index of the node in nodes that has value attVal for attribute attName. Return -1 if not found.
public static FindIndexOfAttrVal ( List nodes, string attName, string attVal, SIL.Utils.StringTable tbl ) : int
nodes List The nodes.
attName string Name of the att.
attVal string The att val.
tbl SIL.Utils.StringTable The TBL.
return int

FindIndexOfMatchingNode() public static method

Find the index of the node in nodes that 'matches' the target node. Return -1 if not found.
public static FindIndexOfMatchingNode ( IEnumerable nodes, XmlNode target ) : int
nodes IEnumerable The nodes.
target System.Xml.XmlNode The target.
return int

FindNodeWithAttrVal() public static method

Finds the node with attr val.
public static FindNodeWithAttrVal ( List nodes, string attName, string attVal, SIL.Utils.StringTable tbl ) : XmlNode
nodes List The nodes.
attName string Name of the att.
attVal string The att val.
tbl SIL.Utils.StringTable The TBL.
return System.Xml.XmlNode

FindParams() public static method

Finds the params.
public static FindParams ( XmlNode input ) : string[]
input System.Xml.XmlNode The input.
return string[]

FindWsParam() public static method

Search the node for an element with an attribute that has a value that looks like "$ws=..." and return the "...".
public static FindWsParam ( XmlNode node ) : string
node System.Xml.XmlNode
return string

GetDisplayCommandForColumn() public static method

This returns a NodeDisplayCommand containing thd node for GetNodeToUseForColumn. However, it distinguishes whether to display the children of this node or the node itself by returning the appropriate kind of NodeDisplayCommand.
public static GetDisplayCommandForColumn ( IManyOnePathSortItem bvi, XmlNode colSpec, IFwMetaDataCache mdc, ISilDataAccess sda, LayoutCache layouts, int &hvo, List collectOuterStructParts ) : NodeDisplayCommand
bvi IManyOnePathSortItem
colSpec System.Xml.XmlNode
mdc IFwMetaDataCache
sda ISilDataAccess
layouts LayoutCache
hvo int
collectOuterStructParts List
return NodeDisplayCommand

GetGuidForUnspecifiedComplexFormType() public static method

Returns a 'fake' Guid used to filter unspecified Complex Form types in XmlVc. Setup in configuration files by XmlDocConfigureDlg.
public static GetGuidForUnspecifiedComplexFormType ( ) : System.Guid
return System.Guid

GetGuidForUnspecifiedVariantType() public static method

Returns a 'fake' Guid used to filter unspecified Variant types in XmlVc. Setup in configuration files by XmlDocConfigureDlg.
public static GetGuidForUnspecifiedVariantType ( ) : System.Guid
return System.Guid

GetNodeToUseForColumn() public static method

We want to display the object bvi.KeyObject, or one of its pathobjects, in a column specified by colSpec. Determine the hvo and XmlNode that we should use as the root for the cell. By default, we display the first object in the path, using the base node derived from the colSpec. However, if the colSpec begins with a path compatible with bvi.PathFlid(0), we can use bvi.PathObject(1) and the appropriate derived node. If all flids match we can use bvi.KeyObject itself. If collectOuterStructParts is non-null, it accumulates containing parts that are structural, like para, span, div.
public static GetNodeToUseForColumn ( IManyOnePathSortItem bvi, XmlNode colSpec, IFwMetaDataCache mdc, ISilDataAccess sda, LayoutCache layouts, int &hvo, List collectOuterStructParts ) : XmlNode
bvi IManyOnePathSortItem The bvi.
colSpec System.Xml.XmlNode The col spec.
mdc IFwMetaDataCache The MDC.
sda ISilDataAccess The sda.
layouts LayoutCache The layouts.
hvo int The hvo.
collectOuterStructParts List The collect outer struct parts.
return System.Xml.XmlNode

GetWsFromString() public static method

Convert the string found for a writing system to the appropriate integer code (hvo).
public static GetWsFromString ( string wsParam, SIL.FieldWorks.FDO.FdoCache cache ) : int
wsParam string
cache SIL.FieldWorks.FDO.FdoCache
return int

GetWsRequiresObject() public static method

Return true if the specified fragment requires an hvo (and possibly flid) for its interpretation. Currently this assumes just the "ws" attribute, since smartws is obsolete.
public static GetWsRequiresObject ( XmlNode frag ) : bool
frag System.Xml.XmlNode
return bool

GetWsRequiresObject() public static method

Return true if the specified fragment requires an hvo (and possibly flid) for its interpretation. Currently this assumes just the "ws" attribute, since smartws is obsolete.
public static GetWsRequiresObject ( string wsSpec ) : bool
wsSpec string
return bool

HasParam() public static method

Find the value of the first parameter-like attribute value "$param=default"
public static HasParam ( XmlNode input ) : bool
input System.Xml.XmlNode
return bool

StringsFor() static public method

Returns an array of string values (keys) for the objects under this layout node.
static public StringsFor ( SIL.FieldWorks.FDO.FdoCache fdoCache, ISilDataAccess sda, XmlNode layout, int hvo, LayoutCache layoutCache, XmlNode caller, SIL.Utils.StringTable stringTbl, int wsForce ) : string[]
fdoCache SIL.FieldWorks.FDO.FdoCache The fdo cache.
sda ISilDataAccess The sda.
layout System.Xml.XmlNode The layout.
hvo int The hvo.
layoutCache LayoutCache The layout cache.
caller System.Xml.XmlNode where layout is a component of a 'part' element, caller /// is the 'part ref' that invoked it.
stringTbl SIL.Utils.StringTable The string TBL.
wsForce int if non-zero, "string" elements are forced to use that writing system for multistrings.
return string[]

TryFindPluralFormFromClassId() public static method

public static TryFindPluralFormFromClassId ( IFwMetaDataCache mdc, SIL.Utils.StringTable tbl, int clsId, string &titleStr ) : bool
mdc IFwMetaDataCache
tbl SIL.Utils.StringTable
clsId int
titleStr string *{dstClass}* if couldn't find result.
return bool

TryFindPluralFormFromFlid() public static method

looks up plural form alternative first for given flid, secondly for its destination class.
public static TryFindPluralFormFromFlid ( IFwMetaDataCache mdc, SIL.Utils.StringTable tbl, int owningFlid, string &titleStr ) : bool
mdc IFwMetaDataCache
tbl SIL.Utils.StringTable
owningFlid int
titleStr string *{dstClass}* if couldn't find result.
return bool

TryFindString() public static method

public static TryFindString ( SIL.Utils.StringTable tbl, string group, string key, string &result ) : bool
tbl SIL.Utils.StringTable
group string
key string
result string
return bool

TryMatchExistingAttributes() public static method

go through possible attributes to match, and return true when the ones that exist match the same attributes in another node.
public static TryMatchExistingAttributes ( XmlNode colSpec1, XmlNode colSpec2, Queue &possibleAttributesToMatch ) : bool
colSpec1 System.Xml.XmlNode
colSpec2 System.Xml.XmlNode
possibleAttributesToMatch Queue the attributes to try to match, in the order we try to match them. /// if this routine returns true then this the top queue element will be the attribute we matched on.
return bool

Property Details

s_cwsMulti static_oe protected_oe property

static protected int s_cwsMulti
return int

s_fMultiFirst static_oe protected_oe property

static protected bool s_fMultiFirst
return bool

s_qwsCurrent static_oe protected_oe property

Current writing system id being used in multilingual fragment. Some methods that refer to this variable are static, so it must be static also. REVIEW (EberhardB/TimS): this probably won't work with different databases that have different default ws!
static protected IWritingSystem s_qwsCurrent
return IWritingSystem

s_sMultiSep static_oe protected_oe property

static protected string s_sMultiSep
return string