Kaydet (Commit) 9f9fa48a authored tarafından Miklos Vajna's avatar Miklos Vajna

writerfilter: avoid ugly cross-directory include

Change-Id: I16db4e16e5c2fa3aa3bfb22f83d2c36695499b5c
üst 5d593158
......@@ -21,7 +21,6 @@ $(eval $(call gb_Library_set_include,writerfilter,\
$$(INCLUDE) \
-I$(SRCDIR)/writerfilter/inc \
-I$(SRCDIR)/writerfilter/source \
-I$(SRCDIR)/writerfilter/source/dmapper \
))
$(eval $(call gb_Library_use_sdk_api,writerfilter))
......
......@@ -9,6 +9,8 @@
#ifndef INCLUDED_WRITERFILTER_INC_DMAPPER_DOMAINMAPPERFACTORY_HXX
#define INCLUDED_WRITERFILTER_INC_DMAPPER_DOMAINMAPPERFACTORY_HXX
#include <vector>
#include <dmapper/resourcemodel.hxx>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/lang/XComponent.hpp>
......@@ -42,6 +44,10 @@ public:
SourceDocumentType eDocumentType,
utl::MediaDescriptor& rMediaDesc);
};
// export just for test
SAL_DLLPUBLIC_EXPORT std::tuple<OUString, std::vector<OUString>, std::vector<OUString> > splitFieldCommand(const OUString& rCommand);
} // namespace dmapper
} // namespace writerfilter
......
......@@ -59,80 +59,80 @@ void WriterfilterMiscTest::testTwipConversions()
void WriterfilterMiscTest::testFieldParameters()
{
using writerfilter::dmapper::lcl_SplitFieldCommand;
using writerfilter::dmapper::splitFieldCommand;
std::tuple<OUString, std::vector<OUString>, std::vector<OUString> > result;
result = lcl_SplitFieldCommand("PAGEREF last_page");
result = splitFieldCommand("PAGEREF last_page");
CPPUNIT_ASSERT_EQUAL(OUString("PAGEREF"), std::get<0>(result));
CPPUNIT_ASSERT_EQUAL(size_t(1), std::get<1>(result).size());
CPPUNIT_ASSERT_EQUAL(OUString("last_page"), std::get<1>(result)[0]);
CPPUNIT_ASSERT(std::get<2>(result).empty());
result = lcl_SplitFieldCommand(" PAGEREF last_page ");
result = splitFieldCommand(" PAGEREF last_page ");
CPPUNIT_ASSERT_EQUAL(OUString("PAGEREF"), std::get<0>(result));
CPPUNIT_ASSERT_EQUAL(size_t(1), std::get<1>(result).size());
CPPUNIT_ASSERT_EQUAL(OUString("last_page"), std::get<1>(result)[0]);
result = lcl_SplitFieldCommand("pageref last_page");
result = splitFieldCommand("pageref last_page");
CPPUNIT_ASSERT(std::get<2>(result).empty());
CPPUNIT_ASSERT_EQUAL(OUString("PAGEREF"), std::get<0>(result));
CPPUNIT_ASSERT_EQUAL(size_t(1), std::get<1>(result).size());
CPPUNIT_ASSERT_EQUAL(OUString("last_page"), std::get<1>(result)[0]);
CPPUNIT_ASSERT(std::get<2>(result).empty());
result = lcl_SplitFieldCommand("pageref \"last_page\"");
result = splitFieldCommand("pageref \"last_page\"");
CPPUNIT_ASSERT_EQUAL(OUString("PAGEREF"), std::get<0>(result));
CPPUNIT_ASSERT_EQUAL(size_t(1), std::get<1>(result).size());
CPPUNIT_ASSERT_EQUAL(OUString("last_page"), std::get<1>(result)[0]);
CPPUNIT_ASSERT(std::get<2>(result).empty());
result = lcl_SplitFieldCommand("\"PAGEREF\" \"last_page\" \"\" ");
result = splitFieldCommand("\"PAGEREF\" \"last_page\" \"\" ");
CPPUNIT_ASSERT_EQUAL(OUString("PAGEREF"), std::get<0>(result));
CPPUNIT_ASSERT_EQUAL(size_t(2), std::get<1>(result).size());
CPPUNIT_ASSERT_EQUAL(OUString("last_page"), std::get<1>(result)[0]);
CPPUNIT_ASSERT_EQUAL(OUString(), std::get<1>(result)[1]);
CPPUNIT_ASSERT(std::get<2>(result).empty());
result = lcl_SplitFieldCommand("\"PAGEREF\"\"last_page\" ");
result = splitFieldCommand("\"PAGEREF\"\"last_page\" ");
CPPUNIT_ASSERT_EQUAL(OUString("PAGEREF"), std::get<0>(result));
CPPUNIT_ASSERT_EQUAL(size_t(1), std::get<1>(result).size());
CPPUNIT_ASSERT_EQUAL(OUString("last_page"), std::get<1>(result)[0]);
CPPUNIT_ASSERT(std::get<2>(result).empty());
result = lcl_SplitFieldCommand("PAGEREF\"last_page\" ");
result = splitFieldCommand("PAGEREF\"last_page\" ");
CPPUNIT_ASSERT_EQUAL(OUString("PAGEREF"), std::get<0>(result));
CPPUNIT_ASSERT_EQUAL(size_t(1), std::get<1>(result).size());
CPPUNIT_ASSERT_EQUAL(OUString("last_page"), std::get<1>(result)[0]);
CPPUNIT_ASSERT(std::get<2>(result).empty());
result = lcl_SplitFieldCommand("\"PAGEREF\"last_page \"\"");
result = splitFieldCommand("\"PAGEREF\"last_page \"\"");
CPPUNIT_ASSERT_EQUAL(OUString("PAGEREF"), std::get<0>(result));
CPPUNIT_ASSERT_EQUAL(size_t(2), std::get<1>(result).size());
CPPUNIT_ASSERT_EQUAL(OUString("last_page"), std::get<1>(result)[0]);
CPPUNIT_ASSERT_EQUAL(OUString(), std::get<1>(result)[1]);
CPPUNIT_ASSERT(std::get<2>(result).empty());
result = lcl_SplitFieldCommand("\"PAGEREF\"last_page \"\"");
result = splitFieldCommand("\"PAGEREF\"last_page \"\"");
CPPUNIT_ASSERT_EQUAL(OUString("PAGEREF"), std::get<0>(result));
CPPUNIT_ASSERT_EQUAL(size_t(2), std::get<1>(result).size());
CPPUNIT_ASSERT_EQUAL(OUString("last_page"), std::get<1>(result)[0]);
CPPUNIT_ASSERT_EQUAL(OUString(), std::get<1>(result)[1]);
CPPUNIT_ASSERT(std::get<2>(result).empty());
result = lcl_SplitFieldCommand("pageref \"last\\\\pa\\\"ge\"");
result = splitFieldCommand("pageref \"last\\\\pa\\\"ge\"");
CPPUNIT_ASSERT_EQUAL(OUString("PAGEREF"), std::get<0>(result));
CPPUNIT_ASSERT_EQUAL(size_t(1), std::get<1>(result).size());
CPPUNIT_ASSERT_EQUAL(OUString("last\\pa\"ge"), std::get<1>(result)[0]);
CPPUNIT_ASSERT(std::get<2>(result).empty());
result = lcl_SplitFieldCommand("PAGEREF\"last_page\"\\*");
result = splitFieldCommand("PAGEREF\"last_page\"\\*");
CPPUNIT_ASSERT_EQUAL(OUString("PAGEREF"), std::get<0>(result));
CPPUNIT_ASSERT_EQUAL(size_t(1), std::get<1>(result).size());
CPPUNIT_ASSERT_EQUAL(OUString("last_page"), std::get<1>(result)[0]);
CPPUNIT_ASSERT_EQUAL(size_t(1), std::get<2>(result).size());
CPPUNIT_ASSERT_EQUAL(OUString("\\*"), std::get<2>(result)[0]);
result = lcl_SplitFieldCommand("PAGEREF last_page \\b foobar ");
result = splitFieldCommand("PAGEREF last_page \\b foobar ");
CPPUNIT_ASSERT_EQUAL(OUString("PAGEREF"), std::get<0>(result));
CPPUNIT_ASSERT_EQUAL(size_t(1), std::get<1>(result).size());
CPPUNIT_ASSERT_EQUAL(OUString("last_page"), std::get<1>(result)[0]);
......@@ -140,7 +140,7 @@ void WriterfilterMiscTest::testFieldParameters()
CPPUNIT_ASSERT_EQUAL(OUString("\\B"), std::get<2>(result)[0]);
CPPUNIT_ASSERT_EQUAL(OUString("foobar"), std::get<2>(result)[1]);
result = lcl_SplitFieldCommand("PAGEREF\\bfoobar\\A\"\"");
result = splitFieldCommand("PAGEREF\\bfoobar\\A\"\"");
CPPUNIT_ASSERT_EQUAL(OUString("PAGEREF"), std::get<0>(result));
CPPUNIT_ASSERT(std::get<1>(result).empty());
CPPUNIT_ASSERT_EQUAL(size_t(4), std::get<2>(result).size());
......@@ -154,19 +154,19 @@ void WriterfilterMiscTest::testFieldParameters()
"]", "^", "_", "`", "{", "|", "}", "~"})
{
OUString test(OUString::createFromAscii(prefix) + "PAGE");
result = lcl_SplitFieldCommand(test + " ");
result = splitFieldCommand(test + " ");
CPPUNIT_ASSERT_EQUAL(test, std::get<0>(result));
}
result = lcl_SplitFieldCommand("\\PAGE ");
result = splitFieldCommand("\\PAGE ");
CPPUNIT_ASSERT_EQUAL(OUString("PAGE"), std::get<0>(result));
result = lcl_SplitFieldCommand("\\ PAGE ");
result = splitFieldCommand("\\ PAGE ");
CPPUNIT_ASSERT_EQUAL(OUString("\\ "), std::get<0>(result));
CPPUNIT_ASSERT_EQUAL(OUString("PAGE"), std::get<1>(result)[0]);
result = lcl_SplitFieldCommand("\\\\PAGE ");
result = splitFieldCommand("\\\\PAGE ");
CPPUNIT_ASSERT_EQUAL(OUString("\\PAGE"), std::get<0>(result));
result = lcl_SplitFieldCommand("\"PAGE\" ");
result = splitFieldCommand("\"PAGE\" ");
CPPUNIT_ASSERT_EQUAL(OUString("PAGE"), std::get<0>(result));
result = lcl_SplitFieldCommand("\"PAGE ");
result = splitFieldCommand("\"PAGE ");
CPPUNIT_ASSERT_EQUAL(OUString("PAGE "), std::get<0>(result));
}
......
......@@ -2283,8 +2283,7 @@ static OUString lcl_ExtractToken(OUString const& rCommand,
return token.makeStringAndClear();
}
std::tuple<OUString, std::vector<OUString>, std::vector<OUString> >
lcl_SplitFieldCommand(const OUString& rCommand)
std::tuple<OUString, std::vector<OUString>, std::vector<OUString> > splitFieldCommand(const OUString& rCommand)
{
OUString sType;
std::vector<OUString> arguments;
......@@ -3550,7 +3549,7 @@ void DomainMapper_Impl::CloseFieldCommand()
uno::Reference< uno::XInterface > xFieldInterface;
std::tuple<OUString, std::vector<OUString>, std::vector<OUString> > const
field(lcl_SplitFieldCommand(pContext->GetCommand()));
field(splitFieldCommand(pContext->GetCommand()));
OUString const sFirstParam(std::get<1>(field).empty()
? OUString() : std::get<1>(field).front());
......
......@@ -870,10 +870,6 @@ private:
bool m_bParaHadField;
};
// export just for test
SAL_DLLPUBLIC_EXPORT std::tuple<OUString, std::vector<OUString>, std::vector<OUString> >
lcl_SplitFieldCommand(const OUString& rCommand);
} //namespace dmapper
} //namespace writerfilter
#endif
......
......@@ -40,7 +40,7 @@
#include <oox/token/namespaces.hxx>
#include <oox/drawingml/drawingmltypes.hxx>
#include <rtl/uri.hxx>
#include <dmapper/DomainMapper_Impl.hxx>
#include <dmapper/DomainMapperFactory.hxx>
#include <rtfsdrimport.hxx>
#include <rtflookahead.hxx>
#include <rtfcharsets.hxx>
......@@ -1575,7 +1575,7 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
aBuf.append(ch);
}
OUString aFieldCommand = OStringToOUString(aBuf.toString(), RTL_TEXTENCODING_UTF8);
std::tuple<OUString, std::vector<OUString>, std::vector<OUString> > aResult = writerfilter::dmapper::lcl_SplitFieldCommand(aFieldCommand);
std::tuple<OUString, std::vector<OUString>, std::vector<OUString> > aResult = writerfilter::dmapper::splitFieldCommand(aFieldCommand);
m_aPicturePath = std::get<1>(aResult).empty() ? OUString() : std::get<1>(aResult).front();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment