LibreOffice Module sc (master) 1
gridwin_dbgutil.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 */
9
10#include <iostream>
11
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>
20
21namespace {
22
23std::ostream& operator<<(std::ostream& rStrm, const ScAddress& rAddr)
24{
25 rStrm << "Col: " << rAddr.Col() << ", Row: " << rAddr.Row() << ", Tab: " << rAddr.Tab();
26 return rStrm;
27}
28
29void dumpScDrawObjData(const ScGridWindow& rWindow, const ScDrawObjData& rData, MapUnit eMapUnit)
30{
31 const Point& rStartOffset = rData.maStartOffset;
32 Point aStartOffsetPixel = rWindow.LogicToPixel(rStartOffset, MapMode(eMapUnit));
33 std::cout << " Start: " << rData.maStart << ", Offset: " << aStartOffsetPixel << std::endl;
34
35 const Point& rEndOffset = rData.maEndOffset;
36 Point aEndOffsetPixel = rWindow.LogicToPixel(rEndOffset, MapMode(eMapUnit));
37 std::cout << " End: : " << rData.maEnd << ", Offset: " << aEndOffsetPixel << std::endl;
38}
39
40}
41
43{
45 SCTAB nTab = mrViewData.GetTabNo();
46 for (SCCOL nCol = 0; nCol <= 20; ++nCol)
47 {
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;
51 }
52}
53
55{
57 SCTAB nTab = mrViewData.GetTabNo();
58 for (SCCOL nCol = 0; nCol <= 20; ++nCol)
59 {
60 sal_uInt16 nWidth = rDoc.GetColWidth(nCol, nTab);
62 std::cout << "Column: " << nCol << ", Width: " << nPixel << "hmm" << std::endl;
63 }
64}
65
67{
69 const ScMarkData& rMark = mrViewData.GetMarkData();
70 SCTAB nTab = mrViewData.GetTabNo();
71
72 ScRangeList aList;
73 if (rMark.IsMultiMarked())
74 {
75 aList = rMark.GetMarkedRangesForTab(nTab);
76 }
77 else if (rMark.IsMarked())
78 {
79 aList.Join(rMark.GetMarkArea());
80 }
81 else
82 {
83 SCCOL nCol = mrViewData.GetCurX();
84 SCROW nRow = mrViewData.GetCurY();
85
86 ScRange aRange(nCol, nRow, nTab);
87 aList.Join(aRange, false);
88 }
89
90 xmlTextWriterPtr writer = xmlNewTextWriterFilename( "dump.xml", 0 );
91 xmlTextWriterSetIndent(writer,1);
92 (void)xmlTextWriterSetIndentString(writer, BAD_CAST(" "));
93
94 (void)xmlTextWriterStartDocument( writer, nullptr, nullptr, nullptr );
95
96 (void)xmlTextWriterStartElement(writer, BAD_CAST("selection"));
97
98 for (size_t i = 0, n = aList.size(); i < n; ++i)
99 {
100 ScRange const & rRange = aList[i];
101
102 for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol)
103 {
104 for (SCROW nRow = rRange.aStart.Row(); nRow <= rRange.aEnd.Row(); ++nRow)
105 {
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()));
111
112 pPatternAttr->GetItemSet().dumpAsXml(writer);
113
114 (void)xmlTextWriterEndElement(writer);
115 }
116 }
117 }
118
119 (void)xmlTextWriterEndElement(writer);
120
121 (void)xmlTextWriterEndDocument( writer );
122 xmlFreeTextWriter (writer);
123}
124
126{
128 ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
129 if (!pDrawLayer)
130 return;
131
132 sal_uInt16 nPageCount = pDrawLayer->GetPageCount();
133 for (sal_uInt16 nPage = 0; nPage < nPageCount; ++nPage)
134 {
135 SdrPage* pPage = pDrawLayer->GetPage(nPage);
136 size_t nObjCount = pPage->GetObjCount();
137 for (size_t nObj = 0; nObj < nObjCount; ++nObj)
138 {
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());
144
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;
148 }
149 }
150}
151
153{
154 // Get the current cursor position.
155 ScAddress aCurPos = mrViewData.GetCurPos();
156
158 const ScDPObject* pDP = rDoc.GetDPAtCursor(aCurPos.Col(), aCurPos.Row(), aCurPos.Tab());
159 if (pDP)
160 {
161 // Dump the pivot table info if the cursor is over a pivot table.
162 pDP->Dump();
163 pDP->DumpCache();
164 return;
165 }
166
167 // Dump the column cell storage info.
168 rDoc.DumpColumnStorage(aCurPos.Tab(), aCurPos.Col());
169}
170
171/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr tools::Long getX() const
SCTAB Tab() const
Definition: address.hxx:283
SCROW Row() const
Definition: address.hxx:274
SCCOL Col() const
Definition: address.hxx:279
void DumpCache() const
void Dump() const
SC_DLLPUBLIC void DumpColumnStorage(SCTAB nTab, SCCOL nCol) const
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4122
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1084
SC_DLLPUBLIC ScDPObject * GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: documen3.cxx:377
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4719
static ScDrawObjData * GetObjData(SdrObject *pObj, bool bCreate=false)
Definition: drwlayer.cxx:2874
ScAddress maStart
Definition: userdat.hxx:36
Point maStartOffset
Definition: userdat.hxx:38
Point maEndOffset
Definition: userdat.hxx:39
ScAddress maEnd
Definition: userdat.hxx:37
void dumpColumnInformationPixel()
void dumpGraphicInformation()
void dumpCellProperties()
ScViewData & mrViewData
Definition: gridwin.hxx:153
void dumpColumnInformationHmm()
void dumpColumnCellStorage()
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
ScRangeList GetMarkedRangesForTab(SCTAB nTab) const
Get marked ranges with sheet-tab set to nTab.
Definition: markdata.cxx:457
const ScRange & GetMarkArea() const
Definition: markdata.hxx:83
bool IsMultiMarked() const
Definition: markdata.hxx:81
bool IsMarked() const
Definition: markdata.hxx:80
SfxItemSet & GetItemSet()
Definition: patattr.hxx:192
void Join(const ScRange &, bool bIsInList=false)
Definition: rangelst.cxx:152
size_t size() const
Definition: rangelst.hxx:89
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3146
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
ScAddress GetCurPos() const
Definition: viewdata.cxx:4119
SCROW GetCurY() const
Definition: viewdata.hxx:402
SCCOL GetCurX() const
Definition: viewdata.hxx:401
MapUnit GetScaleUnit() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
sal_uInt16 GetPageCount() const
SdrObject * GetObj(size_t nNum) const
size_t GetObjCount() const
virtual const tools::Rectangle & GetSnapRect() const
void dumpAsXml(xmlTextWriterPtr pWriter) const
Point LogicToPixel(const Point &rLogicPt) const
struct _xmlTextWriter * xmlTextWriterPtr
sal_Int64 n
MapUnit
int i
void SvStream & rStrm
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, const ParamIfsResult &rRes)
Definition: interpre.hxx:71
long Long
#define nPixel
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17