Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
4bc6484c
Kaydet (Commit)
4bc6484c
authored
Agu 16, 2014
tarafından
Tomaž Vajngerl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
initial implementation of XML dump for Primitive2DSequence
Change-Id: I6618b18164a26553f81a1c737e009b7187b028c3
üst
d3a59629
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
233 additions
and
0 deletions
+233
-0
primitive2dxmldump.hxx
include/test/primitive2dxmldump.hxx
+47
-0
Library_test.mk
test/Library_test.mk
+3
-0
primitive2dxmldump.cxx
test/source/primitive2dxmldump.cxx
+183
-0
No files found.
include/test/primitive2dxmldump.hxx
0 → 100644
Dosyayı görüntüle @
4bc6484c
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_TEST_PRIMITIVE2DXMLDUMP_HXX
#define INCLUDED_TEST_PRIMITIVE2DXMLDUMP_HXX
#include <sal/config.h>
#include <test/testdllapi.hxx>
#include <test/xmlwriter.hxx>
#include <libxml/tree.h>
#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
#include <vector>
class
OOO_DLLPUBLIC_TEST
Primitive2dXmlDump
{
private
:
std
::
vector
<
bool
>
maFilter
;
void
decomposeAndWrite
(
const
drawinglayer
::
primitive2d
::
Primitive2DSequence
&
rPrimitive2DSequence
,
XmlWriter
&
rWriter
);
public
:
Primitive2dXmlDump
();
virtual
~
Primitive2dXmlDump
();
void
filterActionType
(
const
sal_uInt16
nActionType
,
bool
bShouldFilter
);
void
filterAllActionTypes
();
/** The actual result that will be used for testing.
This function normally uses a SvMemoryStream for its operation; but
can use a physical file when a filename is specified in
pTempStreamName - this is useful when creating the test, to dump the
file for examination.
*/
xmlDocPtr
dumpAndParse
(
drawinglayer
::
primitive2d
::
Primitive2DSequence
aPrimitive2DSequence
,
const
OUString
&
rTempStreamName
=
OUString
());
};
#endif // INCLUDED_TEST_PRIMITIVE2DXMLDUMP_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
test/Library_test.mk
Dosyayı görüntüle @
4bc6484c
...
...
@@ -22,6 +22,7 @@ $(eval $(call gb_Library_use_externals,test,\
))
$(eval $(call gb_Library_use_libraries,test,\
basegfx \
comphelper \
cppu \
cppuhelper \
...
...
@@ -32,6 +33,7 @@ $(eval $(call gb_Library_use_libraries,test,\
utl \
unotest \
vcl \
drawinglayer \
$(gb_UWINAPI) \
))
...
...
@@ -42,6 +44,7 @@ $(eval $(call gb_Library_add_exception_objects,test,\
test/source/htmltesttools \
test/source/mtfxmldump \
test/source/xmlwriter \
test/source/primitive2dxmldump \
))
# vim: set noet sw=4 ts=4:
test/source/primitive2dxmldump.cxx
0 → 100644
Dosyayı görüntüle @
4bc6484c
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <test/primitive2dxmldump.hxx>
#include <test/xmltesttools.hxx>
#include <vcl/metaact.hxx>
#include <rtl/string.hxx>
#include <rtl/strbuf.hxx>
#include <boost/scoped_ptr.hpp>
#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
#include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
#include <drawinglayer/attribute/lineattribute.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
using
namespace
drawinglayer
::
primitive2d
;
namespace
{
const
size_t
constMaxActionType
=
513
;
OUString
convertColorToString
(
basegfx
::
BColor
aColor
)
{
OUString
aRGBString
=
Color
(
aColor
).
AsRGBHexString
();
return
"#"
+
aRGBString
;
}
}
// anonymous namespace
Primitive2dXmlDump
::
Primitive2dXmlDump
()
:
maFilter
(
constMaxActionType
,
false
)
{}
Primitive2dXmlDump
::~
Primitive2dXmlDump
()
{}
void
Primitive2dXmlDump
::
filterActionType
(
const
sal_uInt16
nActionType
,
bool
bShouldFilter
)
{
maFilter
[
nActionType
]
=
bShouldFilter
;
}
void
Primitive2dXmlDump
::
filterAllActionTypes
()
{
maFilter
.
assign
(
constMaxActionType
,
true
);
}
xmlDocPtr
Primitive2dXmlDump
::
dumpAndParse
(
Primitive2DSequence
aPrimitive2DSequence
,
const
OUString
&
rTempStreamName
)
{
boost
::
scoped_ptr
<
SvStream
>
pStream
;
if
(
rTempStreamName
.
isEmpty
())
pStream
.
reset
(
new
SvMemoryStream
());
else
pStream
.
reset
(
new
SvFileStream
(
rTempStreamName
,
STREAM_STD_READWRITE
|
STREAM_TRUNC
));
XmlWriter
aWriter
(
pStream
.
get
());
aWriter
.
startDocument
();
aWriter
.
startElement
(
"primitive2D"
);
decomposeAndWrite
(
aPrimitive2DSequence
,
aWriter
);
aWriter
.
endElement
();
aWriter
.
endDocument
();
pStream
->
Seek
(
STREAM_SEEK_TO_BEGIN
);
xmlDocPtr
pDoc
=
XmlTestTools
::
parseXmlStream
(
pStream
.
get
());
return
pDoc
;
}
void
Primitive2dXmlDump
::
decomposeAndWrite
(
const
Primitive2DSequence
&
rPrimitive2DSequence
,
XmlWriter
&
rWriter
)
{
for
(
int
i
=
0
;
i
<
rPrimitive2DSequence
.
getLength
();
i
++
)
{
Primitive2DReference
xPrimitive2DReference
=
rPrimitive2DSequence
[
i
];
const
BasePrimitive2D
*
pBasePrimitive
=
dynamic_cast
<
const
BasePrimitive2D
*
>
(
xPrimitive2DReference
.
get
());
sal_uInt32
nId
=
pBasePrimitive
->
getPrimitive2DID
();
if
(
maFilter
[
nId
])
continue
;
OUString
sCurrentElementTag
=
drawinglayer
::
primitive2d
::
idToString
(
nId
);
switch
(
nId
)
{
case
PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D
:
{
const
HiddenGeometryPrimitive2D
*
pHiddenGeometryPrimitive2D
=
dynamic_cast
<
const
HiddenGeometryPrimitive2D
*>
(
pBasePrimitive
);
rWriter
.
startElement
(
"hiddengeometry"
);
decomposeAndWrite
(
pHiddenGeometryPrimitive2D
->
getChildren
(),
rWriter
);
rWriter
.
endElement
();
}
break
;
case
PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D
:
{
const
TransformPrimitive2D
*
pTransformPrimitive2D
=
dynamic_cast
<
const
TransformPrimitive2D
*>
(
pBasePrimitive
);
rWriter
.
startElement
(
"transform"
);
//pTransformPrimitive2D->getTransformation()
decomposeAndWrite
(
pTransformPrimitive2D
->
getChildren
(),
rWriter
);
rWriter
.
endElement
();
}
break
;
case
PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D
:
{
const
PolyPolygonColorPrimitive2D
*
pPolyPolygonColorPrimitive2D
=
dynamic_cast
<
const
PolyPolygonColorPrimitive2D
*>
(
pBasePrimitive
);
rWriter
.
startElement
(
"polypolygoncolor"
);
rWriter
.
attribute
(
"color"
,
convertColorToString
(
pPolyPolygonColorPrimitive2D
->
getBColor
()));
rWriter
.
startElement
(
"polypolygon"
);
rWriter
.
content
(
basegfx
::
tools
::
exportToSvgD
(
pPolyPolygonColorPrimitive2D
->
getB2DPolyPolygon
(),
true
,
true
,
false
));
rWriter
.
endElement
();
rWriter
.
endElement
();
}
break
;
case
PRIMITIVE2D_ID_POLYPOLYGONSTROKEPRIMITIVE2D
:
{
const
PolyPolygonStrokePrimitive2D
*
pPolyPolygonStrokePrimitive2D
=
dynamic_cast
<
const
PolyPolygonStrokePrimitive2D
*>
(
pBasePrimitive
);
rWriter
.
startElement
(
"polypolygonstroke"
);
rWriter
.
startElement
(
"line"
);
drawinglayer
::
attribute
::
LineAttribute
aLineAttribute
=
pPolyPolygonStrokePrimitive2D
->
getLineAttribute
();
rWriter
.
attribute
(
"color"
,
convertColorToString
(
aLineAttribute
.
getColor
()));
rWriter
.
attribute
(
"width"
,
aLineAttribute
.
getWidth
());
//rWriter.attribute("linejoin", aLineAttribute.getLineJoin());
//rWriter.attribute("linecap", aLineAttribute.getLineCap());
rWriter
.
endElement
();
//getStrokeAttribute()
rWriter
.
startElement
(
"polypolygon"
);
rWriter
.
content
(
basegfx
::
tools
::
exportToSvgD
(
pPolyPolygonStrokePrimitive2D
->
getB2DPolyPolygon
(),
true
,
true
,
false
));
rWriter
.
endElement
();
rWriter
.
endElement
();
}
break
;
case
PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D
:
{
const
PolygonHairlinePrimitive2D
*
pPolygonHairlinePrimitive2D
=
dynamic_cast
<
const
PolygonHairlinePrimitive2D
*>
(
pBasePrimitive
);
rWriter
.
startElement
(
"polygonhairline"
);
rWriter
.
attribute
(
"color"
,
convertColorToString
(
pPolygonHairlinePrimitive2D
->
getBColor
()));
rWriter
.
startElement
(
"polygon"
);
rWriter
.
content
(
basegfx
::
tools
::
exportToSvgPoints
(
pPolygonHairlinePrimitive2D
->
getB2DPolygon
()));
rWriter
.
endElement
();
rWriter
.
endElement
();
}
break
;
default
:
{
rWriter
.
element
(
OUStringToOString
(
sCurrentElementTag
,
RTL_TEXTENCODING_UTF8
));
}
break
;
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment