[ooo-build-commit] doc/sw-flr.otl scratch/writer

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Wed Sep 9 05:29:50 PDT 2009


 doc/sw-flr.otl                |  299 +++++++++++++++++
 scratch/writer/gdbinit-cbosdo |  729 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 1028 insertions(+)

New commits:
commit dad3b1a474d9015594f8dc68009d97ad1b200c9e
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date:   Wed Sep 9 14:30:12 2009 +0200

    From the writer training with Florian
    
    * doc/sw-flr.otl: some notes (should be merged with sw.txt)
    * scratch/writer/gdbinit-cbosdo: my gdbinit

diff --git a/doc/sw-flr.otl b/doc/sw-flr.otl
new file mode 100644
index 0000000..5ee0f8c
--- /dev/null
+++ b/doc/sw-flr.otl
@@ -0,0 +1,299 @@
+Core
+	Positions
+		: UNO API doesn't use SwPaM / SwPosition: creates a bookmark (see the UNO cursor)
+	SwDoc
+		Nodes
+			: SwDoc::aNodes
+			: Infos taken from sw/inc/ndarr.hxx
+			:
+			: || Nodes begin/end | Containing |
+			: | 1st | empty |
+			: | 2nd | footnotes, endnotes |
+			: | 3rd | Headers, footers, flys |
+			: | 4th | Redlines, but doesn't seems to be used |
+			: | 5th | Content |
+			:
+			: The redlines are stored in SwDoc::pRedlineTbl. This member is an
+			: SvArray of SwRedline.
+			:
+			: The undo informations seems to be stored in the SwDoc::pUndos
+			: rather than in the aUndoNodes structure. The latter structure
+			: seems to be unused.
+			:
+			: Text nodes are using tool strings, which are only 16bits index.
+			: Paragraphs can't then be longer than 65k characters.
+		Formatting
+			: The formatting is stored in SwTxtNode::m_pSwpHints. One
+			: formatting is one hint. A hint is composed by a start and an
+			: end. For example, if "Cell1" is bold on the "Cell" word, then
+			: the hint will be "Bold [0,4)"
+			:
+			: Some text attributes have a CJK (or even BiDi) equivalent
+			: attribute. OOo and MSO seems to have some problems on that part
+			: as these are sometimes created without any CJK/BiDi scripts.
+	SvPointerArrays
+		SV_DECL_PTRARR_SORT(SwpHtStart,SwTxtAttr*,1,1)
+			: Declares SwpHtStart as an array of SwTxtAttr*
+			: Contains a Count() method and [] operator
+	SfxPoolItem
+		: used for any attribute in OOo.
+		: ( sv: StarView, UI class view marketted by StarDivision )
+		:
+		: Which IDs are stored in inc/hintids.hxx
+		: 
+		SfxItemSet:
+			: Interesting header file sw/inc/charatr.hxx#81
+			_pWhichRanges
+				:stores the possible Which of the stored items
+				>STRUCTURE
+				> Loop until there is a 0 value	
+				> value n: the start of the range
+				> value n+1 the end of the range
+			_nCount 
+				:the number of items
+			_aItems 
+				: Contains all the items. The array contains as much values as
+				: what is possible for the range. If an item isn't set: the
+				: value in the _aItems is 0.
+				: 
+				: All the possible values of the first range are stored first, then all
+				: the possible values for the second range, and so on.
+			_pParent
+				: The parent SfxItemSet are used when possible to find the
+				: value defined in one of the parents.	
+	Lists
+		A SwNumberTree is maintained at the document level
+		Each numbered node has a pointer to the element in the SwNumberTree
+		Virtual nodes are created for missing levels in the tree
+	Undo
+		: aUnodeNodes stores mainly the entire removed nodes (may be other
+		: cases ?). Everything else is in SwDoc::pUndos.
+		:
+		: Constants for the undo types are defined in sw/inc/swundo.hxx.
+
+	Tables
+		: The start node of the table is a SwTableNode. pTable: reference to
+		: the SwTable object. On a table, there is a list of lines
+		: (SwTableLine). On a SwTableLine, pUpper is the parent SwTable.
+		Historic point
+			: The old table model is considering the table as one big splitted
+			: cell.
+			: The new table model is the same as HTML model
+			:
+			In Odf: table:is-subtable
+				: When there are merged cells: other cells in the row will contain
+				: a nested table if table:is-subtable="true" attribute
+			In the SwTable
+				: If the Cell pSttNd == NULL, then the cell is a "subtable" of
+				: the old model.
+				: In that case, the aLines member isn't empty
+				:
+				: The SwTableBox.nLines contains either lines or columns: it
+				: changes everytime (after a column split, there is a row
+				: split)
+	Sections / TOC
+		Same Start/End node things than for tables.
+		A TOC is just a normal section
+			The title is in a section
+			The contents + title section are in another section
+			WW8 interop problems
+				: During the WW8 import of TOC, the Word TOC is thrown away
+				: and an OOo TOC is generated: manual changes are lost
+				:
+				: Not an ODF problem
+		Never create empty sections: layout will crash!
+	Compatibility options
+		Stored in IDocumentSettingsAccess
+		Writer/Compatibility options dialog
+			Implemented in sw/source/ui/config/optcomp.cxx
+			Changing the options happens in the ViewShell do invalidate the layout
+Layout
+	: Most of the code is in sw/core/layout
+	:
+	: Layout was (caolan fixed a lot of it) running every xxx ms: even when
+	: nothing was done. 
+	: Many parts of the GUI code are based on timers.
+	Shells
+		ViewShell: used in the help viewer
+		EditShell: used by Writer.
+	Frames
+		SwFrm is the base for all the frames
+		There is always RootFrame / PageFrame
+		Every node has a pointer to a linked list of frames
+		Body frames
+			used in many places ( columns, pages... )
+			Mostly for reusing purpose
+		Points to a list of SwTxtPortion ( text runs )
+		Formatting
+			Each frame has its own format method
+			Calls the children format methods
+			Can create loops by having to call format method of an already formatted child
+	Portions
+		SwLinesLayout contains SwLinePortion
+		SwTxtPortion, SwTabPortion ( runs of text )
+		first ASCII characters
+			Character 0x1: something anchored as character
+			Other characters are used too: Defined in sw/inc/hintids.hxx
+				INWORD: same as 0x1 without line break after it
+		Using WhichIDs like in core
+			Defined in sw/source/core/inc/txttypes.hxx
+				: SwParaPortion (8002) -> SwLineLayout (8001)-> SwTxtPortion (8000)-> SwLinePortion 
+				: (-> inherits)
+				:
+				: POR_QUOVADIS: used for elements which are not rendered yet
+			SwTxtPortions are only storing the length of the portion. 
+				: To get the offset, all the previous portions have to be
+				: parsed
+		Layout done using the Visitor pattern
+			SwPortionHandler: interface for the visitor
+			A paragraph is split on two pages
+				Two text portions with the same text (the paragraph)
+				The second one is a follow text portion
+				The follow text portion will skip the first characters
+					The number of chars to skip is sometimes wrong
+			Fields are rendered using the Special method
+		SwTxtFrm::GetFormatted
+			Ensures the portion is formatte
+	Field problems
+		The problem
+			Wasn't possible to place the cursor in the field, but on the field
+		How this is done
+			Using field start / end markers
+			Bookmarks are used to link start and end together
+			Tweaked layout to make it looks like a field
+			The document can be marked as protected
+				Section can toggle be unprotected
+		Still to be done
+			All the UI for that feature
+		Patch not upstreamed
+			ODF would need to be changed to integrate the new fields stuffs
+			Sun doesn't want it
+	Lists
+		: Some flags in the EditShell are handling cursors before the start of
+		: the node to select the numbering.
+	Utils
+		scratch/writer/sw-dump-layout-tree.diff
+			: F12 dumps the current window layout in layout.xml
+			: Can still be improved to get some more useful infos
+		Sun devs
+			Frank Meies
+			Oliver Reiner Wittman
+	Misc problems
+		Device indenpendent layout
+			Some old .doc documents have a compatibility option to use the printer metrics
+				Layout is broken because the printer isn't the original one
+				Same problem with word
+			Layout done with hight res, printed on low res
+			OOo uses integers for fonts measurements, everything else uses float
+Word filters
+	Links
+		Office binary formats specs
+			http://www.microsoft.com/interop/docs/OfficeBinaryFormats.mspx
+	General structure
+		.DOC is an OLE storage
+			See the dumpers code to understand how this is done
+				scratch/mso-dumper/src/ole.py
+		2 important streams
+			"document" stream
+			table stream "0Table" and sometimes "1Table"
+	FIB ( File Information Block )
+		First bytes found in the "document" stream
+		fWhichTblStm
+			Defines which one of the table streams to use
+		fcMin
+			Offset to the first text character of the document
+	Table stream
+		Contains the SPRM: Single PRoperty Modifier
+			PAP: PAragraph Property
+			CHP: Character Property
+			PIC: PICture porperty
+			SEP: SEction Property
+			TAP: TAble Property
+		Contains attributes based on the index of the characters in the Text part
+			[6,25) BOLD (0x0835 0x01)
+				0x0835 is the SPRM
+				0x01 is the value of the SPRM
+			Some SPRM are more complex (variable length)
+				eg: sprmPChgabsPapx ( 0xC60D )
+			Sequence of SPRMs after each position
+		Paragraph SPRM are always including the whole paragraph (including the 13 char)
+		Indexes are encoded in PLEX
+			: <Start Index, End index, Offset to next pair>
+			FIB tells where those pairs are in the table stream
+				fcPlcfbteChpx, lcbPlcfbteChpx: Character properties
+				fcPlcfbtePapx, lcbPlcfbtePapx: Paragraph properties
+			Everything starting with PL
+				way to encode a start/end interval with informations attached to it
+	Tables
+		Structure
+			Cell and row marks only
+			sprmPFInTable SPRM set to true to indicate what is in the table
+			table Level SPRM to set the nesting level (not understood by old versions)
+	Piece table / Fast save
+		To consider when fComplex is set to 1 in FIB
+			Used by Word 2000 and above for Unicode support
+		General idea
+			The text is stored in the order the user adds the text
+			Character position: position in the text
+			File position: position of the character in the file (storage)
+		SPRMs are indexed on File positions
+	List table / List Override table
+	Comparison with RTF
+		Spec
+			http://www.microsoft.com/downloads/details.aspx?FamilyID=dd422b8d-ff06-4207-b476-6b5396a18a2b&displaylang=en
+		Similarities
+			SPRMs are encoded in \SPRMvalue 
+				with the name and value of SPRM
+				eg: \b1 (Bold set to 1)
+				eg {\b1 foo} bar: only foo is bold
+			Paragraphs boundaries 
+				started by \pard (paragraph default)
+				ended by \par (same like char 13
+			\intbl is used in the same way than in doc
+			Small changes
+				Last \par isn't mandatory
+				Starts with \rtf
+				\plain reset the character properties
+		Differences
+			Difference between a Command and a Destination
+				{\b Florian} -> Florian (even if b command isn't understood)
+				{\author Florian} -> gives nothing : this is a destination
+				Forced destination {\*\tag ...} starting with \*
+				Word uses it for backward compatibility
+					Example {\shp {\*\shpinst NEW SHAPE STUFFS}{\do ALTERNATIVE DRAWING OBJECT}}
+						Word 2003 would read the first part and throw away the \do
+						Word 95 won't know the \shp command
+							will read inside and ignore the \*\shpinst
+							will read the known \do destination
+				The RTF filter doesn't handles this difference between command and destination
+		Some strange things
+			\'01 means \x01
+			\uXXXX is an unicode character. If unicode can't be handled, use the next character
+WW8 Filter
+	Files
+		ww8par files
+			split due to some old compiler unable to handle a big file
+			handles the reading
+		ww8scan.hxx
+			Important header file for the import
+			wwSprmParser: parses an SPRM
+		ww8par.hxx
+			SwWW8ImplReader is the main class where everything happens
+
+
+
+Debugging with gdb
+	Misc gdb infos
+		>WARNING
+		> gdb variables are global, not local!
+		: use source /path/to/file to load gdb commands
+	Handy places to put breakpoints
+		; sw/source/core/doc/doc.cxx:457
+		; sw/source/core/doc/doc.cxx:793 (Insert method on SwDoc)
+
+Further docs
+	; http://wiki.services.openoffice.org/wiki/Writer_Core_And_Layout
+
+Misc infos
+	: for localization stuffs, have a look at ICU. Its includes have to be
+	: prefixed with "unicode" and everything is in the icu namespace
diff --git a/scratch/writer/gdbinit-cbosdo b/scratch/writer/gdbinit-cbosdo
new file mode 100644
index 0000000..d65cfb3
--- /dev/null
+++ b/scratch/writer/gdbinit-cbosdo
@@ -0,0 +1,729 @@
+handle SIGPWR nostop noprint
+handle SIGXCPU nostop noprint
+handle SIG33 nostop noprint
+
+# define "pu" command to display sal_Unicode *
+def pu
+  set $uni = $arg0
+  set $len = $arg1
+  set $i = 0
+  printf "\""
+  while (*$uni && $i++<$len && $i<255)
+    if (*$uni < 0x80)
+      printf "%c", *(char*)$uni++
+    else
+      printf "\\x%x", *(short*)$uni++
+    end
+  end
+  printf "\"\n"
+end
+
+# define "pus" command to display rtl_uString
+def pus
+  set $ns = $arg0
+  if ($ns.buffer)
+    pu $ns.buffer $ns.length
+  else
+    print "Invalid/non-initialized rtl_uString."
+  end
+end
+
+# define "pou" command to display rtl::OUString
+def pou
+  set $ns = $arg0
+  if ($ns.pData)
+    pus $ns.pData
+  else
+    print "Invalid/non-initialized OUString."
+  end
+end
+
+# define "ptu" command to display tools (Uni)String
+def ptu
+  set $ns = $arg0
+  if ($ns.mpData)
+    pu $ns.mpData->maStr $ns.mpData->mnLen
+  else
+    print "Invalid/non-initialized tools String."
+  end
+end
+
+define pIndent
+  set $level = $arg0
+  set $iLevel = 0
+  while ( $iLevel < $level )
+    printf "\t"
+    set $iLevel = $iLevel + 1
+  end
+end
+
+define pNodeType
+    if ($sw_node->nNodeType==1)
+        printf "ND_ENDNODE "
+    end 
+    if ($sw_node->nNodeType==2)
+        printf "ND_STARTNODE "
+    end
+    if ($sw_node->nNodeType==6)
+        printf "ND_TABLENODE "
+    end
+    if ($sw_node->nNodeType==8)
+        printf "ND_TEXTNODE "
+    end
+    if ($sw_node->nNodeType==0x10)
+        printf "ND_GRFNODE "
+    end
+    if ($sw_node->nNodeType==0x20)
+        printf "ND_OLENODE "
+    end
+    if ($sw_node->nNodeType==0x38)
+        printf "ND_CONTENTNODE "
+    end
+    if ($sw_node->nNodeType==0x30)
+        printf "ND_NOTXTNODE "
+    end
+    if ($sw_node->nNodeType==0x42)
+        printf "ND_SECTIONNODE "
+    end
+end
+
+define dump_pSfxItemSet
+   printf "count=%i\n", $arg0->_nCount
+   set $is_i=0
+   set $is_k=0
+   while($arg0->_pWhichRanges[$is_i]!=0)
+      printf "[%i; %i]\n", $arg0->_pWhichRanges[$is_i], $arg0->_pWhichRanges[$is_i+1]
+      set $is_j=$arg0->_pWhichRanges[$is_i]
+      while($is_j<=$arg0->_pWhichRanges[$is_i+1])
+         if ($arg0->_aItems[$is_k]!=0)
+            printf "%i %i %p\n", $is_k, $is_j, $arg0->_aItems[$is_k]
+         end
+         set $is_j++ 
+         set $is_k++
+      end
+      set $is_i=$is_i+2
+   end
+end
+
+
+define dump_pSwUndo
+  set $su_i=0
+  while ($su_i<$arg0->nA)
+    set $su_n=((SwUndo**)($arg0->pData))[$su_i]
+    printf "%i %p %i\n", $su_i, $su_n, $su_n->nId
+    set $su_i++
+  end
+end
+
+define pnodesarr
+  set $sw_size = $arg0->nSize
+  set $iNodes = 0
+  set $indent = 0
+  while ( $iNodes++<$sw_size && $iNodes<255 )
+    set $sw_node=$arg0[$iNodes-1]
+
+    if ( $sw_node->nNodeType == 1 )
+        set $indent = $indent - 1
+    end
+
+    pIndent $indent
+
+    printf "%d ", $iNodes - 1
+    pNodeType
+#    printf "- SoS: %d", $sw_node->pStartOfSection->nOffset
+
+    if ( $sw_node->nNodeType == 2 || $sw_node->nNodeType == 6 )
+        printf ", EoS: %d", $sw_node->GetStartNode( )->pEndOfSection->nOffset
+        set $indent = $indent + 1
+    end
+    
+    if ( $sw_node->IsTxtNode( ) )
+        printf ", Text: "
+        set $sw_txt = $sw_node->GetTxtNode( )->aText
+        ptu $sw_txt
+    else
+        printf "\n"
+    end
+  end
+end
+
+##########################################
+# #
+# STL GDB evaluators/views/utilities #
+# #
+##########################################
+#
+# The new GDB commands:
+# are entirely non instrumental
+# do not depend on any "inline"(s) - e.g. size(), [], etc
+# are extremely tolerant to debugger settings
+#
+# This file should be "included" in .gdbinit as following:
+# source stl-views.gdb or just paste it into your .gdbinit file
+#
+# The following STL containers are currently supported:
+#
+# std::vector<T> -- via pvector command
+# std::list<T> -- via plist command
+# std::map<T,T> -- via pmap command
+# std::multimap<T,T> -- via pmap command
+# std::set<T> -- via pset command
+# std::multiset<T> -- via pset command
+# std::deque<T> -- via pdequeue command
+# std::stack<T> -- via pstack command
+# std::queue<T> -- via pqueue command
+# std::priority_queue<T> -- via ppqueue command
+# std::bitset<n> -- via pbitset command
+# std::string -- via pstring command
+# std::widestring -- via pwstring command
+#
+# The end of this file contains (optional) C++ beautifiers
+#
+##########################################################################
+# #
+# CopyRight @ 2008 - Dan C Marinescu - All Rights Reserved under GPL V3. #
+# #
+# Email: dan_c_marinescu.TakeThisOut at yahoo.com #
+# #
+##########################################################################
+
+
+
+#
+# std::vector<>
+#
+
+define pvector
+if $argc == 0
+help pvector
+else
+set $size = $arg0._M_impl._M_finish - $arg0._M_impl._M_start
+set $capacity = $arg0._M_impl._M_end_of_storage - $arg0._M_impl._M_start
+set $size_max = $size - 1
+end
+if $argc == 1
+set $i = 0
+while $i < $size
+printf "elem[%u]: ", $i
+p *($arg0._M_impl._M_start + $i)
+set $i++
+end
+end
+if $argc == 2
+set $idx = $arg1
+if $idx < 0 || $idx > $size_max
+printf "idx1, idx2 are not in acceptable range: [0..%u].\n", $size_max
+else
+printf "elem[%u]: ", $idx
+p *($arg0._M_impl._M_start + $idx)
+end
+end
+if $argc == 3
+set $start_idx = $arg1
+set $stop_idx = $arg2
+if $start_idx > $stop_idx
+set $tmp_idx = $start_idx
+set $start_idx = $stop_idx
+set $stop_idx = $tmp_idx
+end
+if $start_idx < 0 || $stop_idx < 0 || $start_idx > $size_max || $stop_idx > $size_max
+printf "idx1, idx2 are not in acceptable range: [0..%u].\n", $size_max
+else
+set $i = $start_idx
+while $i <= $stop_idx
+printf "elem[%u]: ", $i
+p *($arg0._M_impl._M_start + $i)
+set $i++
+end
+end
+end
+if $argc > 0
+printf "Vector size = %u\n", $size
+printf "Vector capacity = %u\n", $capacity
+printf "Element "
+whatis $arg0._M_impl._M_start
+end
+end
+
+document pvector
+Prints std::vector<T> information.
+Syntax: pvector <vector> <idx1> <idx2>
+Note: idx, idx1 and idx2 must be in acceptable range [0..<vector>.size()-1].
+Examples:
+pvector v - Prints vector content, size, capacity and T typedef
+pvector v 0 - Prints element[idx] from vector
+pvector v 1 2 - Prints elements in range [idx1..idx2] from vector
+end
+
+
+
+#
+# std::list<>
+#
+
+define plist
+if $argc == 0
+help plist
+else
+set $head = &$arg0._M_impl._M_node
+set $current = $arg0->_M_impl->_M_node->_M_next
+set $size = 0
+while $current != $head
+if $argc == 2
+printf "elem[%u]: ", $size
+p *($arg1*)($current + 1)
+end
+if $argc == 3
+if $size == $arg2
+printf "elem[%u]: ", $size
+p *($arg1*)($current + 1)
+end
+end
+set $current = $current->_M_next
+set $size++
+end
+printf "List size = %u \n", $size
+if $argc == 1
+printf "List "
+whatis $arg0
+printf "Use plist <variable_name> <element_type> to see the elements in the list.\n"
+end
+end
+end
+
+document plist
+Prints std::list<T> information.
+Syntax: plist <list> <T> <idx>: Prints list size, if T defined all elements or just element at idx
+Examples:
+plist l - prints list size and definition
+plist l int - prints all elements and list size
+plist l int 2 - prints the third element in the list (if exists) and list size
+end
+
+
+
+#
+# std::map and std::multimap
+#
+
+define pmap
+if $argc == 0
+help pmap
+else
+set $tree = $arg0
+set $i = 0
+set $node = $tree->_M_t->_M_impl->_M_header->_M_left
+set $end = $tree->_M_t->_M_impl->_M_header
+set $tree_size = $tree->_M_t->_M_impl->_M_node_count
+if $argc == 1
+printf "Map "
+whatis $tree
+printf "Use pmap <variable_name> <left_element_type> <right_element_type> to see the elements in the map.\n"
+end
+if $argc == 3
+while $i < $tree_size
+set $value = (void *)($node + 1)
+printf "elem[%u]->left: ", $i
+p *($arg1*)$value
+set $value = $value + 4
+printf "elem[%u]->right: ", $i
+p *($arg2*)$value
+if $node->_M_right != 0
+set $node = $node->_M_right
+while $node->_M_left != 0
+set $node = $node->_M_left
+end
+else
+set $tmp_node = $node->_M_parent
+while $node == $tmp_node->_M_right
+set $node = $tmp_node
+set $tmp_node = $tmp_node->_M_parent
+end
+if $node->_M_right != $tmp_node
+set $node = $tmp_node
+end
+end
+set $i++
+end
+end
+if $argc == 4
+set $idx = $arg3
+set $ElementsFound = 0
+while $i < $tree_size
+set $value = (void *)($node + 1)
+if *($arg1*)$value == $idx
+printf "elem[%u]->left: ", $i
+p *($arg1*)$value
+set $value = $value + 4
+printf "elem[%u]->right: ", $i
+p *($arg2*)$value
+set $ElementsFound++
+end
+if $node->_M_right != 0
+set $node = $node->_M_right
+while $node->_M_left != 0
+set $node = $node->_M_left
+end
+else
+set $tmp_node = $node->_M_parent
+while $node == $tmp_node->_M_right
+set $node = $tmp_node
+set $tmp_node = $tmp_node->_M_parent
+end
+if $node->_M_right != $tmp_node
+set $node = $tmp_node
+end
+end
+set $i++
+end
+printf "Number of elements found = %u\n", $ElementsFound
+end
+if $argc == 5
+set $idx1 = $arg3
+set $idx2 = $arg4
+set $ElementsFound = 0
+while $i < $tree_size
+set $value = (void *)($node + 1)
+set $valueLeft = *($arg1*)$value
+set $valueRight = *($arg2*)($value + 4)
+if $valueLeft == $idx1 && $valueRight == $idx2
+printf "elem[%u]->left: ", $i
+p $valueLeft
+printf "elem[%u]->right: ", $i
+p $valueRight
+set $ElementsFound++
+end
+if $node->_M_right != 0
+set $node = $node->_M_right
+while $node->_M_left != 0
+set $node = $node->_M_left
+end
+else
+set $tmp_node = $node->_M_parent
+while $node == $tmp_node->_M_right
+set $node = $tmp_node
+set $tmp_node = $tmp_node->_M_parent
+end
+if $node->_M_right != $tmp_node
+set $node = $tmp_node
+end
+end
+set $i++
+end
+printf "Number of elements found = %u\n", $ElementsFound
+end
+printf "Map size = %u\n", $tree_size
+end
+end
+
+document pmap
+Prints std::map<TLeft and TRight> or std::multimap<TLeft and TRight> information. Works for std::multimap as well.
+Syntax: pmap <map> <TtypeLeft> <TypeRight> <valLeft> <valRight>: Prints map size, if T defined all elements or just element(s) with val(s)
+Examples:
+pmap m - prints map size and definition
+pmap m int int - prints all elements and map size
+pmap m int int 20 - prints the element(s) with left-value = 20 (if any) and map size
+pmap m int int 20 200 - prints the element(s) with left-value = 20 and right-value = 200 (if any) and map size
+end
+
+
+
+#
+# std::set and std::multiset
+#
+
+define pset
+if $argc == 0
+help pset
+else
+set $tree = $arg0
+set $i = 0
+set $node = $tree->_M_t->_M_impl->_M_header->_M_left
+set $end = $tree->_M_t->_M_impl->_M_header
+set $tree_size = $tree->_M_t->_M_impl->_M_node_count
+if $argc == 1
+printf "Set "
+whatis $tree
+printf "Use pset <variable_name> <element_type> to see the elements in the set.\n"
+end
+if $argc == 2
+while $i < $tree_size
+set $value = (void *)($node + 1)
+printf "elem[%u]: ", $i
+p *($arg1*)$value
+if $node->_M_right != 0
+set $node = $node->_M_right
+while $node->_M_left != 0
+set $node = $node->_M_left
+end
+else
+set $tmp_node = $node->_M_parent
+while $node == $tmp_node->_M_right
+set $node = $tmp_node
+set $tmp_node = $tmp_node->_M_parent
+end
+if $node->_M_right != $tmp_node
+set $node = $tmp_node
+end
+end
+set $i++
+end
+end
+if $argc == 3
+set $idx = $arg2
+set $ElementsFound = 0
+while $i < $tree_size
+set $value = (void *)($node + 1)
+if *($arg1*)$value == $idx
+printf "elem[%u]: ", $i
+p *($arg1*)$value
+set $ElementsFound++
+end
+if $node->_M_right != 0
+set $node = $node->_M_right
+while $node->_M_left != 0
+set $node = $node->_M_left
+end
+else
+set $tmp_node = $node->_M_parent
+while $node == $tmp_node->_M_right
+set $node = $tmp_node
+set $tmp_node = $tmp_node->_M_parent
+end
+if $node->_M_right != $tmp_node
+set $node = $tmp_node
+end
+end
+set $i++
+end
+printf "Number of elements found = %u\n", $ElementsFound
+end
+printf "Set size = %u\n", $tree_size
+end
+end
+
+document pset
+Prints std::set<T> or std::multiset<T> information. Works for std::multiset as well.
+Syntax: pset <set> <T> <val>: Prints set size, if T defined all elements or just element(s) having val
+Examples:
+pset s - prints set size and definition
+pset s int - prints all elements and the size of s
+pset s int 20 - prints the element(s) with value = 20 (if any) and the size of s
+end
+
+
+
+#
+# std::dequeue
+#
+
+define pdequeue
+if $argc == 0
+help pdequeue
+else
+set $size = 0
+set $start_cur = $arg0._M_impl._M_start._M_cur
+set $start_last = $arg0._M_impl._M_start._M_last
+set $start_stop = $start_last
+while $start_cur != $start_stop
+p *$start_cur
+set $start_cur++
+set $size++
+end
+set $finish_first = $arg0._M_impl._M_finish._M_first
+set $finish_cur = $arg0._M_impl._M_finish._M_cur
+set $finish_last = $arg0._M_impl._M_finish._M_last
+if $finish_cur < $finish_last
+set $finish_stop = $finish_cur
+else
+set $finish_stop = $finish_last
+end
+while $finish_first != $finish_stop
+p *$finish_first
+set $finish_first++
+set $size++
+end
+printf "Dequeue size = %u\n", $size
+end
+end
+
+document pdequeue
+Prints std::dequeue<T> information.
+Syntax: pdequeue <dequeue>: Prints dequeue size, if T defined all elements
+Deque elements are listed "left to right" (left-most stands for front and right-most stands for back)
+Example:
+pdequeue d - prints all elements and size of d
+end
+
+
+
+#
+# std::stack
+#
+
+define pstack
+if $argc == 0
+help pstack
+else
+set $start_cur = $arg0.c._M_impl._M_start._M_cur
+set $finish_cur = $arg0.c._M_impl._M_finish._M_cur
+set $size = $finish_cur - $start_cur
+set $i = $size - 1
+while $i >= 0
+p *($start_cur + $i)
+set $i--
+end
+printf "Stack size = %u\n", $size
+end
+end
+
+document pstack
+Prints std::stack<T> information.
+Syntax: pstack <stack>: Prints all elements and size of the stack
+Stack elements are listed "top to buttom" (top-most element is the first to come on pop)
+Example:
+pstack s - prints all elements and the size of s
+end
+
+
+
+#
+# std::queue
+#
+
+define pqueue
+if $argc == 0
+help pqueue
+else
+set $start_cur = $arg0.c._M_impl._M_start._M_cur
+set $finish_cur = $arg0.c._M_impl._M_finish._M_cur
+set $size = $finish_cur - $start_cur
+set $i = 0
+while $i < $size
+p *($start_cur + $i)
+set $i++
+end
+printf "Queue size = %u\n", $size
+end
+end
+
+document pqueue
+Prints std::queue<T> information.
+Syntax: pqueue <queue>: Prints all elements and the size of the queue
+Queue elements are listed "top to bottom" (top-most element is the first to come on pop)
+Example:
+pqueue q - prints all elements and the size of q
+end
+
+
+
+#
+# std::priority_queue
+#
+
+define ppqueue
+if $argc == 0
+help ppqueue
+else
+set $size = $arg0.c._M_impl._M_finish - $arg0.c._M_impl._M_start
+set $capacity = $arg0.c._M_impl._M_end_of_storage - $arg0.c._M_impl._M_start
+set $i = $size - 1
+while $i >= 0
+p *($arg0.c._M_impl._M_start + $i)
+set $i--
+end
+printf "Priority queue size = %u\n", $size
+printf "Priority queue capacity = %u\n", $capacity
+end
+end
+
+document ppqueue
+Prints std::priority_queue<T> information.
+Syntax: ppqueue <priority_queue>: Prints all elements, size and capacity of the priority_queue
+Priority_queue elements are listed "top to buttom" (top-most element is the first to come on pop)
+Example:
+ppqueue pq - prints all elements, size and capacity of pq
+end
+
+
+
+#
+# std::bitset
+#
+
+define pbitset
+if $argc == 0
+help pbitset
+else
+p /t $arg0._M_w
+end
+end
+
+document pbitset
+Prints std::bitset<n> information.
+Syntax: pbitset <bitset>: Prints all bits in bitset
+Example:
+pbitset b - prints all bits in b
+end
+
+
+
+#
+# std::string
+#
+
+define pstring
+if $argc == 0
+help pstring
+else
+printf "String \t\t\t= \"%s\"\n", $arg0._M_data()
+printf "String size/length \t= %u\n", $arg0._M_rep()->_M_length
+printf "String capacity \t= %u\n", $arg0._M_rep()->_M_capacity
+printf "String ref-count \t= %d\n", $arg0._M_rep()->_M_refcount
+end
+end
+
+document pstring
+Prints std::string information.
+Syntax: pstring <string>
+Example:
+pstring s - Prints content, size/length, capacity and ref-count of string s
+end
+
+
+
+#
+# std::wstring
+#
+
+define pwstring
+if $argc == 0
+help pwstring
+else
+call printf("WString \t\t= \"%ls\"\n", $arg0._M_data())
+printf "WString size/length \t= %u\n", $arg0._M_rep()->_M_length
+printf "WString capacity \t= %u\n", $arg0._M_rep()->_M_capacity
+printf "WString ref-count \t= %d\n", $arg0._M_rep()->_M_refcount
+end
+end
+
+document pwstring
+Prints std::wstring information.
+Syntax: pwstring <wstring>
+Example:
+pwstring s - Prints content, size/length, capacity and ref-count of wstring s
+end
+
+
+
+#
+# C++ related beautifiers
+#
+
+#set print pretty on
+#set print object on
+#set print static-members on
+#set print vtbl on
+#set print demangle on
+#set demangle-style gnu-v3
+#set print sevenbit-strings off


More information about the ooo-build-commit mailing list