[Libreoffice-commits] core.git: sw/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Nov 19 10:19:05 PST 2014


 sw/source/core/access/accportions.cxx   |    2 +-
 sw/source/core/access/accportions.hxx   |    2 +-
 sw/source/core/inc/SwPortionHandler.hxx |    7 +++++--
 sw/source/core/inc/swfont.hxx           |    3 +++
 sw/source/core/text/porfld.cxx          |    6 +++++-
 sw/source/core/text/xmldump.cxx         |   14 +++++++++++++-
 6 files changed, 28 insertions(+), 6 deletions(-)

New commits:
commit 37f613c6eae5ee7e221cecf92ce321622d3cf4a8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Nov 19 19:02:07 2014 +0100

    sw: include the font of SwNumberPortions in layout dump
    
    Change-Id: I3d015c7a97ace6db548c4ad11ae24b0a7daa35c5

diff --git a/sw/source/core/access/accportions.cxx b/sw/source/core/access/accportions.cxx
index b5ccaae..c997d9e 100644
--- a/sw/source/core/access/accportions.cxx
+++ b/sw/source/core/access/accportions.cxx
@@ -135,7 +135,7 @@ void SwAccessiblePortionData::SetAttrFieldType( sal_uInt16 nAttrFldType )
 }
 
 void SwAccessiblePortionData::Special(
-    sal_Int32 nLength, const OUString& rText, sal_uInt16 nType, sal_Int32 /*nHeight*/, sal_Int32 /*nWidth*/)
+    sal_Int32 nLength, const OUString& rText, sal_uInt16 nType, sal_Int32 /*nHeight*/, sal_Int32 /*nWidth*/, const SwFont* /*pFont*/)
 {
     OSL_ENSURE( nModelPosition >= 0, "illegal position" );
     OSL_ENSURE( (nModelPosition + nLength) <= pTxtNode->GetTxt().getLength(),
diff --git a/sw/source/core/access/accportions.hxx b/sw/source/core/access/accportions.hxx
index 491afee..e99cf8f 100644
--- a/sw/source/core/access/accportions.hxx
+++ b/sw/source/core/access/accportions.hxx
@@ -98,7 +98,7 @@ public:
 
     // SwPortionHandler methods
     virtual void Text(sal_Int32 nLength, sal_uInt16 nType, sal_Int32 nHeight = 0, sal_Int32 nWidth = 0) SAL_OVERRIDE;
-    virtual void Special(sal_Int32 nLength, const OUString& rText, sal_uInt16 nType, sal_Int32 nHeight = 0, sal_Int32 nWidth = 0) SAL_OVERRIDE;
+    virtual void Special(sal_Int32 nLength, const OUString& rText, sal_uInt16 nType, sal_Int32 nHeight = 0, sal_Int32 nWidth = 0, const SwFont* pFont = 0) SAL_OVERRIDE;
     virtual void LineBreak(sal_Int32 nWidth) SAL_OVERRIDE;
     virtual void Skip(sal_Int32 nLength) SAL_OVERRIDE;
     virtual void Finish() SAL_OVERRIDE;
diff --git a/sw/source/core/inc/SwPortionHandler.hxx b/sw/source/core/inc/SwPortionHandler.hxx
index 8d04b19..3b76564 100644
--- a/sw/source/core/inc/SwPortionHandler.hxx
+++ b/sw/source/core/inc/SwPortionHandler.hxx
@@ -22,6 +22,8 @@
 
 #include <swtypes.hxx>
 
+class SwFont;
+
 /** The SwPortionHandler interface implements a visitor for the layout
  * engine's text portions. This can be used to gather information of
  * the on-screen representation of a single paragraph.
@@ -35,7 +37,7 @@
  * held by the corresponding SwTxtNode.
  *
  * The SwPortionHandler can be used with the
- * SwTextFrame::VisitPortions(...) method.
+ * SwTxtFrm::VisitPortions(...) method.
  */
 class SwPortionHandler
 {
@@ -68,7 +70,8 @@ public:
         const OUString& rText, /// text which is painted on-screen
         sal_uInt16 nType,         /// type of this portion
         sal_Int32 nHeight = 0,     /// font height of the painted text
-        sal_Int32 nWidth = 0     /// width of this portion
+        sal_Int32 nWidth = 0,     /// width of this portion
+        const SwFont* pFont = 0 /// font of this portion
         ) = 0;
 
     /** line break. This method is called whenever a line break in the
diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx
index fa1d718..b01ba5e 100644
--- a/sw/source/core/inc/swfont.hxx
+++ b/sw/source/core/inc/swfont.hxx
@@ -36,6 +36,7 @@ class SwDrawTextInfo;   // _DrawText
 class SwScriptInfo;     // _GetTxtSize
 class SwViewShell;
 class IDocumentSettingAccess;
+typedef struct _xmlTextWriter *xmlTextWriterPtr;
 
 const sal_Unicode CH_BLANK = ' ';   // ' ' blank spaces
 const sal_Unicode CH_BREAK = 0x0A;
@@ -449,6 +450,8 @@ public:
     sal_uInt16 CalcShadowSpace(
         const sal_uInt16 nShadow, const bool bVertLayout,
         const bool bSkipLeft, const bool bSkipRight ) const;
+
+    void dumpAsXml( xmlTextWriterPtr writer = NULL ) const;
 };
 
 inline void SwFont::SetColor( const Color& rColor )
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index 5ee2d1f..997d975 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -445,9 +445,13 @@ bool SwFldPortion::GetExpTxt( const SwTxtSizeInfo &rInf, OUString &rTxt ) const
 void SwFldPortion::HandlePortion( SwPortionHandler& rPH ) const
 {
     sal_Int32 nH = 0;
+    sal_Int32 nW = 0;
     if (pFnt)
+    {
         nH = pFnt->GetSize(pFnt->GetActual()).Height();
-    rPH.Special( GetLen(), aExpand, GetWhichPor(), nH );
+        nW = pFnt->GetSize(pFnt->GetActual()).Width();
+    }
+    rPH.Special( GetLen(), aExpand, GetWhichPor(), nH, nW, pFnt );
     if( GetWhichPor() == POR_FLD )
     {
         rPH.SetAttrFieldType(m_nAttrFldType);
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index 4365487..17ba86b 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -150,7 +150,8 @@ class XmlPortionDumper:public SwPortionHandler
                           const OUString & rText,
                           sal_uInt16 nType,
                           sal_Int32 nHeight,
-                          sal_Int32 nWidth ) SAL_OVERRIDE
+                          sal_Int32 nWidth,
+                          const SwFont* pFont ) SAL_OVERRIDE
     {
         xmlTextWriterStartElement( writer, BAD_CAST( "Special" ) );
         xmlTextWriterWriteFormatAttribute( writer,
@@ -171,6 +172,9 @@ class XmlPortionDumper:public SwPortionHandler
         if (nWidth > 0)
             xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("nWidth"), "%i", (int)nWidth);
 
+        if (pFont)
+            pFont->dumpAsXml(writer);
+
         xmlTextWriterEndElement( writer );
         ofs += nLength;
     }
@@ -432,6 +436,14 @@ void SwAnchoredObject::dumpAsXml( xmlTextWriterPtr writer ) const
         lcl_freeWriter( writer );
 }
 
+void SwFont::dumpAsXml(xmlTextWriterPtr writer) const
+{
+    xmlTextWriterStartElement(writer, BAD_CAST("pFont"));
+    xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("ptr"), "%p", this);
+    xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("color"), "%s", const_cast<Color&>(GetColor()).AsRGBHexString().toUtf8().getStr());
+    xmlTextWriterEndElement(writer);
+}
+
 void SwTxtFrm::dumpAsXmlAttributes( xmlTextWriterPtr writer ) const
 {
     SwFrm::dumpAsXmlAttributes( writer );


More information about the Libreoffice-commits mailing list