1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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 <svl/poolitem.hxx>
19 #include "userdat.hxx"
23 std::ostream
& operator<<(std::ostream
& rStrm
, const ScAddress
& rAddr
)
25 rStrm
<< "Col: " << rAddr
.Col() << ", Row: " << rAddr
.Row() << ", Tab: " << rAddr
.Tab();
29 void dumpScDrawObjData(ScGridWindow
& rWindow
, 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
* pDoc
= pViewData
->GetDocument();
45 SCTAB nTab
= pViewData
->GetTabNo();
46 for (SCCOL nCol
= 0; nCol
<= 20; ++nCol
)
48 sal_uInt16 nWidth
= pDoc
->GetColWidth(nCol
, nTab
);
49 long nPixel
= LogicToPixel(Point(nWidth
, 0), MapMode(MAP_TWIP
)).getX();
50 std::cout
<< "Column: " << nCol
<< ", Width: " << nPixel
<< "px" << std::endl
;
54 void ScGridWindow::dumpColumnInformationHmm()
56 ScDocument
* pDoc
= pViewData
->GetDocument();
57 SCTAB nTab
= pViewData
->GetTabNo();
58 for (SCCOL nCol
= 0; nCol
<= 20; ++nCol
)
60 sal_uInt16 nWidth
= pDoc
->GetColWidth(nCol
, nTab
);
61 long nPixel
= LogicToLogic(Point(nWidth
, 0), MAP_TWIP
, MAP_100TH_MM
).getX();
62 std::cout
<< "Column: " << nCol
<< ", Width: " << nPixel
<< "hmm" << std::endl
;
66 void ScGridWindow::dumpCellProperties()
68 ScDocument
* pDoc
= pViewData
->GetDocument();
70 SCTAB nTab
= pViewData
->GetTabNo();
71 SCCOL nCol
= pViewData
->GetCurX();
72 SCROW nRow
= pViewData
->GetCurY();
73 const ScPatternAttr
* pPatternAttr
= pDoc
->GetPattern(nCol
,nRow
,nTab
);
75 OString
aOutputFile("dump.xml");
76 xmlTextWriterPtr writer
= xmlNewTextWriterFilename( aOutputFile
.getStr(), 0 );
78 xmlTextWriterStartDocument( writer
, nullptr, nullptr, nullptr );
80 pPatternAttr
->GetItemSet().dumpAsXml(writer
);
82 xmlTextWriterEndDocument( writer
);
83 xmlFreeTextWriter (writer
);
86 void ScGridWindow::dumpGraphicInformation()
88 ScDocument
* pDoc
= pViewData
->GetDocument();
89 ScDrawLayer
* pDrawLayer
= pDoc
->GetDrawLayer();
92 sal_uInt16 nPageCount
= pDrawLayer
->GetPageCount();
93 for (sal_uInt16 nPage
= 0; nPage
< nPageCount
; ++nPage
)
95 SdrPage
* pPage
= pDrawLayer
->GetPage(nPage
);
96 sal_uInt16 nObjCount
= pPage
->GetObjCount();
97 for (sal_uInt16 nObj
= 0; nObj
< nObjCount
; ++nObj
)
99 SdrObject
* pObj
= pPage
->GetObj(nObj
);
100 std::cout
<< "Graphic Object" << std::endl
;
101 ScDrawObjData
* pObjData
= ScDrawLayer::GetObjData(pObj
);
103 dumpScDrawObjData(*this, *pObjData
, pDrawLayer
->GetScaleUnit());
105 const Rectangle
& rRect
= pObj
->GetSnapRect();
106 Rectangle aRect
= LogicToPixel(rRect
, MapMode(pDrawLayer
->GetScaleUnit()));
107 std::cout
<< "Snap Rectangle (in pixel): " << aRect
<< std::endl
;
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */