writerfilter09: new: LoggedResourceHelper
This commit is contained in:
parent
bb22544122
commit
c7463f8d07
2 changed files with 111 additions and 51 deletions
|
@ -34,6 +34,26 @@
|
|||
namespace writerfilter
|
||||
{
|
||||
|
||||
class LoggedResourcesHelper
|
||||
{
|
||||
public:
|
||||
explicit LoggedResourcesHelper(TagLogger::Pointer_t pLogger, const string & sPrefix);
|
||||
virtual ~LoggedResourcesHelper();
|
||||
|
||||
void startElement(const string & sElement);
|
||||
void endElement(const string & sElement);
|
||||
void chars(const ::rtl::OUString & rChars);
|
||||
void chars(const string & rChars);
|
||||
void attribute(const string & rName, const string & rValue);
|
||||
void attribute(const string & rName, sal_uInt32 nValue);
|
||||
|
||||
void setPrefix(const string & rPrefix);
|
||||
|
||||
private:
|
||||
TagLogger::Pointer_t mpLogger;
|
||||
string msPrefix;
|
||||
};
|
||||
|
||||
class LoggedStream : public Stream
|
||||
{
|
||||
public:
|
||||
|
@ -71,9 +91,7 @@ protected:
|
|||
virtual void lcl_substream(Id name, writerfilter::Reference<Stream>::Pointer_t ref) = 0;
|
||||
virtual void lcl_info(const string & info) = 0;
|
||||
|
||||
private:
|
||||
TagLogger::Pointer_t mpLogger;
|
||||
string msPrefix;
|
||||
LoggedResourcesHelper mHelper;
|
||||
};
|
||||
|
||||
class LoggedProperties : public Properties
|
||||
|
@ -89,9 +107,7 @@ protected:
|
|||
virtual void lcl_attribute(Id name, Value & val) = 0;
|
||||
virtual void lcl_sprm(Sprm & sprm) = 0;
|
||||
|
||||
private:
|
||||
TagLogger::Pointer_t mpLogger;
|
||||
string msPrefix;
|
||||
LoggedResourcesHelper mHelper;
|
||||
};
|
||||
|
||||
class LoggedTable : public Table
|
||||
|
@ -105,9 +121,7 @@ public:
|
|||
protected:
|
||||
virtual void lcl_entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref) = 0;
|
||||
|
||||
private:
|
||||
TagLogger::Pointer_t mpLogger;
|
||||
string msPrefix;
|
||||
LoggedResourcesHelper mHelper;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -32,10 +32,56 @@
|
|||
namespace writerfilter
|
||||
{
|
||||
|
||||
// class: LoggedResourcesHelper
|
||||
|
||||
LoggedResourcesHelper::LoggedResourcesHelper(TagLogger::Pointer_t pLogger, const string & sPrefix)
|
||||
: mpLogger(pLogger), msPrefix(sPrefix)
|
||||
{
|
||||
}
|
||||
|
||||
LoggedResourcesHelper::~LoggedResourcesHelper()
|
||||
{
|
||||
}
|
||||
|
||||
void LoggedResourcesHelper::startElement(const string & sElement)
|
||||
{
|
||||
mpLogger->startElement(msPrefix + "." + sElement);
|
||||
}
|
||||
|
||||
void LoggedResourcesHelper::endElement(const string & sElement)
|
||||
{
|
||||
mpLogger->endElement(msPrefix + "." + sElement);
|
||||
}
|
||||
|
||||
void LoggedResourcesHelper::chars(const ::rtl::OUString & rChars)
|
||||
{
|
||||
mpLogger->chars(rChars);
|
||||
}
|
||||
|
||||
void LoggedResourcesHelper::chars(const string & rChars)
|
||||
{
|
||||
mpLogger->chars(rChars);
|
||||
}
|
||||
|
||||
void LoggedResourcesHelper::attribute(const string & rName, const string & rValue)
|
||||
{
|
||||
mpLogger->attribute(rName, rValue);
|
||||
}
|
||||
|
||||
void LoggedResourcesHelper::attribute(const string & rName, sal_uInt32 nValue)
|
||||
{
|
||||
mpLogger->attribute(rName, nValue);
|
||||
}
|
||||
|
||||
void LoggedResourcesHelper::setPrefix(const string & rPrefix)
|
||||
{
|
||||
msPrefix = rPrefix;
|
||||
}
|
||||
|
||||
// class: LoggedStream
|
||||
|
||||
LoggedStream::LoggedStream(TagLogger::Pointer_t pLogger, const string & sPrefix)
|
||||
: mpLogger(pLogger), msPrefix(sPrefix)
|
||||
: mHelper(pLogger, sPrefix)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -46,7 +92,7 @@ LoggedStream::~LoggedStream()
|
|||
void LoggedStream::startSectionGroup()
|
||||
{
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->startElement(msPrefix + ".section");
|
||||
mHelper.startElement("section");
|
||||
#endif
|
||||
|
||||
lcl_startSectionGroup();
|
||||
|
@ -57,14 +103,14 @@ void LoggedStream::endSectionGroup()
|
|||
lcl_endSectionGroup();
|
||||
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->endElement(msPrefix + ".section");
|
||||
mHelper.endElement("section");
|
||||
#endif
|
||||
}
|
||||
|
||||
void LoggedStream::startParagraphGroup()
|
||||
{
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->startElement(msPrefix + ".paragraph");
|
||||
mHelper.startElement("paragraph");
|
||||
#endif
|
||||
|
||||
lcl_startParagraphGroup();
|
||||
|
@ -75,7 +121,7 @@ void LoggedStream::endParagraphGroup()
|
|||
lcl_endParagraphGroup();
|
||||
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->endElement(msPrefix + ".paragraph");
|
||||
mHelper.endElement("paragraph");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -83,7 +129,7 @@ void LoggedStream::endParagraphGroup()
|
|||
void LoggedStream::startCharacterGroup()
|
||||
{
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->startElement(msPrefix + ".charactergroup");
|
||||
mHelper.startElement("charactergroup");
|
||||
#endif
|
||||
|
||||
lcl_startCharacterGroup();
|
||||
|
@ -94,14 +140,14 @@ void LoggedStream::endCharacterGroup()
|
|||
lcl_endCharacterGroup();
|
||||
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->endElement(msPrefix + ".charactergroup");
|
||||
mHelper.endElement("charactergroup");
|
||||
#endif
|
||||
}
|
||||
|
||||
void LoggedStream::startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape )
|
||||
{
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->startElement(msPrefix + ".shape");
|
||||
mHelper.startElement("shape");
|
||||
#endif
|
||||
|
||||
lcl_startShape(xShape);
|
||||
|
@ -112,110 +158,110 @@ void LoggedStream::endShape()
|
|||
lcl_endShape();
|
||||
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->endElement(msPrefix + ".shape");
|
||||
mHelper.endElement("shape");
|
||||
#endif
|
||||
}
|
||||
|
||||
void LoggedStream::text(const sal_uInt8 * data, size_t len)
|
||||
{
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->startElement(msPrefix + ".text");
|
||||
mHelper.startElement("text");
|
||||
|
||||
::rtl::OUString sText( (const sal_Char*) data, len, RTL_TEXTENCODING_MS_1252 );
|
||||
|
||||
mpLogger->startElement(msPrefix + ".data");
|
||||
mpLogger->chars(sText);
|
||||
mpLogger->endElement(msPrefix + ".data");
|
||||
mHelper.startElement("data");
|
||||
mHelper.chars(sText);
|
||||
mHelper.endElement("data");
|
||||
#endif
|
||||
|
||||
lcl_text(data, len);
|
||||
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->endElement(msPrefix + ".text");
|
||||
mHelper.endElement("text");
|
||||
#endif
|
||||
}
|
||||
|
||||
void LoggedStream::utext(const sal_uInt8 * data, size_t len)
|
||||
{
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->startElement(msPrefix + ".utext");
|
||||
mpLogger->startElement(msPrefix + ".data");
|
||||
mHelper.startElement("utext");
|
||||
mHelper.startElement("data");
|
||||
|
||||
::rtl::OUString sText;
|
||||
::rtl::OUStringBuffer aBuffer = ::rtl::OUStringBuffer(len);
|
||||
aBuffer.append( (const sal_Unicode *) data, len);
|
||||
sText = aBuffer.makeStringAndClear();
|
||||
|
||||
mpLogger->chars(sText);
|
||||
mHelper.chars(sText);
|
||||
|
||||
mpLogger->endElement(msPrefix + ".data");
|
||||
mHelper.endElement("data");
|
||||
#endif
|
||||
|
||||
lcl_utext(data, len);
|
||||
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->endElement(msPrefix + ".utext");
|
||||
mHelper.endElement("utext");
|
||||
#endif
|
||||
}
|
||||
|
||||
void LoggedStream::props(writerfilter::Reference<Properties>::Pointer_t ref)
|
||||
{
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->startElement(msPrefix + ".props");
|
||||
mHelper.startElement("props");
|
||||
#endif
|
||||
|
||||
lcl_props(ref);
|
||||
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->endElement(msPrefix + ".props");
|
||||
mHelper.endElement("props");
|
||||
#endif
|
||||
}
|
||||
|
||||
void LoggedStream::table(Id name, writerfilter::Reference<Table>::Pointer_t ref)
|
||||
{
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->startElement(msPrefix + ".table");
|
||||
mpLogger->attribute("name", (*QNameToString::Instance())(name));
|
||||
mHelper.startElement("table");
|
||||
mHelper.attribute("name", (*QNameToString::Instance())(name));
|
||||
#endif
|
||||
|
||||
lcl_table(name, ref);
|
||||
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->endElement(msPrefix + ".table");
|
||||
mHelper.endElement("table");
|
||||
#endif
|
||||
}
|
||||
|
||||
void LoggedStream::substream(Id name, writerfilter::Reference<Stream>::Pointer_t ref)
|
||||
{
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->startElement(msPrefix + ".substream");
|
||||
mpLogger->attribute("name", name);
|
||||
mHelper.startElement("substream");
|
||||
mHelper.attribute("name", (*QNameToString::Instance())(name));
|
||||
#endif
|
||||
|
||||
lcl_substream(name, ref);
|
||||
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->endElement(msPrefix + ".substream");
|
||||
mHelper.endElement("substream");
|
||||
#endif
|
||||
}
|
||||
|
||||
void LoggedStream::info(const string & info)
|
||||
{
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->startElement(msPrefix + ".info");
|
||||
mpLogger->attribute("text", info);
|
||||
mHelper.startElement("info");
|
||||
mHelper.attribute("text", info);
|
||||
#endif
|
||||
|
||||
lcl_info(info);
|
||||
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->endElement(msPrefix + ".info");
|
||||
mHelper.endElement("info");
|
||||
#endif
|
||||
}
|
||||
|
||||
// class LoggedProperties
|
||||
LoggedProperties::LoggedProperties(TagLogger::Pointer_t pLogger, const string & sPrefix)
|
||||
: mpLogger(pLogger), msPrefix(sPrefix)
|
||||
: mHelper(pLogger, sPrefix)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -226,10 +272,10 @@ LoggedProperties::~LoggedProperties()
|
|||
void LoggedProperties::attribute(Id name, Value & val)
|
||||
{
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->startElement(msPrefix + ".attribute");
|
||||
mpLogger->attribute("name", (*QNameToString::Instance())(name));
|
||||
mpLogger->attribute("value", val.toString());
|
||||
mpLogger->endElement(msPrefix + ".attribute");
|
||||
mHelper.startElement("attribute");
|
||||
mHelper.attribute("name", (*QNameToString::Instance())(name));
|
||||
mHelper.attribute("value", val.toString());
|
||||
mHelper.endElement("attribute");
|
||||
#endif
|
||||
|
||||
lcl_attribute(name, val);
|
||||
|
@ -238,19 +284,19 @@ void LoggedProperties::attribute(Id name, Value & val)
|
|||
void LoggedProperties::sprm(Sprm & sprm)
|
||||
{
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->startElement(msPrefix + ".sprm");
|
||||
mpLogger->chars(sprm.toString());
|
||||
mHelper.startElement("sprm");
|
||||
mHelper.chars(sprm.toString());
|
||||
#endif
|
||||
|
||||
lcl_sprm(sprm);
|
||||
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->endElement(msPrefix + ".sprm");
|
||||
mHelper.endElement("sprm");
|
||||
#endif
|
||||
}
|
||||
|
||||
LoggedTable::LoggedTable(TagLogger::Pointer_t pLogger, const string & sPrefix)
|
||||
: mpLogger(pLogger), msPrefix(sPrefix)
|
||||
: mHelper(pLogger, sPrefix)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -261,14 +307,14 @@ LoggedTable::~LoggedTable()
|
|||
void LoggedTable::entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref)
|
||||
{
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->startElement(msPrefix + ".entry");
|
||||
mpLogger->attribute("pos", pos);
|
||||
mHelper.startElement("entry");
|
||||
mHelper.attribute("pos", pos);
|
||||
#endif
|
||||
|
||||
lcl_entry(pos, ref);
|
||||
|
||||
#ifdef DEBUG_LOGGING
|
||||
mpLogger->endElement(msPrefix + ".entry");
|
||||
mHelper.endElement("entry");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue