tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / view / gridwin_dbgutil.cxx
blobb141bddd7619d9cda6f943cb60df8fd9d3dbb56f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <iostream>
12 #include <gridwin.hxx>
13 #include <svx/svdpage.hxx>
14 #include <libxml/xmlwriter.h>
15 #include <viewdata.hxx>
16 #include <document.hxx>
17 #include <patattr.hxx>
18 #include <userdat.hxx>
19 #include <dpobject.hxx>
21 namespace {
23 std::ostream& operator<<(std::ostream& rStrm, const ScAddress& rAddr)
25 rStrm << "Col: " << rAddr.Col() << ", Row: " << rAddr.Row() << ", Tab: " << rAddr.Tab();
26 return rStrm;
29 void dumpScDrawObjData(const ScGridWindow& rWindow, const ScDrawObjData& rData, MapUnit eMapUnit)
31 const Point& rStartOffset = rData.maStartOffset;
32 Point aStartOffsetPixel = rWindow.LogicToPixel(rStartOffset, MapMode(eMapUnit));
33 std::cout << " Start: " << rData.maStart << ", Offset: " << aStartOffsetPixel << std::endl;
35 const Point& rEndOffset = rData.maEndOffset;
36 Point aEndOffsetPixel = rWindow.LogicToPixel(rEndOffset, MapMode(eMapUnit));
37 std::cout << " End: : " << rData.maEnd << ", Offset: " << aEndOffsetPixel << std::endl;
42 void ScGridWindow::dumpColumnInformationPixel()
44 ScDocument& rDoc = mrViewData.GetDocument();
45 SCTAB nTab = mrViewData.GetTabNo();
46 for (SCCOL nCol = 0; nCol <= 20; ++nCol)
48 sal_uInt16 nWidth = rDoc.GetColWidth(nCol, nTab);
49 tools::Long nPixel = LogicToPixel(Point(nWidth, 0), MapMode(MapUnit::MapTwip)).getX();
50 std::cout << "Column: " << nCol << ", Width: " << nPixel << "px" << std::endl;
54 void ScGridWindow::dumpColumnInformationHmm()
56 ScDocument& rDoc = mrViewData.GetDocument();
57 SCTAB nTab = mrViewData.GetTabNo();
58 for (SCCOL nCol = 0; nCol <= 20; ++nCol)
60 sal_uInt16 nWidth = rDoc.GetColWidth(nCol, nTab);
61 tools::Long nPixel = o3tl::convert(nWidth, o3tl::Length::twip, o3tl::Length::mm100);
62 std::cout << "Column: " << nCol << ", Width: " << nPixel << "hmm" << std::endl;
66 void ScGridWindow::dumpCellProperties()
68 ScDocument& rDoc = mrViewData.GetDocument();
69 const ScMarkData& rMark = mrViewData.GetMarkData();
70 SCTAB nTab = mrViewData.GetTabNo();
72 ScRangeList aList;
73 if (rMark.IsMultiMarked())
75 aList = rMark.GetMarkedRangesForTab(nTab);
77 else if (rMark.IsMarked())
79 aList.Join(rMark.GetMarkArea());
81 else
83 SCCOL nCol = mrViewData.GetCurX();
84 SCROW nRow = mrViewData.GetCurY();
86 ScRange aRange(nCol, nRow, nTab);
87 aList.Join(aRange, false);
90 xmlTextWriterPtr writer = xmlNewTextWriterFilename( "dump.xml", 0 );
91 xmlTextWriterSetIndent(writer,1);
92 (void)xmlTextWriterSetIndentString(writer, BAD_CAST(" "));
94 (void)xmlTextWriterStartDocument( writer, nullptr, nullptr, nullptr );
96 (void)xmlTextWriterStartElement(writer, BAD_CAST("selection"));
98 for (size_t i = 0, n = aList.size(); i < n; ++i)
100 ScRange const & rRange = aList[i];
102 for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol)
104 for (SCROW nRow = rRange.aStart.Row(); nRow <= rRange.aEnd.Row(); ++nRow)
106 const ScPatternAttr* pPatternAttr = rDoc.GetPattern(nCol, nRow, nTab);
107 (void)xmlTextWriterStartElement(writer, BAD_CAST("cell"));
108 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("column"), BAD_CAST(OString::number(nCol).getStr()));
109 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("row"), BAD_CAST(OString::number(nRow).getStr()));
110 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("tab"), BAD_CAST(OString::number(nTab).getStr()));
112 pPatternAttr->GetItemSet().dumpAsXml(writer);
114 (void)xmlTextWriterEndElement(writer);
119 (void)xmlTextWriterEndElement(writer);
121 (void)xmlTextWriterEndDocument( writer );
122 xmlFreeTextWriter (writer);
125 void ScGridWindow::dumpGraphicInformation()
127 ScDocument& rDoc = mrViewData.GetDocument();
128 ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
129 if (!pDrawLayer)
130 return;
132 sal_uInt16 nPageCount = pDrawLayer->GetPageCount();
133 for (sal_uInt16 nPage = 0; nPage < nPageCount; ++nPage)
135 SdrPage* pPage = pDrawLayer->GetPage(nPage);
136 size_t nObjCount = pPage->GetObjCount();
137 for (size_t nObj = 0; nObj < nObjCount; ++nObj)
139 SdrObject* pObj = pPage->GetObj(nObj);
140 std::cout << "Graphic Object" << std::endl;
141 ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pObj);
142 if (pObjData)
143 dumpScDrawObjData(*this, *pObjData, pDrawLayer->GetScaleUnit());
145 const tools::Rectangle& rRect = pObj->GetSnapRect();
146 tools::Rectangle aRect = LogicToPixel(rRect, MapMode(pDrawLayer->GetScaleUnit()));
147 std::cout << "Snap Rectangle (in pixel): " << aRect << std::endl;
152 void ScGridWindow::dumpColumnCellStorage()
154 // Get the current cursor position.
155 ScAddress aCurPos = mrViewData.GetCurPos();
157 ScDocument& rDoc = mrViewData.GetDocument();
158 const ScDPObject* pDP = rDoc.GetDPAtCursor(aCurPos.Col(), aCurPos.Row(), aCurPos.Tab());
159 if (pDP)
161 // Dump the pivot table info if the cursor is over a pivot table.
162 pDP->Dump();
163 pDP->DumpCache();
164 return;
167 // Dump the column cell storage info.
168 rDoc.DumpColumnStorage(aCurPos.Tab(), aCurPos.Col());
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */