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

Manfred Blume manfred.blume at cib.de
Sat Apr 28 12:43:20 UTC 2018


 sw/source/core/layout/dbg_lay.cxx |  140 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 140 insertions(+)

New commits:
commit 750f616d137cda0656f3b2a06a013fd3569a039b
Author: Manfred Blume <manfred.blume at cib.de>
Date:   Fri Oct 27 07:29:08 2017 +0200

    sw: add frame size & content logging to dbg_lay
    
    Change-Id: Ibc4f3dbfb9f6a4ad182185deac71d5fd31d5597f
    Reviewed-on: https://gerrit.libreoffice.org/43926
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/core/layout/dbg_lay.cxx b/sw/source/core/layout/dbg_lay.cxx
old mode 100644
new mode 100755
index c472a90f51ba..6db1895b80e8
--- a/sw/source/core/layout/dbg_lay.cxx
+++ b/sw/source/core/layout/dbg_lay.cxx
@@ -100,6 +100,13 @@
 #include <flyfrm.hxx>
 #include <txtfrm.hxx>
 #include <fntcache.hxx>
+#include <tabfrm.hxx>
+#include <swtblfmt.hxx>
+#include <rowfrm.hxx>
+#include <cellfrm.hxx>
+#include <layfrm.hxx>
+#include <frame.hxx>
+#include <swtable.hxx>
 
 #include <comphelper/string.hxx>
 
@@ -447,6 +454,105 @@ static void lcl_Flags(OStringBuffer& rOut, const SwFrame* pFrame)
     rOut.append(pFrame->isFramePrintAreaValid() ? '+' : '-');
 }
 
+static void lcl_Padded(OStringBuffer& rOut, const OString& s, size_t length)
+{
+    rOut.append(s);
+    for (size_t i = 0; i < length - s.getLength(); i++)
+    {
+        rOut.append(" ");
+    }
+}
+
+static void lcl_Padded(OStringBuffer& rOut, const long n, size_t length = 5)
+{
+    sal_Char sz[RTL_STR_MAX_VALUEOFINT64];
+    rtl_str_valueOfInt64(sz, n, 10);
+    OString s(sz);
+    lcl_Padded(rOut, s, length);
+}
+
+/// output the frame as plain text.
+static void lcl_FrameRect(OStringBuffer& rOut, const char* hint, const SwRect rect)
+{
+    rOut.append("[");
+    rOut.append(hint);
+    rOut.append(":X:");
+    lcl_Padded(rOut, rect.Pos().X());
+    rOut.append(", Y:");
+    lcl_Padded(rOut, rect.Pos().Y());
+    rOut.append(", Width:");
+    lcl_Padded(rOut, rect.SSize().Width());
+    rOut.append(", Height:");
+    lcl_Padded(rOut, rect.SSize().Height());
+    rOut.append("] ");
+}
+
+static OString lcl_TableInfo(const SwTabFrame* pTabFrame)
+{
+    const SwTable* pTable = pTabFrame->GetTable();
+    const SwModify* pModify = pTable->GetRegisteredIn();
+    const SwFormat* pFormat = static_cast<const SwFormat*>(pModify);
+    const OUString& text = pFormat->GetName();
+    return OUStringToOString(text, RTL_TEXTENCODING_ASCII_US);
+}
+
+static OString lcl_RowInfo(const SwRowFrame* pFrame)
+{
+    // dummy, needs actual functionality...
+    if (pFrame == nullptr)
+        return "";
+    const SwTableLine* pTabLine = pFrame->GetTabLine();
+    if (pTabLine == nullptr)
+        return "";
+
+    return "RowInfo";
+}
+
+static OUString lcl_CellText(const SwCellFrame* pFrame)
+{
+    OUString result;
+    int n = 0;
+    sal_Char sz[RTL_STR_MAX_VALUEOFINT64];
+
+    const SwStartNode* pStartNode = pFrame->GetTabBox()->GetSttNd();
+    const SwEndNode* pEndNode = pStartNode->EndOfSectionNode();
+    const SwNodes& nodes = pStartNode->GetNodes();
+
+    for (sal_uLong i = pStartNode->GetIndex(); i < nodes.Count(); i++)
+    {
+        SwNode* pNode = nodes[i];
+
+        if (pNode->IsEndNode())
+        {
+            if (pNode->EndOfSectionNode() == pEndNode)
+                break;
+        }
+        else if (pNode->IsTextNode())
+        {
+            n++;
+            result += "Para:";
+            rtl_str_valueOfInt64(sz, n, 10);
+            OUString s = OUString::createFromAscii(sz);
+            result += s;
+            result += " ";
+            result += pNode->GetTextNode()->GetText();
+        }
+    }
+
+    rtl_str_valueOfInt64(sz, n, 10);
+    OUString s = OUString::createFromAscii(sz);
+    s += " para(s):";
+    s += result;
+
+    return s;
+}
+
+static OString lcl_CellInfo(const SwCellFrame* pFrame)
+{
+    const OUString text = "CellInfo: " + pFrame->GetTabBox()->GetName() + " Text: " + lcl_CellText(pFrame);
+    return OUStringToOString(text, RTL_TEXTENCODING_ASCII_US);
+}
+
 /// output the type of the frame as plain text.
 static void lcl_FrameType( OStringBuffer& rOut, const SwFrame* pFrame )
 {
@@ -656,6 +762,40 @@ void SwImplProtocol::Record_( const SwFrame* pFrame, PROT nFunction, DbgAction n
                             }
         default: break;
     }
+
+    aOut.append("  ");
+    while (aOut.getLength() < 40) aOut.append(" ");
+    lcl_FrameRect(aOut, "SwFrame", pFrame->getFrameArea());
+
+    aOut.append(" ");
+    while (aOut.getLength() < 90) aOut.append(" ");
+    lcl_FrameRect(aOut, "SwPrint", pFrame->getFramePrintArea());
+
+    if (pFrame->IsTextFrame())
+    {
+        aOut.append(" ");
+        while (aOut.getLength() < 140) aOut.append(" ");
+        const OUString& text = static_cast<const SwTextFrame*>(pFrame)->GetTextNode()->GetText();
+        OString o = OUStringToOString(text, RTL_TEXTENCODING_ASCII_US);
+        aOut.append(o);
+    }
+    else if (pFrame->IsTabFrame())
+    {
+        const SwTabFrame* pTabFrame = static_cast<const SwTabFrame*>(pFrame);
+        aOut.append(lcl_TableInfo(pTabFrame));
+    }
+    else if (pFrame->IsRowFrame())
+    {
+        const SwRowFrame* pRowFrame = static_cast<const SwRowFrame*>(pFrame);
+        aOut.append(lcl_RowInfo(pRowFrame));
+
+    }
+    else if (pFrame->IsCellFrame())
+    {
+        const SwCellFrame* pCellFrame = static_cast<const SwCellFrame*>(pFrame);
+        aOut.append(lcl_CellInfo(pCellFrame));
+    }
+
     pStream->WriteCharPtr( aOut.getStr() );
     (*pStream) << endl;  // output
     pStream->Flush();   // to the disk, so we can read it immediately


More information about the Libreoffice-commits mailing list