summaryrefslogtreecommitdiff
path: root/writerfilter/source/resourcemodel
diff options
context:
space:
mode:
Diffstat (limited to 'writerfilter/source/resourcemodel')
-rw-r--r--writerfilter/source/resourcemodel/Protocol.cxx2
-rw-r--r--writerfilter/source/resourcemodel/ResourceModelHelper.cxx48
-rw-r--r--writerfilter/source/resourcemodel/TagLogger.cxx125
-rw-r--r--writerfilter/source/resourcemodel/makefile.mk1
-rw-r--r--writerfilter/source/resourcemodel/resourcemodel.cxx6
-rw-r--r--writerfilter/source/resourcemodel/resourcemodel.hxx2
-rw-r--r--writerfilter/source/resourcemodel/util.cxx95
7 files changed, 221 insertions, 58 deletions
diff --git a/writerfilter/source/resourcemodel/Protocol.cxx b/writerfilter/source/resourcemodel/Protocol.cxx
index 7ae3c06f2675..51d12eb4f2d6 100644
--- a/writerfilter/source/resourcemodel/Protocol.cxx
+++ b/writerfilter/source/resourcemodel/Protocol.cxx
@@ -28,6 +28,7 @@
*
************************************************************************/
+#ifdef DEBUG
#include <stdio.h>
#include <rtl/ustrbuf.hxx>
#include <resourcemodel/Protocol.hxx>
@@ -214,3 +215,4 @@ void TableProtocol::entry(int pos,
}
}
+#endif // DEBUG
diff --git a/writerfilter/source/resourcemodel/ResourceModelHelper.cxx b/writerfilter/source/resourcemodel/ResourceModelHelper.cxx
new file mode 100644
index 000000000000..fee286fb4570
--- /dev/null
+++ b/writerfilter/source/resourcemodel/ResourceModelHelper.cxx
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "resourcemodel/ResourceModelHelper.hxx"
+
+namespace writerfilter {
+namespace resourcemodel {
+
+void resolveSprmProps(Properties & rHandler, Sprm & rSprm)
+{
+ writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
+ if( pProperties.get())
+ pProperties->resolve(rHandler);
+}
+
+void resolveAttributeProperties(Properties & rHandler, Value & val)
+{
+ writerfilter::Reference<Properties>::Pointer_t pProperties = val.getProperties();
+ if( pProperties.get())
+ pProperties->resolve(rHandler);
+}
+
+
+}}
diff --git a/writerfilter/source/resourcemodel/TagLogger.cxx b/writerfilter/source/resourcemodel/TagLogger.cxx
index 1d9b23623e56..f19bef7c01d1 100644
--- a/writerfilter/source/resourcemodel/TagLogger.cxx
+++ b/writerfilter/source/resourcemodel/TagLogger.cxx
@@ -25,6 +25,7 @@
*
************************************************************************/
+#ifdef DEBUG
#include <fstream>
#include <string.h>
#include <resourcemodel/TagLogger.hxx>
@@ -51,11 +52,65 @@ namespace writerfilter
void XMLTag::addAttr(string sName, sal_uInt32 nValue)
{
- char buffer[256];
+ static char buffer[256];
snprintf(buffer, sizeof(buffer), "%" SAL_PRIdINT32, nValue);
addAttr(sName, buffer);
}
+void XMLTag::addAttr(string sName, uno::Any aAny)
+{
+ string aTmpStrInt;
+ string aTmpStrFloat;
+ string aTmpStrString;
+
+ static char buffer[256];
+
+ try
+ {
+ sal_Int32 nInt = 0;
+ aAny >>= nInt;
+
+ snprintf(buffer, sizeof(buffer), "%" SAL_PRIdINT32,
+ nInt);
+
+ aTmpStrInt = buffer;
+ }
+ catch (uno::Exception aExcept)
+ {
+ aTmpStrInt = "exception";
+ }
+
+ try
+ {
+ float nFloat = 0.0;
+ aAny >>= nFloat;
+
+ snprintf(buffer, sizeof(buffer), "%f",
+ nFloat);
+
+ aTmpStrFloat = buffer;
+ }
+ catch (uno::Exception aExcept)
+ {
+ aTmpStrFloat = "exception";
+ }
+
+ try
+ {
+ ::rtl::OUString aStr;
+ aAny >>= aStr;
+
+ aTmpStrString = OUStringToOString(aStr, RTL_TEXTENCODING_ASCII_US).getStr();
+ }
+ catch (uno::Exception aExcept)
+ {
+ aTmpStrString = "exception";
+ }
+
+ addAttr(sName, "i:" + aTmpStrInt + " f:" + aTmpStrFloat + " s:" +
+ aTmpStrString);
+}
+
void XMLTag::addTag(XMLTag::Pointer_t pTag)
{
if (pTag != XMLTag::Pointer_t())
@@ -64,9 +119,14 @@ namespace writerfilter
void XMLTag::chars(const string & rChars)
{
- mChars = rChars;
+ mChars += rChars;
}
+void XMLTag::chars(const ::rtl::OUString & rChars)
+{
+ chars(OUStringToOString(rChars, RTL_TEXTENCODING_ASCII_US).getStr());
+}
+
const string & XMLTag::getTag() const
{
return mTag;
@@ -162,6 +222,7 @@ namespace writerfilter
static TagLoggerHashMap_t * tagLoggers = NULL;
TagLogger::TagLogger()
+ : mFileName("writerfilter")
{
}
@@ -169,6 +230,11 @@ namespace writerfilter
{
}
+ void TagLogger::setFileName(const string & rName)
+ {
+ mFileName = rName;
+ }
+
TagLogger::Pointer_t TagLogger::getInstance(const char * name)
{
if (tagLoggers == NULL)
@@ -233,6 +299,11 @@ namespace writerfilter
currentTag()->addAttr(name, value);
}
+void TagLogger::attribute(const string & name, const uno::Any aAny)
+{
+ currentTag()->addAttr(name, aAny);
+}
+
void TagLogger::addTag(XMLTag::Pointer_t pTag)
{
currentTag()->addTag(pTag);
@@ -287,7 +358,18 @@ namespace writerfilter
else
fileName += "/tmp";
- fileName += "/writerfilter.";
+ string sPrefix = aIt->second->mFileName;
+ size_t nLastSlash = sPrefix.find_last_of('/');
+ size_t nLastBackslash = sPrefix.find_last_of('\\');
+ size_t nCutPos = nLastSlash;
+ if (nLastBackslash < nCutPos)
+ nCutPos = nLastBackslash;
+ if (nCutPos < sPrefix.size())
+ sPrefix = sPrefix.substr(nCutPos + 1);
+
+ fileName += "/";
+ fileName += sPrefix;
+ fileName +=".";
fileName += name;
fileName += ".xml";
@@ -336,7 +418,7 @@ namespace writerfilter
static char sBuffer[256];
snprintf(sBuffer, sizeof(sBuffer),
- "0x%" SAL_PRIxUINT32 "x, %" SAL_PRIxUINT32 "d", rSprm.getId(),
+ "0x%" SAL_PRIxUINT32 ", %" SAL_PRIuUINT32, rSprm.getId(),
rSprm.getId());
pTag->addAttr("id", sBuffer);
pTag->addAttr("value", rSprm.getValue()->toString());
@@ -347,4 +429,39 @@ namespace writerfilter
}
+XMLTag::Pointer_t unoPropertySetToTag(uno::Reference<beans::XPropertySet> rPropSet)
+{
+ uno::Reference<beans::XPropertySetInfo> xPropSetInfo(rPropSet->getPropertySetInfo());
+ uno::Sequence<beans::Property> aProps(xPropSetInfo->getProperties());
+
+ XMLTag::Pointer_t pResult(new XMLTag("unoPropertySet"));
+
+ for (int i = 0; i < aProps.getLength(); ++i)
+ {
+ XMLTag::Pointer_t pPropTag(new XMLTag("property"));
+
+ ::rtl::OUString sName(aProps[i].Name);
+
+ pPropTag->addAttr("name", sName);
+ try
+ {
+ pPropTag->addAttr("value", rPropSet->getPropertyValue(sName));
+ }
+ catch (uno::Exception aException)
+ {
+ XMLTag::Pointer_t pException(new XMLTag("exception"));
+
+ pException->chars("getPropertyValue(\"");
+ pException->chars(sName);
+ pException->chars("\")");
+ pPropTag->addTag(pException);
+ }
+
+ pResult->addTag(pPropTag);
+ }
+
+ return pResult;
+}
+
}
+#endif // DEBUG
diff --git a/writerfilter/source/resourcemodel/makefile.mk b/writerfilter/source/resourcemodel/makefile.mk
index f3869f30611b..bb5bc05ac1bd 100644
--- a/writerfilter/source/resourcemodel/makefile.mk
+++ b/writerfilter/source/resourcemodel/makefile.mk
@@ -54,6 +54,7 @@ SLOFILES= \
$(SLO)$/resourcemodel.obj \
$(SLO)$/util.obj \
$(SLO)$/TagLogger.obj \
+ $(SLO)$/ResourceModelHelper.obj \
$(SLO)$/WW8Analyzer.obj \
$(SLO)$/Protocol.obj
diff --git a/writerfilter/source/resourcemodel/resourcemodel.cxx b/writerfilter/source/resourcemodel/resourcemodel.cxx
index 9b45834c5ce3..096792c76b8e 100644
--- a/writerfilter/source/resourcemodel/resourcemodel.cxx
+++ b/writerfilter/source/resourcemodel/resourcemodel.cxx
@@ -481,12 +481,6 @@ void WW8PropertiesHandler::attribute(Id name, Value & val)
output.addItem("</attribute>");
}
-bool WW8PropertiesHandler::compare(SprmSharedPointer_t sprm1,
- SprmSharedPointer_t sprm2)
-{
- return sprm1->getId() < sprm2->getId();
-}
-
void WW8PropertiesHandler::sprm(Sprm & sprm_)
{
string tmpStr = "<sprm id=\"";
diff --git a/writerfilter/source/resourcemodel/resourcemodel.hxx b/writerfilter/source/resourcemodel/resourcemodel.hxx
index b316f4c912f9..9f59e68b9e1f 100644
--- a/writerfilter/source/resourcemodel/resourcemodel.hxx
+++ b/writerfilter/source/resourcemodel/resourcemodel.hxx
@@ -76,8 +76,6 @@ public:
void dumpSprm(SprmSharedPointer_t sprm);
void dumpSprms();
-
- static bool compare(SprmSharedPointer_t sprm1, SprmSharedPointer_t sprm2);
};
class WW8BinaryObjHandler : public BinaryObj
diff --git a/writerfilter/source/resourcemodel/util.cxx b/writerfilter/source/resourcemodel/util.cxx
index 47d325654d5b..3d041d18c126 100644
--- a/writerfilter/source/resourcemodel/util.cxx
+++ b/writerfilter/source/resourcemodel/util.cxx
@@ -64,6 +64,37 @@ void logger(string prefix, string message)
logger_stream().flush();
}
+ string xmlify(const string & str)
+ {
+ string result = "";
+ char sBuffer[16];
+
+ for (string::const_iterator aIt = str.begin(); aIt != str.end(); ++aIt)
+ {
+ char c = *aIt;
+
+ if (isprint(c) && c != '\"')
+ {
+ if (c == '<')
+ result += "&lt;";
+ else if (c == '>')
+ result += "&gt;";
+ else if (c == '&')
+ result += "&amp;";
+ else
+ result += c;
+ }
+ else
+ {
+ snprintf(sBuffer, sizeof(sBuffer), "\\%03d", c);
+ result += sBuffer;
+ }
+ }
+
+ return result;
+ }
+
+#ifdef DEBUG
string propertysetToString(uno::Reference<beans::XPropertySet> const & xPropSet)
{
string sResult;
@@ -368,57 +399,29 @@ string propertysetToString(uno::Reference<beans::XPropertySet> const & xPropSet)
return sResult;
}
- string xmlify(const string & str)
- {
- string result = "";
- char sBuffer[16];
-
- for (string::const_iterator aIt = str.begin(); aIt != str.end(); ++aIt)
- {
- char c = *aIt;
-
- if (isprint(c) && c != '\"')
- {
- if (c == '<')
- result += "&lt;";
- else if (c == '>')
- result += "&gt;";
- else if (c == '&')
- result += "&amp;";
- else
- result += c;
- }
- else
- {
- snprintf(sBuffer, sizeof(sBuffer), "\\%03d", c);
- result += sBuffer;
- }
- }
- return result;
- }
+string toString(uno::Reference< text::XTextRange > textRange)
+{
+ string result;
- string toString(uno::Reference< text::XTextRange > textRange)
+ if (textRange.get())
{
- string result;
-
- if (textRange.get())
- {
- rtl::OUString aOUStr = textRange->getString();
- rtl::OString aOStr(aOUStr.getStr(), aOUStr.getLength(), RTL_TEXTENCODING_ASCII_US );
-
- result = aOStr.getStr();
- }
- else
- {
- result="(nil)";
- }
+ rtl::OUString aOUStr = textRange->getString();
+ rtl::OString aOStr(aOUStr.getStr(), aOUStr.getLength(), RTL_TEXTENCODING_ASCII_US );
- return result;
+ result = aOStr.getStr();
}
-
- string toString(const string & rString)
+ else
{
- return rString;
+ result="(nil)";
}
+
+ return result;
+}
+
+string toString(const string & rString)
+{
+ return rString;
+}
+#endif
}