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
e566d0e0
Kaydet (Commit)
e566d0e0
authored
Tem 19, 2014
tarafından
Markus Mohrhard
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
there is already a shared XPath test class
Change-Id: I3c94d1f8302aba52164fb27f40832415eb435a85
üst
abede5a4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
107 deletions
+29
-107
xpath.cxx
sc/qa/unit/helper/xpath.cxx
+0
-73
xpath.hxx
sc/qa/unit/helper/xpath.hxx
+0
-32
subsequent_export-test.cxx
sc/qa/unit/subsequent_export-test.cxx
+29
-2
No files found.
sc/qa/unit/helper/xpath.cxx
Dosyayı görüntüle @
e566d0e0
...
@@ -40,77 +40,4 @@ xmlDocPtr XPathHelper::parseExport(ScDocShell* pShell, uno::Reference<lang::XMul
...
@@ -40,77 +40,4 @@ xmlDocPtr XPathHelper::parseExport(ScDocShell* pShell, uno::Reference<lang::XMul
return
xmlParseMemory
((
const
char
*
)
aDocument
.
getStr
(),
aDocument
.
getLength
());
return
xmlParseMemory
((
const
char
*
)
aDocument
.
getStr
(),
aDocument
.
getLength
());
}
}
xmlNodeSetPtr
XPathHelper
::
getXPathNode
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
)
{
struct
{
xmlChar
*
pPrefix
;
xmlChar
*
pURI
;
}
aNamespaces
[]
=
{
{
BAD_CAST
(
"w"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/wordprocessingml/2006/main"
)
},
{
BAD_CAST
(
"v"
),
BAD_CAST
(
"urn:schemas-microsoft-com:vml"
)
},
{
BAD_CAST
(
"c"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/drawingml/2006/chart"
)
},
{
BAD_CAST
(
"a"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/drawingml/2006/main"
)
},
{
BAD_CAST
(
"mc"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/markup-compatibility/2006"
)
},
{
BAD_CAST
(
"wps"
),
BAD_CAST
(
"http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
)
},
{
BAD_CAST
(
"wpg"
),
BAD_CAST
(
"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"
)
},
{
BAD_CAST
(
"wp"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
)
},
{
BAD_CAST
(
"office"
),
BAD_CAST
(
"urn:oasis:names:tc:opendocument:xmlns:office:1.0"
)
},
{
BAD_CAST
(
"table"
),
BAD_CAST
(
"urn:oasis:names:tc:opendocument:xmlns:table:1.0"
)
},
{
BAD_CAST
(
"text"
),
BAD_CAST
(
"urn:oasis:names:tc:opendocument:xmlns:text:1.0"
)
},
{
BAD_CAST
(
"xlink"
),
BAD_CAST
(
"http://www.w3c.org/1999/xlink"
)
}
};
xmlXPathContextPtr
pXmlXpathCtx
=
xmlXPathNewContext
(
pXmlDoc
);
for
(
size_t
i
=
0
;
i
<
SAL_N_ELEMENTS
(
aNamespaces
);
++
i
)
{
xmlXPathRegisterNs
(
pXmlXpathCtx
,
aNamespaces
[
i
].
pPrefix
,
aNamespaces
[
i
].
pURI
);
}
xmlXPathObjectPtr
pXmlXpathObj
=
xmlXPathEvalExpression
(
BAD_CAST
(
rXPath
.
getStr
()),
pXmlXpathCtx
);
return
pXmlXpathObj
->
nodesetval
;
}
void
XPathHelper
::
assertXPath
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
,
const
OString
&
rAttribute
,
const
OUString
&
rExpectedValue
)
{
OUString
aValue
=
getXPath
(
pXmlDoc
,
rXPath
,
rAttribute
);
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
OString
(
"Attribute '"
+
rAttribute
+
"' of '"
+
rXPath
+
"' incorrect value."
).
getStr
(),
rExpectedValue
,
aValue
);
}
void
XPathHelper
::
assertXPath
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
,
int
nNumberOfNodes
)
{
xmlNodeSetPtr
pXmlNodes
=
getXPathNode
(
pXmlDoc
,
rXPath
);
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
OString
(
"XPath '"
+
rXPath
+
"' number of nodes is incorrect"
).
getStr
(),
nNumberOfNodes
,
xmlXPathNodeSetGetLength
(
pXmlNodes
));
}
void
XPathHelper
::
assertXPathContent
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
,
const
OUString
&
rContent
)
{
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"XPath contents of child does not match"
,
rContent
,
getXPathContent
(
pXmlDoc
,
rXPath
));
}
OUString
XPathHelper
::
getXPathContent
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
)
{
xmlNodeSetPtr
pXmlNodes
=
getXPathNode
(
pXmlDoc
,
rXPath
);
CPPUNIT_ASSERT_MESSAGE
(
OString
(
"XPath '"
+
rXPath
+
"' not found"
).
getStr
(),
xmlXPathNodeSetGetLength
(
pXmlNodes
)
>
0
);
xmlNodePtr
pXmlNode
=
pXmlNodes
->
nodeTab
[
0
];
_xmlNode
*
pNode
=
&
(
pXmlNode
->
children
[
0
]);
return
pNode
?
OUString
::
createFromAscii
((
const
char
*
)((
pXmlNode
->
children
[
0
]).
content
))
:
OUString
();
}
OUString
XPathHelper
::
getXPath
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
,
const
OString
&
rAttribute
)
{
xmlNodeSetPtr
pXmlNodes
=
getXPathNode
(
pXmlDoc
,
rXPath
);
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
OString
(
"XPath '"
+
rXPath
+
"' number of nodes is incorrect"
).
getStr
(),
1
,
xmlXPathNodeSetGetLength
(
pXmlNodes
));
if
(
rAttribute
.
isEmpty
())
return
OUString
();
xmlNodePtr
pXmlNode
=
pXmlNodes
->
nodeTab
[
0
];
return
OUString
::
createFromAscii
((
const
char
*
)
xmlGetProp
(
pXmlNode
,
BAD_CAST
(
rAttribute
.
getStr
())));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sc/qa/unit/helper/xpath.hxx
Dosyayı görüntüle @
e566d0e0
...
@@ -25,7 +25,6 @@
...
@@ -25,7 +25,6 @@
#endif
#endif
#include "docsh.hxx"
#include "docsh.hxx"
#include "scdllapi.h"
using
namespace
com
::
sun
::
star
;
using
namespace
com
::
sun
::
star
;
...
@@ -39,37 +38,6 @@ namespace XPathHelper
...
@@ -39,37 +38,6 @@ namespace XPathHelper
*/
*/
SCQAHELPER_DLLPUBLIC
xmlDocPtr
parseExport
(
ScDocShell
*
pShell
,
uno
::
Reference
<
lang
::
XMultiServiceFactory
>
xSFactory
,
SCQAHELPER_DLLPUBLIC
xmlDocPtr
parseExport
(
ScDocShell
*
pShell
,
uno
::
Reference
<
lang
::
XMultiServiceFactory
>
xSFactory
,
const
OUString
&
rFile
,
sal_Int32
nFormat
);
const
OUString
&
rFile
,
sal_Int32
nFormat
);
/**
* Helper method to return nodes represented by rXPath.
*/
SCQAHELPER_DLLPUBLIC
xmlNodeSetPtr
getXPathNode
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
);
/**
* Assert that rXPath exists, and returns exactly one node.
* In case rAttribute is provided, the rXPath's attribute's value must
* equal to the rExpected value.
*/
SCQAHELPER_DLLPUBLIC
void
assertXPath
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
,
const
OString
&
rAttribute
=
OString
(),
const
OUString
&
rExpectedValue
=
OUString
());
/**
* Assert that rXPath exists, and returns exactly nNumberOfNodes nodes.
* Useful for checking that we do _not_ export some node (nNumberOfNodes == 0).
*/
SCQAHELPER_DLLPUBLIC
void
assertXPath
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
,
int
nNumberOfNodes
);
/**
* Same as the assertXPath(), but don't assert: return the string instead.
*/
SCQAHELPER_DLLPUBLIC
OUString
getXPath
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
,
const
OString
&
rAttribute
);
/**
Assert that rXPath exists, and its content equals rContent.
*/
SCQAHELPER_DLLPUBLIC
void
assertXPathContent
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
,
const
OUString
&
rContent
);
/**
Same as the assertXPathContent(), but don't assert: return the string instead.
*/
SCQAHELPER_DLLPUBLIC
OUString
getXPathContent
(
xmlDocPtr
pXmlDoc
,
const
OString
&
rXPath
);
}
}
#endif
#endif
...
...
sc/qa/unit/subsequent_export-test.cxx
Dosyayı görüntüle @
e566d0e0
...
@@ -50,13 +50,17 @@
...
@@ -50,13 +50,17 @@
#include <editeng/udlnitem.hxx>
#include <editeng/udlnitem.hxx>
#include <formula/grammar.hxx>
#include <formula/grammar.hxx>
#include <test/xmltesttools.hxx>
#include <com/sun/star/table/BorderLineStyle.hpp>
#include <com/sun/star/table/BorderLineStyle.hpp>
using
namespace
::
com
::
sun
::
star
;
using
namespace
::
com
::
sun
::
star
;
using
namespace
::
com
::
sun
::
star
::
uno
;
using
namespace
::
com
::
sun
::
star
::
uno
;
class
ScExportTest
:
public
ScBootstrapFixture
class
ScExportTest
:
public
ScBootstrapFixture
,
XmlTestTools
{
{
protected
:
virtual
void
registerNamespaces
(
xmlXPathContextPtr
&
pXmlXPathCtx
);
public
:
public
:
ScExportTest
();
ScExportTest
();
...
@@ -161,6 +165,29 @@ private:
...
@@ -161,6 +165,29 @@ private:
};
};
void
ScExportTest
::
registerNamespaces
(
xmlXPathContextPtr
&
pXmlXPathCtx
)
{
struct
{
xmlChar
*
pPrefix
;
xmlChar
*
pURI
;
}
aNamespaces
[]
=
{
{
BAD_CAST
(
"w"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/wordprocessingml/2006/main"
)
},
{
BAD_CAST
(
"v"
),
BAD_CAST
(
"urn:schemas-microsoft-com:vml"
)
},
{
BAD_CAST
(
"c"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/drawingml/2006/chart"
)
},
{
BAD_CAST
(
"a"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/drawingml/2006/main"
)
},
{
BAD_CAST
(
"mc"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/markup-compatibility/2006"
)
},
{
BAD_CAST
(
"wps"
),
BAD_CAST
(
"http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
)
},
{
BAD_CAST
(
"wpg"
),
BAD_CAST
(
"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"
)
},
{
BAD_CAST
(
"wp"
),
BAD_CAST
(
"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
)
},
{
BAD_CAST
(
"office"
),
BAD_CAST
(
"urn:oasis:names:tc:opendocument:xmlns:office:1.0"
)
},
{
BAD_CAST
(
"table"
),
BAD_CAST
(
"urn:oasis:names:tc:opendocument:xmlns:table:1.0"
)
},
{
BAD_CAST
(
"text"
),
BAD_CAST
(
"urn:oasis:names:tc:opendocument:xmlns:text:1.0"
)
},
{
BAD_CAST
(
"xlink"
),
BAD_CAST
(
"http://www.w3c.org/1999/xlink"
)
}
};
for
(
size_t
i
=
0
;
i
<
SAL_N_ELEMENTS
(
aNamespaces
);
++
i
)
{
xmlXPathRegisterNs
(
pXmlXPathCtx
,
aNamespaces
[
i
].
pPrefix
,
aNamespaces
[
i
].
pURI
);
}
}
#if !defined MACOSX && !defined DRAGONFLY
#if !defined MACOSX && !defined DRAGONFLY
ScDocShellRef
ScExportTest
::
saveAndReloadPassword
(
ScDocShell
*
pShell
,
const
OUString
&
rFilter
,
ScDocShellRef
ScExportTest
::
saveAndReloadPassword
(
ScDocShell
*
pShell
,
const
OUString
&
rFilter
,
const
OUString
&
rUserData
,
const
OUString
&
rTypeName
,
sal_uLong
nFormatType
)
const
OUString
&
rUserData
,
const
OUString
&
rTypeName
,
sal_uLong
nFormatType
)
...
@@ -1832,7 +1859,7 @@ void ScExportTest::testRelativePaths()
...
@@ -1832,7 +1859,7 @@ void ScExportTest::testRelativePaths()
xmlDocPtr
pDoc
=
XPathHelper
::
parseExport
(
&
(
*
xDocSh
),
m_xSFactory
,
"content.xml"
,
ODS
);
xmlDocPtr
pDoc
=
XPathHelper
::
parseExport
(
&
(
*
xDocSh
),
m_xSFactory
,
"content.xml"
,
ODS
);
CPPUNIT_ASSERT
(
pDoc
);
CPPUNIT_ASSERT
(
pDoc
);
OUString
aURL
=
XPathHelper
::
getXPath
(
pDoc
,
OUString
aURL
=
getXPath
(
pDoc
,
"/office:document-content/office:body/office:spreadsheet/table:table/table:table-row[2]/table:table-cell[2]/text:p/text:a"
,
"href"
);
"/office:document-content/office:body/office:spreadsheet/table:table/table:table-row[2]/table:table-cell[2]/text:p/text:a"
,
"href"
);
// make sure that the URL is relative
// make sure that the URL is relative
CPPUNIT_ASSERT
(
aURL
.
startsWith
(
".."
));
CPPUNIT_ASSERT
(
aURL
.
startsWith
(
".."
));
...
...
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