summaryrefslogtreecommitdiff
path: root/writerperfect/source/common
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-04-20 09:07:25 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-04-20 11:16:34 +0200
commitac4ea366ec040cdb68f93d42045cba5780852d9f (patch)
tree5be6a2ecac320004551fd4bd50b66271cf5322a9 /writerperfect/source/common
parent66c02d16dd078613e754dcc775f366413fad13f0 (diff)
writerperfect: astyle -> clang-format
< vmiklos> dtardon: are you strongly attached to astyle usage in core.git writerperfect/? my problem is that 1) when less regular contributors touch it, they don't run astyle 2) core.git has git hooks in place to enforce consistent style for selected files, but that uses clang-format. i wonder if switching to the standard core.git clang-format would be an option to stop this reformat game <@dtardon> vmiklos, clang-format is okay. we started to use astyle years ago, before there were even any serious talk about automatic formatting for the whole libreoffice Change-Id: I844fc9c2e8560e54a49f26064cc0b3c55a5f034c Reviewed-on: https://gerrit.libreoffice.org/53184 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'writerperfect/source/common')
-rw-r--r--writerperfect/source/common/DirectoryStream.cxx77
-rw-r--r--writerperfect/source/common/DocumentHandler.cxx184
-rw-r--r--writerperfect/source/common/WPFTEncodingDialog.cxx146
-rw-r--r--writerperfect/source/common/WPXSvInputStream.cxx234
4 files changed, 313 insertions, 328 deletions
diff --git a/writerperfect/source/common/DirectoryStream.cxx b/writerperfect/source/common/DirectoryStream.cxx
index cc186cfaab0b..eeb449db0e9a 100644
--- a/writerperfect/source/common/DirectoryStream.cxx
+++ b/writerperfect/source/common/DirectoryStream.cxx
@@ -49,22 +49,22 @@ namespace uno = com::sun::star::uno;
namespace writerperfect
{
-
namespace
{
-
-uno::Reference<io::XInputStream> findStream(ucbhelper::Content &rContent, const rtl::OUString &rName)
+uno::Reference<io::XInputStream> findStream(ucbhelper::Content& rContent,
+ const rtl::OUString& rName)
{
uno::Reference<io::XInputStream> xInputStream;
- uno::Sequence<OUString> lPropNames { "Title" };
+ uno::Sequence<OUString> lPropNames{ "Title" };
try
{
const uno::Reference<sdbc::XResultSet> xResultSet(
rContent.createCursor(lPropNames, ucbhelper::INCLUDE_DOCUMENTS_ONLY));
if (xResultSet->first())
{
- const uno::Reference<ucb::XContentAccess> xContentAccess(xResultSet, uno::UNO_QUERY_THROW);
+ const uno::Reference<ucb::XContentAccess> xContentAccess(xResultSet,
+ uno::UNO_QUERY_THROW);
const uno::Reference<sdbc::XRow> xRow(xResultSet, uno::UNO_QUERY_THROW);
do
{
@@ -72,57 +72,56 @@ uno::Reference<io::XInputStream> findStream(ucbhelper::Content &rContent, const
if (aTitle == rName)
{
const uno::Reference<ucb::XContent> xSubContent(xContentAccess->queryContent());
- ucbhelper::Content aSubContent(xSubContent, uno::Reference<ucb::XCommandEnvironment>(), comphelper::getProcessComponentContext());
+ ucbhelper::Content aSubContent(xSubContent,
+ uno::Reference<ucb::XCommandEnvironment>(),
+ comphelper::getProcessComponentContext());
xInputStream = aSubContent.openStream();
break;
}
- }
- while (xResultSet->next());
+ } while (xResultSet->next());
}
}
- catch (const uno::RuntimeException &)
+ catch (const uno::RuntimeException&)
{
// ignore
}
- catch (const uno::Exception &)
+ catch (const uno::Exception&)
{
// ignore
}
return xInputStream;
}
-
}
struct DirectoryStream::Impl
{
- explicit Impl(const uno::Reference<ucb::XContent> &rxContent);
+ explicit Impl(const uno::Reference<ucb::XContent>& rxContent);
uno::Reference<ucb::XContent> xContent;
};
-DirectoryStream::Impl::Impl(const uno::Reference<ucb::XContent> &rxContent)
+DirectoryStream::Impl::Impl(const uno::Reference<ucb::XContent>& rxContent)
: xContent(rxContent)
{
}
-DirectoryStream::DirectoryStream(const css::uno::Reference<css::ucb::XContent> &xContent)
+DirectoryStream::DirectoryStream(const css::uno::Reference<css::ucb::XContent>& xContent)
: m_pImpl(isDirectory(xContent) ? new Impl(xContent) : nullptr)
{
}
-DirectoryStream::~DirectoryStream()
-{
-}
+DirectoryStream::~DirectoryStream() {}
-bool DirectoryStream::isDirectory(const css::uno::Reference<css::ucb::XContent> &xContent)
+bool DirectoryStream::isDirectory(const css::uno::Reference<css::ucb::XContent>& xContent)
{
try
{
if (!xContent.is())
return false;
- ucbhelper::Content aContent(xContent, uno::Reference<ucb::XCommandEnvironment>(), comphelper::getProcessComponentContext());
+ ucbhelper::Content aContent(xContent, uno::Reference<ucb::XCommandEnvironment>(),
+ comphelper::getProcessComponentContext());
return aContent.isFolder();
}
catch (...)
@@ -131,7 +130,8 @@ bool DirectoryStream::isDirectory(const css::uno::Reference<css::ucb::XContent>
}
}
-std::unique_ptr<DirectoryStream> DirectoryStream::createForParent(const css::uno::Reference<css::ucb::XContent> &xContent)
+std::unique_ptr<DirectoryStream>
+DirectoryStream::createForParent(const css::uno::Reference<css::ucb::XContent>& xContent)
{
try
{
@@ -167,10 +167,7 @@ const css::uno::Reference<css::ucb::XContent> DirectoryStream::getContent() cons
return m_pImpl->xContent;
}
-bool DirectoryStream::isStructured()
-{
- return m_pImpl != nullptr;
-}
+bool DirectoryStream::isStructured() { return m_pImpl != nullptr; }
unsigned DirectoryStream::subStreamCount()
{
@@ -178,58 +175,50 @@ unsigned DirectoryStream::subStreamCount()
return 0;
}
-const char *DirectoryStream::subStreamName(unsigned /* id */)
+const char* DirectoryStream::subStreamName(unsigned /* id */)
{
// TODO: implement me
return nullptr;
}
-bool DirectoryStream::existsSubStream(const char * /* name */)
+bool DirectoryStream::existsSubStream(const char* /* name */)
{
// TODO: implement me
return false;
}
-librevenge::RVNGInputStream *DirectoryStream::getSubStreamByName(const char *const pName)
+librevenge::RVNGInputStream* DirectoryStream::getSubStreamByName(const char* const pName)
{
if (!m_pImpl)
return nullptr;
- ucbhelper::Content aContent(m_pImpl->xContent, uno::Reference<ucb::XCommandEnvironment>(), comphelper::getProcessComponentContext());
- const uno::Reference<io::XInputStream> xInputStream(findStream(aContent, rtl::OUString::createFromAscii(pName)));
+ ucbhelper::Content aContent(m_pImpl->xContent, uno::Reference<ucb::XCommandEnvironment>(),
+ comphelper::getProcessComponentContext());
+ const uno::Reference<io::XInputStream> xInputStream(
+ findStream(aContent, rtl::OUString::createFromAscii(pName)));
if (xInputStream.is())
return new WPXSvInputStream(xInputStream);
return nullptr;
}
-librevenge::RVNGInputStream *DirectoryStream::getSubStreamById(unsigned /* id */)
+librevenge::RVNGInputStream* DirectoryStream::getSubStreamById(unsigned /* id */)
{
// TODO: implement me
return nullptr;
}
-const unsigned char *DirectoryStream::read(unsigned long, unsigned long &nNumBytesRead)
+const unsigned char* DirectoryStream::read(unsigned long, unsigned long& nNumBytesRead)
{
nNumBytesRead = 0;
return nullptr;
}
-int DirectoryStream::seek(long, librevenge::RVNG_SEEK_TYPE)
-{
- return -1;
-}
-
-long DirectoryStream::tell()
-{
- return 0;
-}
+int DirectoryStream::seek(long, librevenge::RVNG_SEEK_TYPE) { return -1; }
-bool DirectoryStream::isEnd()
-{
- return true;
-}
+long DirectoryStream::tell() { return 0; }
+bool DirectoryStream::isEnd() { return true; }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/DocumentHandler.cxx b/writerperfect/source/common/DocumentHandler.cxx
index 43de86bfc879..aa171ba8a199 100644
--- a/writerperfect/source/common/DocumentHandler.cxx
+++ b/writerperfect/source/common/DocumentHandler.cxx
@@ -20,81 +20,81 @@
namespace writerperfect
{
-
-static const unsigned char librvng_utf8_skip_data[256] =
-{
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
-};
-
-#define librvng_utf8_next_char(p) ((p) + librvng_utf8_skip_data[*reinterpret_cast<unsigned char const *>(p)])
-
-static void unescapeXML(const char *s, const unsigned long sz, librevenge::RVNGString &res)
+static const unsigned char librvng_utf8_skip_data[256]
+ = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 1, 1 };
+
+#define librvng_utf8_next_char(p) \
+ ((p) + librvng_utf8_skip_data[*reinterpret_cast<unsigned char const*>(p)])
+
+static void unescapeXML(const char* s, const unsigned long sz, librevenge::RVNGString& res)
{
- const char *p = s;
- const char *const end = p + sz;
+ const char* p = s;
+ const char* const end = p + sz;
while (p != end)
{
- const char *const next = librvng_utf8_next_char(p);
+ const char* const next = librvng_utf8_next_char(p);
if (next > end)
{
// oops, the string is invalid
break;
}
- if (p+4 <= end && p+1==next && *p=='&')
+ if (p + 4 <= end && p + 1 == next && *p == '&')
{
// look for &amp; , &lt; , &gt; , &apos; , &quot;
- bool escapedChar=false;
- switch (*(p+1))
+ bool escapedChar = false;
+ switch (*(p + 1))
{
- case 'a':
- if (p+5 <= end && strncmp(p,"&amp;",5)==0)
- {
- res.append('&');
- p+=5;
- escapedChar=true;
- }
- else if (p+6 <= end && strncmp(p,"&apos;",6)==0)
- {
- res.append('\'');
- p+=6;
- escapedChar=true;
- }
- break;
- case 'g':
- if (strncmp(p,"&gt;",4)==0)
- {
- res.append('>');
- p+=4;
- escapedChar=true;
- }
- break;
- case 'l':
- if (strncmp(p,"&lt;",4)==0)
- {
- res.append('<');
- p+=4;
- escapedChar=true;
- }
- break;
- case 'q':
- if (p+6 <= end && strncmp(p,"&quot;",6)==0)
- {
- res.append('"');
- p+=6;
- escapedChar=true;
- }
- break;
- default:
- break;
+ case 'a':
+ if (p + 5 <= end && strncmp(p, "&amp;", 5) == 0)
+ {
+ res.append('&');
+ p += 5;
+ escapedChar = true;
+ }
+ else if (p + 6 <= end && strncmp(p, "&apos;", 6) == 0)
+ {
+ res.append('\'');
+ p += 6;
+ escapedChar = true;
+ }
+ break;
+ case 'g':
+ if (strncmp(p, "&gt;", 4) == 0)
+ {
+ res.append('>');
+ p += 4;
+ escapedChar = true;
+ }
+ break;
+ case 'l':
+ if (strncmp(p, "&lt;", 4) == 0)
+ {
+ res.append('<');
+ p += 4;
+ escapedChar = true;
+ }
+ break;
+ case 'q':
+ if (p + 6 <= end && strncmp(p, "&quot;", 6) == 0)
+ {
+ res.append('"');
+ p += 6;
+ escapedChar = true;
+ }
+ break;
+ default:
+ break;
}
- if (escapedChar) continue;
+ if (escapedChar)
+ continue;
}
while (p != next)
@@ -110,52 +110,51 @@ using com::sun::star::uno::Reference;
using com::sun::star::xml::sax::XAttributeList;
using com::sun::star::xml::sax::XDocumentHandler;
-DocumentHandler::DocumentHandler(Reference < XDocumentHandler > const &xHandler) :
- mxHandler(xHandler)
+DocumentHandler::DocumentHandler(Reference<XDocumentHandler> const& xHandler)
+ : mxHandler(xHandler)
{
- if (SvXMLImport *pFastHandler = dynamic_cast<SvXMLImport *>(mxHandler.get()))
+ if (SvXMLImport* pFastHandler = dynamic_cast<SvXMLImport*>(mxHandler.get()))
mxHandler.set(new SvXMLLegacyToFastDocHandler(pFastHandler));
}
-void DocumentHandler::startDocument()
-{
- mxHandler->startDocument();
-}
+void DocumentHandler::startDocument() { mxHandler->startDocument(); }
-void DocumentHandler::endDocument()
-{
- mxHandler->endDocument();
-}
+void DocumentHandler::endDocument() { mxHandler->endDocument(); }
-void DocumentHandler::startElement(const char *psName, const librevenge::RVNGPropertyList &xPropList)
+void DocumentHandler::startElement(const char* psName,
+ const librevenge::RVNGPropertyList& xPropList)
{
- SvXMLAttributeList *pAttrList = new SvXMLAttributeList();
- Reference < XAttributeList > xAttrList(pAttrList);
+ SvXMLAttributeList* pAttrList = new SvXMLAttributeList();
+ Reference<XAttributeList> xAttrList(pAttrList);
librevenge::RVNGPropertyList::Iter i(xPropList);
for (i.rewind(); i.next();)
{
// filter out librevenge elements
if (strncmp(i.key(), "librevenge", 10) != 0)
{
- size_t keyLength=strlen(i.key());
- OUString sName(i.key(), keyLength, RTL_TEXTENCODING_UTF8);
- OUString sValue(i()->getStr().cstr(), strlen(i()->getStr().cstr()), RTL_TEXTENCODING_UTF8);
+ size_t keyLength = strlen(i.key());
+ OUString sName(i.key(), keyLength, RTL_TEXTENCODING_UTF8);
+ OUString sValue(i()->getStr().cstr(), strlen(i()->getStr().cstr()),
+ RTL_TEXTENCODING_UTF8);
// libodfgen xml-encodes some attribute's value, so check if the value is encoded or not
- for (int j=0; j<9; ++j)
+ for (int j = 0; j < 9; ++j)
{
// list of the encoded attributes followed by their lengths
- static char const *listEncoded[9]=
- {
- "draw:name", "svg:font-family", "style:condition", "style:num-prefix", "style:num-suffix",
- "table:formula", "text:bullet-char", "text:label", "xlink:href"
- };
- static size_t const listEncodedLength[9]= {9,15,15,16,16,13,16,10,10};
- if (keyLength==listEncodedLength[j] && strncmp(i.key(), listEncoded[j], keyLength)==0)
+ static char const* listEncoded[9]
+ = { "draw:name", "svg:font-family", "style:condition",
+ "style:num-prefix", "style:num-suffix", "table:formula",
+ "text:bullet-char", "text:label", "xlink:href" };
+ static size_t const listEncodedLength[9] = { 9, 15, 15, 16, 16, 13, 16, 10, 10 };
+ if (keyLength == listEncodedLength[j]
+ && strncmp(i.key(), listEncoded[j], keyLength) == 0)
{
librevenge::RVNGString decodedValue("");
- unescapeXML(i()->getStr().cstr(), static_cast<unsigned long>(strlen(i()->getStr().cstr())), decodedValue);
- sValue=OUString(decodedValue.cstr(), strlen(decodedValue.cstr()), RTL_TEXTENCODING_UTF8);
+ unescapeXML(i()->getStr().cstr(),
+ static_cast<unsigned long>(strlen(i()->getStr().cstr())),
+ decodedValue);
+ sValue = OUString(decodedValue.cstr(), strlen(decodedValue.cstr()),
+ RTL_TEXTENCODING_UTF8);
break;
}
}
@@ -167,18 +166,17 @@ void DocumentHandler::startElement(const char *psName, const librevenge::RVNGPro
mxHandler->startElement(sElementName, xAttrList);
}
-void DocumentHandler::endElement(const char *psName)
+void DocumentHandler::endElement(const char* psName)
{
OUString sElementName(psName, strlen(psName), RTL_TEXTENCODING_UTF8);
mxHandler->endElement(sElementName);
}
-void DocumentHandler::characters(const librevenge::RVNGString &sCharacters)
+void DocumentHandler::characters(const librevenge::RVNGString& sCharacters)
{
OUString sCharU16(sCharacters.cstr(), strlen(sCharacters.cstr()), RTL_TEXTENCODING_UTF8);
mxHandler->characters(sCharU16);
}
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/WPFTEncodingDialog.cxx b/writerperfect/source/common/WPFTEncodingDialog.cxx
index d025774d2e0d..dbd5356e5030 100644
--- a/writerperfect/source/common/WPFTEncodingDialog.cxx
+++ b/writerperfect/source/common/WPFTEncodingDialog.cxx
@@ -26,96 +26,93 @@
namespace writerperfect
{
-
namespace
{
-
-std::pair<OUStringLiteral, OUStringLiteral> const s_encodings[] =
-{
- {"MacArabic", "Arabic (Apple Macintosh)"},
- {"CP864", "Arabic (DOS/OS2-864)"},
- {"CP1006", "Arabic (IBM-1006)"},
- {"CP1256", "Arabic (Windows-1256)"},
- {"CP775", "Baltic (DOS/OS2-775)"},
- {"CP1257", "Baltic (Windows-1257)"},
- {"MacCeltic", "Celtic (Apple Macintosh)"},
- {"MacCyrillic", "Cyrillic (Apple Macintosh)"},
- {"CP855", "Cyrillic (DOS/OS2-855)"},
- {"CP866", "Cyrillic (DOS/OS2-866/Russian)"},
- {"CP1251", "Cyrillic (Windows-1251)"},
- {"MacCEurope", "Eastern Europe (Apple Macintosh)"},
- {"MacCroatian", "Eastern Europe (Apple Macintosh/Croatian)"},
- {"MacRomanian", "Eastern Europe (Apple Macintosh/Romanian)"},
- {"CP852", "Eastern Europe (DOS/OS2-852)"},
- {"CP1250", "Eastern Europe (Windows-1250/WinLatin 2)"},
- {"MacGreek", "Greek (Apple Macintosh)"},
- {"CP737", "Greek (DOS/OS2-737)"},
- {"CP869", "Greek (DOS/OS2-869/Greek-2)"},
- {"CP875", "Greek (DOS/OS2-875)"},
- {"CP1253", "Greek (Windows-1253)"},
- {"MacHebrew", "Hebrew (Apple Macintosh)"},
- {"CP424", "Hebrew (DOS/OS2-424)"},
- {"CP856", "Hebrew (DOS/OS2-856)"},
- {"CP862", "Hebrew (DOS/OS2-862)"},
- {"CP1255", "Hebrew (Windows-1255)"},
- {"CP500", "International (DOS/OS2-500)"},
- {"CP932", "Japanese (Windows-932)"},
- {"MacThai", "Thai (Apple Macintosh)"},
- {"CP874", "Thai (DOS/OS2-874)"},
- {"CP950", "Traditional Chinese (Windows-950)"},
- {"MacTurkish", "Turkish (Apple Macintosh)"},
- {"CP857", "Turkish (DOS/OS2-857)"},
- {"CP1026", "Turkish (DOS/OS2-1026)"},
- {"CP1254", "Turkish (Windows-1254)"},
- {"CP1258", "Vietnamese (Windows-1258)"},
- {"MacRoman", "Western Europe (Apple Macintosh)"},
- {"MacIceland", "Western Europe (Apple Macintosh/Icelandic)"},
- {"CP037", "Western Europe (DOS/OS2-037/US-Canada)"},
- {"CP437", "Western Europe (DOS/OS2-437/US)"},
- {"CP850", "Western Europe (DOS/OS2-850)"},
- {"CP860", "Western Europe (DOS/OS2-860/Portuguese)"},
- {"CP861", "Western Europe (DOS/OS2-861/Icelandic)"},
- {"CP863", "Western Europe (DOS/OS2-863/French)"},
- {"CP865", "Western Europe (DOS/OS2-865/Nordic)"},
- {"CP1252", "Western Europe (Windows-1252/WinLatin 1)"}
-};
+std::pair<OUStringLiteral, OUStringLiteral> const s_encodings[]
+ = { { "MacArabic", "Arabic (Apple Macintosh)" },
+ { "CP864", "Arabic (DOS/OS2-864)" },
+ { "CP1006", "Arabic (IBM-1006)" },
+ { "CP1256", "Arabic (Windows-1256)" },
+ { "CP775", "Baltic (DOS/OS2-775)" },
+ { "CP1257", "Baltic (Windows-1257)" },
+ { "MacCeltic", "Celtic (Apple Macintosh)" },
+ { "MacCyrillic", "Cyrillic (Apple Macintosh)" },
+ { "CP855", "Cyrillic (DOS/OS2-855)" },
+ { "CP866", "Cyrillic (DOS/OS2-866/Russian)" },
+ { "CP1251", "Cyrillic (Windows-1251)" },
+ { "MacCEurope", "Eastern Europe (Apple Macintosh)" },
+ { "MacCroatian", "Eastern Europe (Apple Macintosh/Croatian)" },
+ { "MacRomanian", "Eastern Europe (Apple Macintosh/Romanian)" },
+ { "CP852", "Eastern Europe (DOS/OS2-852)" },
+ { "CP1250", "Eastern Europe (Windows-1250/WinLatin 2)" },
+ { "MacGreek", "Greek (Apple Macintosh)" },
+ { "CP737", "Greek (DOS/OS2-737)" },
+ { "CP869", "Greek (DOS/OS2-869/Greek-2)" },
+ { "CP875", "Greek (DOS/OS2-875)" },
+ { "CP1253", "Greek (Windows-1253)" },
+ { "MacHebrew", "Hebrew (Apple Macintosh)" },
+ { "CP424", "Hebrew (DOS/OS2-424)" },
+ { "CP856", "Hebrew (DOS/OS2-856)" },
+ { "CP862", "Hebrew (DOS/OS2-862)" },
+ { "CP1255", "Hebrew (Windows-1255)" },
+ { "CP500", "International (DOS/OS2-500)" },
+ { "CP932", "Japanese (Windows-932)" },
+ { "MacThai", "Thai (Apple Macintosh)" },
+ { "CP874", "Thai (DOS/OS2-874)" },
+ { "CP950", "Traditional Chinese (Windows-950)" },
+ { "MacTurkish", "Turkish (Apple Macintosh)" },
+ { "CP857", "Turkish (DOS/OS2-857)" },
+ { "CP1026", "Turkish (DOS/OS2-1026)" },
+ { "CP1254", "Turkish (Windows-1254)" },
+ { "CP1258", "Vietnamese (Windows-1258)" },
+ { "MacRoman", "Western Europe (Apple Macintosh)" },
+ { "MacIceland", "Western Europe (Apple Macintosh/Icelandic)" },
+ { "CP037", "Western Europe (DOS/OS2-037/US-Canada)" },
+ { "CP437", "Western Europe (DOS/OS2-437/US)" },
+ { "CP850", "Western Europe (DOS/OS2-850)" },
+ { "CP860", "Western Europe (DOS/OS2-860/Portuguese)" },
+ { "CP861", "Western Europe (DOS/OS2-861/Icelandic)" },
+ { "CP863", "Western Europe (DOS/OS2-863/French)" },
+ { "CP865", "Western Europe (DOS/OS2-865/Nordic)" },
+ { "CP1252", "Western Europe (Windows-1252/WinLatin 1)" } };
std::size_t const numEncodings = SAL_N_ELEMENTS(s_encodings);
-void insertEncodings(ListBox *box)
+void insertEncodings(ListBox* box)
{
- for (std::size_t i=0; i<numEncodings; ++i)
+ for (std::size_t i = 0; i < numEncodings; ++i)
{
- sal_IntPtr nAt=box->InsertEntry(s_encodings[i].second);
- box->SetEntryData(
- nAt, reinterpret_cast<void *>(static_cast<sal_uIntPtr>(i)));
+ sal_IntPtr nAt = box->InsertEntry(s_encodings[i].second);
+ box->SetEntryData(nAt, reinterpret_cast<void*>(static_cast<sal_uIntPtr>(i)));
}
}
-void selectEncoding(ListBox *box, const OUString &encoding)
+void selectEncoding(ListBox* box, const OUString& encoding)
{
- for (std::size_t i=0; i<numEncodings; ++i)
+ for (std::size_t i = 0; i < numEncodings; ++i)
{
- if (encoding!=s_encodings[i].first) continue;
+ if (encoding != s_encodings[i].first)
+ continue;
box->SelectEntryPos(i);
return;
}
}
-OUString getEncoding(ListBox const *box)
+OUString getEncoding(ListBox const* box)
{
sal_uIntPtr pos = reinterpret_cast<sal_uIntPtr>(box->GetSelectedEntryData());
- if (pos>=numEncodings)
+ if (pos >= numEncodings)
return OUString();
return s_encodings[pos].first;
}
-
}
-WPFTEncodingDialog::WPFTEncodingDialog(
- const OUString &title, const OUString &encoding)
- : ModalDialog(nullptr, "WPFTEncodingDialog", "writerperfect/ui/wpftencodingdialog.ui"),
- m_pLbCharset(), m_pBtnOk(), m_pBtnCancel(), m_userHasCancelled(false)
+WPFTEncodingDialog::WPFTEncodingDialog(const OUString& title, const OUString& encoding)
+ : ModalDialog(nullptr, "WPFTEncodingDialog", "writerperfect/ui/wpftencodingdialog.ui")
+ , m_pLbCharset()
+ , m_pBtnOk()
+ , m_pBtnCancel()
+ , m_userHasCancelled(false)
{
get(m_pLbCharset, "comboboxtext");
get(m_pBtnOk, "ok");
@@ -133,23 +130,17 @@ WPFTEncodingDialog::WPFTEncodingDialog(
SetText(title);
}
-WPFTEncodingDialog::~WPFTEncodingDialog()
-{
- disposeOnce();
-}
+WPFTEncodingDialog::~WPFTEncodingDialog() { disposeOnce(); }
-OUString WPFTEncodingDialog::GetEncoding() const
-{
- return getEncoding(m_pLbCharset);
-}
+OUString WPFTEncodingDialog::GetEncoding() const { return getEncoding(m_pLbCharset); }
-IMPL_LINK_NOARG(WPFTEncodingDialog, CancelHdl, Button *, void)
+IMPL_LINK_NOARG(WPFTEncodingDialog, CancelHdl, Button*, void)
{
- m_userHasCancelled=true;
+ m_userHasCancelled = true;
Close();
}
-IMPL_LINK(WPFTEncodingDialog, DoubleClickHdl, ListBox &, rLb, void)
+IMPL_LINK(WPFTEncodingDialog, DoubleClickHdl, ListBox&, rLb, void)
{
if (&rLb == m_pLbCharset)
{
@@ -164,7 +155,6 @@ void WPFTEncodingDialog::dispose()
m_pBtnCancel.disposeAndClear();
ModalDialog::dispose();
}
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/WPXSvInputStream.cxx b/writerperfect/source/common/WPXSvInputStream.cxx
index 971280b8e25b..2dfee8a44799 100644
--- a/writerperfect/source/common/WPXSvInputStream.cxx
+++ b/writerperfect/source/common/WPXSvInputStream.cxx
@@ -30,7 +30,6 @@
namespace writerperfect
{
-
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::io;
@@ -39,21 +38,20 @@ namespace packages = com::sun::star::packages;
namespace
{
-
class PositionHolder
{
public:
- explicit PositionHolder(const Reference<XSeekable> &rxSeekable);
+ explicit PositionHolder(const Reference<XSeekable>& rxSeekable);
~PositionHolder();
- PositionHolder(const PositionHolder &) = delete;
- PositionHolder &operator=(const PositionHolder &) = delete;
+ PositionHolder(const PositionHolder&) = delete;
+ PositionHolder& operator=(const PositionHolder&) = delete;
private:
const Reference<XSeekable> mxSeekable;
const sal_uInt64 mnPosition;
};
-PositionHolder::PositionHolder(const Reference<XSeekable> &rxSeekable)
+PositionHolder::PositionHolder(const Reference<XSeekable>& rxSeekable)
: mxSeekable(rxSeekable)
, mnPosition(rxSeekable->getPosition())
{
@@ -65,7 +63,9 @@ PositionHolder::~PositionHolder()
{
mxSeekable->seek(mnPosition);
}
- catch (...) {}
+ catch (...)
+ {
+ }
}
} // anonymous namespace
@@ -82,8 +82,7 @@ typedef struct
namespace
{
-
-rtl::OUString lcl_normalizeSubStreamPath(const rtl::OUString &rPath)
+rtl::OUString lcl_normalizeSubStreamPath(const rtl::OUString& rPath)
{
// accept paths which begin by '/'
// TODO: maybe this should to a full normalization
@@ -91,13 +90,11 @@ rtl::OUString lcl_normalizeSubStreamPath(const rtl::OUString &rPath)
return rPath.copy(1);
return rPath;
}
-
}
namespace
{
-
-const rtl::OUString concatPath(const rtl::OUString &lhs, const rtl::OUString &rhs)
+const rtl::OUString concatPath(const rtl::OUString& lhs, const rtl::OUString& rhs)
{
if (lhs.isEmpty())
return rhs;
@@ -106,7 +103,7 @@ const rtl::OUString concatPath(const rtl::OUString &lhs, const rtl::OUString &rh
struct OLEStreamData
{
- OLEStreamData(const rtl::OString &rName, const rtl::OString &rvngName);
+ OLEStreamData(const rtl::OString& rName, const rtl::OString& rvngName);
SotStorageStreamRefWrapper stream;
@@ -147,25 +144,25 @@ struct OLEStorageImpl
{
OLEStorageImpl();
- void initialize(SvStream *pStream);
+ void initialize(SvStream* pStream);
- tools::SvRef<SotStorageStream> getStream(const rtl::OUString &rPath);
- tools::SvRef<SotStorageStream> const &getStream(std::size_t nId);
+ tools::SvRef<SotStorageStream> getStream(const rtl::OUString& rPath);
+ tools::SvRef<SotStorageStream> const& getStream(std::size_t nId);
private:
- void traverse(const tools::SvRef<SotStorage> &rStorage, const rtl::OUString &rPath);
+ void traverse(const tools::SvRef<SotStorage>& rStorage, const rtl::OUString& rPath);
- tools::SvRef<SotStorageStream> createStream(const rtl::OUString &rPath);
+ tools::SvRef<SotStorageStream> createStream(const rtl::OUString& rPath);
public:
SotStorageRefWrapper mxRootStorage; //< root storage of the OLE2
OLEStorageMap_t maStorageMap; //< map of all sub storages by name
- ::std::vector< OLEStreamData > maStreams; //< list of streams and their names
+ ::std::vector<OLEStreamData> maStreams; //< list of streams and their names
NameMap_t maNameMap; //< map of stream names to indexes (into @c maStreams)
bool mbInitialized;
};
-OLEStreamData::OLEStreamData(const rtl::OString &rName, const rtl::OString &rvngName)
+OLEStreamData::OLEStreamData(const rtl::OString& rName, const rtl::OString& rvngName)
: stream()
, name(rName)
, RVNGname(rvngName)
@@ -181,7 +178,7 @@ OLEStorageImpl::OLEStorageImpl()
{
}
-void OLEStorageImpl::initialize(SvStream *const pStream)
+void OLEStorageImpl::initialize(SvStream* const pStream)
{
if (!pStream)
return;
@@ -193,7 +190,7 @@ void OLEStorageImpl::initialize(SvStream *const pStream)
mbInitialized = true;
}
-tools::SvRef<SotStorageStream> OLEStorageImpl::getStream(const rtl::OUString &rPath)
+tools::SvRef<SotStorageStream> OLEStorageImpl::getStream(const rtl::OUString& rPath)
{
const rtl::OUString aPath(lcl_normalizeSubStreamPath(rPath));
NameMap_t::iterator aIt = maNameMap.find(aPath);
@@ -205,20 +202,22 @@ tools::SvRef<SotStorageStream> OLEStorageImpl::getStream(const rtl::OUString &rP
return tools::SvRef<SotStorageStream>();
if (!maStreams[aIt->second].stream.ref.is())
- maStreams[aIt->second].stream.ref = createStream(rtl::OStringToOUString(maStreams[aIt->second].name, RTL_TEXTENCODING_UTF8));
+ maStreams[aIt->second].stream.ref = createStream(
+ rtl::OStringToOUString(maStreams[aIt->second].name, RTL_TEXTENCODING_UTF8));
return maStreams[aIt->second].stream.ref;
}
-tools::SvRef<SotStorageStream> const &OLEStorageImpl::getStream(const std::size_t nId)
+tools::SvRef<SotStorageStream> const& OLEStorageImpl::getStream(const std::size_t nId)
{
if (!maStreams[nId].stream.ref.is())
- maStreams[nId].stream.ref = createStream(rtl::OStringToOUString(maStreams[nId].name, RTL_TEXTENCODING_UTF8));
+ maStreams[nId].stream.ref
+ = createStream(rtl::OStringToOUString(maStreams[nId].name, RTL_TEXTENCODING_UTF8));
return maStreams[nId].stream.ref;
}
-void OLEStorageImpl::traverse(const tools::SvRef<SotStorage> &rStorage, const rtl::OUString &rPath)
+void OLEStorageImpl::traverse(const tools::SvRef<SotStorage>& rStorage, const rtl::OUString& rPath)
{
SvStorageInfoList infos;
@@ -228,12 +227,13 @@ void OLEStorageImpl::traverse(const tools::SvRef<SotStorage> &rStorage, const rt
{
if (aIt->IsStream())
{
- rtl::OUString baseName=aIt->GetName(), rvngName=baseName;
+ rtl::OUString baseName = aIt->GetName(), rvngName = baseName;
// librevenge::RVNGOLEStream ignores the first character when is a control code, so ...
- if (!rvngName.isEmpty() && rvngName.toChar()<32)
- rvngName=rvngName.copy(1);
- maStreams.emplace_back(rtl::OUStringToOString(concatPath(rPath, baseName), RTL_TEXTENCODING_UTF8),
- rtl::OUStringToOString(concatPath(rPath, rvngName), RTL_TEXTENCODING_UTF8));
+ if (!rvngName.isEmpty() && rvngName.toChar() < 32)
+ rvngName = rvngName.copy(1);
+ maStreams.emplace_back(
+ rtl::OUStringToOString(concatPath(rPath, baseName), RTL_TEXTENCODING_UTF8),
+ rtl::OUStringToOString(concatPath(rPath, rvngName), RTL_TEXTENCODING_UTF8));
maNameMap[concatPath(rPath, rvngName)] = maStreams.size() - 1;
}
else if (aIt->IsStorage())
@@ -248,12 +248,13 @@ void OLEStorageImpl::traverse(const tools::SvRef<SotStorage> &rStorage, const rt
}
else
{
- SAL_WARN("writerperfect", "OLEStorageImpl::traverse: invalid storage entry, neither stream nor file");
+ SAL_WARN("writerperfect",
+ "OLEStorageImpl::traverse: invalid storage entry, neither stream nor file");
}
}
}
-tools::SvRef<SotStorageStream> OLEStorageImpl::createStream(const rtl::OUString &rPath)
+tools::SvRef<SotStorageStream> OLEStorageImpl::createStream(const rtl::OUString& rPath)
{
const sal_Int32 nDelim = rPath.lastIndexOf(u'/');
@@ -270,15 +271,13 @@ tools::SvRef<SotStorageStream> OLEStorageImpl::createStream(const rtl::OUString
return aIt->second.ref->OpenSotStream(aName, StreamMode::STD_READ);
}
-
}
namespace
{
-
struct ZipStreamData
{
- explicit ZipStreamData(const rtl::OString &rName);
+ explicit ZipStreamData(const rtl::OString& rName);
Reference<XInputStream> xStream;
@@ -297,7 +296,7 @@ struct ZipStreamData
*/
struct ZipStorageImpl
{
- explicit ZipStorageImpl(const Reference<container::XNameAccess> &rxContainer);
+ explicit ZipStorageImpl(const Reference<container::XNameAccess>& rxContainer);
/** Initialize for access.
*
@@ -307,28 +306,28 @@ struct ZipStorageImpl
*/
void initialize();
- Reference<XInputStream> getStream(const rtl::OUString &rPath);
- Reference<XInputStream> const &getStream(std::size_t nId);
+ Reference<XInputStream> getStream(const rtl::OUString& rPath);
+ Reference<XInputStream> const& getStream(std::size_t nId);
private:
- void traverse(const Reference<container::XNameAccess> &rxEnum);
+ void traverse(const Reference<container::XNameAccess>& rxEnum);
- Reference<XInputStream> createStream(const rtl::OUString &rPath);
+ Reference<XInputStream> createStream(const rtl::OUString& rPath);
public:
Reference<container::XNameAccess> mxContainer; //< root of the Zip
- ::std::vector< ZipStreamData > maStreams; //< list of streams and their names
+ ::std::vector<ZipStreamData> maStreams; //< list of streams and their names
NameMap_t maNameMap; //< map of stream names to indexes (into @c maStreams)
bool mbInitialized;
};
-ZipStreamData::ZipStreamData(const rtl::OString &rName)
+ZipStreamData::ZipStreamData(const rtl::OString& rName)
: xStream()
, aName(rName)
{
}
-ZipStorageImpl::ZipStorageImpl(const Reference<container::XNameAccess> &rxContainer)
+ZipStorageImpl::ZipStorageImpl(const Reference<container::XNameAccess>& rxContainer)
: mxContainer(rxContainer)
, maStreams()
, maNameMap()
@@ -344,7 +343,7 @@ void ZipStorageImpl::initialize()
mbInitialized = true;
}
-Reference<XInputStream> ZipStorageImpl::getStream(const rtl::OUString &rPath)
+Reference<XInputStream> ZipStorageImpl::getStream(const rtl::OUString& rPath)
{
const rtl::OUString aPath(lcl_normalizeSubStreamPath(rPath));
NameMap_t::iterator aIt = maNameMap.find(aPath);
@@ -361,15 +360,16 @@ Reference<XInputStream> ZipStorageImpl::getStream(const rtl::OUString &rPath)
return maStreams[aIt->second].xStream;
}
-Reference<XInputStream> const &ZipStorageImpl::getStream(const std::size_t nId)
+Reference<XInputStream> const& ZipStorageImpl::getStream(const std::size_t nId)
{
if (!maStreams[nId].xStream.is())
- maStreams[nId].xStream = createStream(rtl::OStringToOUString(maStreams[nId].aName, RTL_TEXTENCODING_UTF8));
+ maStreams[nId].xStream
+ = createStream(rtl::OStringToOUString(maStreams[nId].aName, RTL_TEXTENCODING_UTF8));
return maStreams[nId].xStream;
}
-void ZipStorageImpl::traverse(const Reference<container::XNameAccess> &rxContainer)
+void ZipStorageImpl::traverse(const Reference<container::XNameAccess>& rxContainer)
{
const Sequence<rtl::OUString> lNames = rxContainer->getElementNames();
@@ -385,7 +385,7 @@ void ZipStorageImpl::traverse(const Reference<container::XNameAccess> &rxContain
}
}
-Reference<XInputStream> ZipStorageImpl::createStream(const rtl::OUString &rPath)
+Reference<XInputStream> ZipStorageImpl::createStream(const rtl::OUString& rPath)
{
Reference<XInputStream> xStream;
@@ -397,32 +397,31 @@ Reference<XInputStream> ZipStorageImpl::createStream(const rtl::OUString &rPath)
if (xSeekable.is())
xStream = xInputStream;
else
- xStream.set(new comphelper::OSeekableInputWrapper(xInputStream, comphelper::getProcessComponentContext()));
+ xStream.set(new comphelper::OSeekableInputWrapper(
+ xInputStream, comphelper::getProcessComponentContext()));
}
- catch (const Exception &)
+ catch (const Exception&)
{
// nothing needed
}
return xStream;
}
-
}
class WPXSvInputStreamImpl
{
public:
- explicit WPXSvInputStreamImpl(css::uno::Reference<
- css::io::XInputStream > const &xStream);
+ explicit WPXSvInputStreamImpl(css::uno::Reference<css::io::XInputStream> const& xStream);
bool isStructured();
unsigned subStreamCount();
- const char *subStreamName(unsigned id);
- bool existsSubStream(const char *name);
- librevenge::RVNGInputStream *getSubStreamByName(const char *name);
- librevenge::RVNGInputStream *getSubStreamById(unsigned id);
+ const char* subStreamName(unsigned id);
+ bool existsSubStream(const char* name);
+ librevenge::RVNGInputStream* getSubStreamByName(const char* name);
+ librevenge::RVNGInputStream* getSubStreamById(unsigned id);
- const unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead);
+ const unsigned char* read(unsigned long numBytes, unsigned long& numBytesRead);
int seek(long offset);
long tell();
bool isEnd();
@@ -436,36 +435,38 @@ private:
bool isZip();
void ensureZipIsInitialized();
- static librevenge::RVNGInputStream *createWPXStream(const tools::SvRef<SotStorageStream> &rxStorage);
- static librevenge::RVNGInputStream *createWPXStream(const Reference<XInputStream> &rxStream);
+ static librevenge::RVNGInputStream*
+ createWPXStream(const tools::SvRef<SotStorageStream>& rxStorage);
+ static librevenge::RVNGInputStream* createWPXStream(const Reference<XInputStream>& rxStream);
private:
- css::uno::Reference< css::io::XInputStream > mxStream;
- css::uno::Reference< css::io::XSeekable > mxSeekable;
- css::uno::Sequence< sal_Int8 > maData;
- std::unique_ptr< OLEStorageImpl > mpOLEStorage;
- std::unique_ptr< ZipStorageImpl > mpZipStorage;
+ css::uno::Reference<css::io::XInputStream> mxStream;
+ css::uno::Reference<css::io::XSeekable> mxSeekable;
+ css::uno::Sequence<sal_Int8> maData;
+ std::unique_ptr<OLEStorageImpl> mpOLEStorage;
+ std::unique_ptr<ZipStorageImpl> mpZipStorage;
bool mbCheckedOLE;
bool mbCheckedZip;
+
public:
sal_Int64 mnLength;
- const unsigned char *mpReadBuffer;
+ const unsigned char* mpReadBuffer;
unsigned long mnReadBufferLength;
unsigned long mnReadBufferPos;
};
-WPXSvInputStreamImpl::WPXSvInputStreamImpl(Reference< XInputStream > const &xStream) :
- mxStream(xStream),
- mxSeekable(xStream, UNO_QUERY),
- maData(0),
- mpOLEStorage(nullptr),
- mpZipStorage(nullptr),
- mbCheckedOLE(false),
- mbCheckedZip(false),
- mnLength(0),
- mpReadBuffer(nullptr),
- mnReadBufferLength(0),
- mnReadBufferPos(0)
+WPXSvInputStreamImpl::WPXSvInputStreamImpl(Reference<XInputStream> const& xStream)
+ : mxStream(xStream)
+ , mxSeekable(xStream, UNO_QUERY)
+ , maData(0)
+ , mpOLEStorage(nullptr)
+ , mpZipStorage(nullptr)
+ , mbCheckedOLE(false)
+ , mbCheckedZip(false)
+ , mnLength(0)
+ , mpReadBuffer(nullptr)
+ , mnReadBufferLength(0)
+ , mnReadBufferPos(0)
{
if (!xStream.is() || !mxStream.is())
mnLength = 0;
@@ -490,7 +491,7 @@ WPXSvInputStreamImpl::WPXSvInputStreamImpl(Reference< XInputStream > const &xStr
}
}
-const unsigned char *WPXSvInputStreamImpl::read(unsigned long numBytes, unsigned long &numBytesRead)
+const unsigned char* WPXSvInputStreamImpl::read(unsigned long numBytes, unsigned long& numBytesRead)
{
numBytesRead = 0;
@@ -501,7 +502,7 @@ const unsigned char *WPXSvInputStreamImpl::read(unsigned long numBytes, unsigned
if (numBytesRead == 0)
return nullptr;
- return reinterpret_cast<const unsigned char *>(maData.getConstArray());
+ return reinterpret_cast<const unsigned char*>(maData.getConstArray());
}
long WPXSvInputStreamImpl::tell()
@@ -588,7 +589,7 @@ unsigned WPXSvInputStreamImpl::subStreamCount()
return 0;
}
-const char *WPXSvInputStreamImpl::subStreamName(const unsigned id)
+const char* WPXSvInputStreamImpl::subStreamName(const unsigned id)
{
if ((mnLength == 0) || !mxStream.is() || !mxSeekable.is())
return nullptr;
@@ -621,7 +622,7 @@ const char *WPXSvInputStreamImpl::subStreamName(const unsigned id)
return nullptr;
}
-bool WPXSvInputStreamImpl::existsSubStream(const char *const name)
+bool WPXSvInputStreamImpl::existsSubStream(const char* const name)
{
if (!name)
return false;
@@ -651,7 +652,7 @@ bool WPXSvInputStreamImpl::existsSubStream(const char *const name)
return false;
}
-librevenge::RVNGInputStream *WPXSvInputStreamImpl::getSubStreamByName(const char *const name)
+librevenge::RVNGInputStream* WPXSvInputStreamImpl::getSubStreamByName(const char* const name)
{
if (!name)
return nullptr;
@@ -680,7 +681,7 @@ librevenge::RVNGInputStream *WPXSvInputStreamImpl::getSubStreamByName(const char
{
return createWPXStream(mpZipStorage->getStream(aName));
}
- catch (const Exception &)
+ catch (const Exception&)
{
// nothing needed
}
@@ -689,7 +690,7 @@ librevenge::RVNGInputStream *WPXSvInputStreamImpl::getSubStreamByName(const char
return nullptr;
}
-librevenge::RVNGInputStream *WPXSvInputStreamImpl::getSubStreamById(const unsigned id)
+librevenge::RVNGInputStream* WPXSvInputStreamImpl::getSubStreamById(const unsigned id)
{
if ((mnLength == 0) || !mxStream.is() || !mxSeekable.is())
return nullptr;
@@ -720,7 +721,7 @@ librevenge::RVNGInputStream *WPXSvInputStreamImpl::getSubStreamById(const unsign
{
return createWPXStream(mpZipStorage->getStream(id));
}
- catch (const Exception &)
+ catch (const Exception&)
{
// nothing needed
}
@@ -739,17 +740,19 @@ void WPXSvInputStreamImpl::invalidateReadBuffer()
}
}
-librevenge::RVNGInputStream *WPXSvInputStreamImpl::createWPXStream(const tools::SvRef<SotStorageStream> &rxStorage)
+librevenge::RVNGInputStream*
+WPXSvInputStreamImpl::createWPXStream(const tools::SvRef<SotStorageStream>& rxStorage)
{
if (rxStorage.is())
{
- Reference < XInputStream > xContents(new utl::OSeekableInputStreamWrapper(rxStorage.get()));
+ Reference<XInputStream> xContents(new utl::OSeekableInputStreamWrapper(rxStorage.get()));
return new WPXSvInputStream(xContents);
}
return nullptr;
}
-librevenge::RVNGInputStream *WPXSvInputStreamImpl::createWPXStream(const Reference<XInputStream> &rxStream)
+librevenge::RVNGInputStream*
+WPXSvInputStreamImpl::createWPXStream(const Reference<XInputStream>& rxStream)
{
if (rxStream.is())
return new WPXSvInputStream(rxStream);
@@ -784,13 +787,15 @@ bool WPXSvInputStreamImpl::isZip()
Sequence<Any> aArgs(1);
aArgs[0] <<= mxStream;
- const Reference<XComponentContext> xContext(comphelper::getProcessComponentContext(), UNO_QUERY_THROW);
+ const Reference<XComponentContext> xContext(comphelper::getProcessComponentContext(),
+ UNO_QUERY_THROW);
const Reference<packages::zip::XZipFileAccess2> xZip(
- xContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.packages.zip.ZipFileAccess", aArgs, xContext),
+ xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+ "com.sun.star.packages.zip.ZipFileAccess", aArgs, xContext),
UNO_QUERY_THROW);
mpZipStorage.reset(new ZipStorageImpl(xZip));
}
- catch (const Exception &)
+ catch (const Exception&)
{
// ignore
}
@@ -817,29 +822,28 @@ void WPXSvInputStreamImpl::ensureZipIsInitialized()
mpZipStorage->initialize();
}
-WPXSvInputStream::WPXSvInputStream(Reference< XInputStream > const &xStream) :
- mpImpl(new WPXSvInputStreamImpl(xStream))
+WPXSvInputStream::WPXSvInputStream(Reference<XInputStream> const& xStream)
+ : mpImpl(new WPXSvInputStreamImpl(xStream))
{
}
-WPXSvInputStream::~WPXSvInputStream()
-{
-}
+WPXSvInputStream::~WPXSvInputStream() {}
#define BUFFER_MAX 65536
-const unsigned char *WPXSvInputStream::read(unsigned long numBytes, unsigned long &numBytesRead)
+const unsigned char* WPXSvInputStream::read(unsigned long numBytes, unsigned long& numBytesRead)
{
numBytesRead = 0;
- if (numBytes == 0 || numBytes > std::numeric_limits<unsigned long>::max()/2)
+ if (numBytes == 0 || numBytes > std::numeric_limits<unsigned long>::max() / 2)
return nullptr;
if (mpImpl->mpReadBuffer)
{
- if ((mpImpl->mnReadBufferPos + numBytes > mpImpl->mnReadBufferPos) && (mpImpl->mnReadBufferPos + numBytes <= mpImpl->mnReadBufferLength))
+ if ((mpImpl->mnReadBufferPos + numBytes > mpImpl->mnReadBufferPos)
+ && (mpImpl->mnReadBufferPos + numBytes <= mpImpl->mnReadBufferLength))
{
- const unsigned char *pTmp = mpImpl->mpReadBuffer + mpImpl->mnReadBufferPos;
+ const unsigned char* pTmp = mpImpl->mpReadBuffer + mpImpl->mnReadBufferPos;
mpImpl->mnReadBufferPos += numBytes;
numBytesRead = numBytes;
return pTmp;
@@ -849,11 +853,12 @@ const unsigned char *WPXSvInputStream::read(unsigned long numBytes, unsigned lon
}
unsigned long curpos = static_cast<unsigned long>(mpImpl->tell());
- if (curpos == static_cast<unsigned long>(-1)) // returned ERROR
+ if (curpos == static_cast<unsigned long>(-1)) // returned ERROR
return nullptr;
- if ((curpos + numBytes < curpos) /*overflow*/ ||
- (curpos + numBytes >= static_cast<sal_uInt64>(mpImpl->mnLength))) /*reading more than available*/
+ if ((curpos + numBytes < curpos) /*overflow*/
+ || (curpos + numBytes
+ >= static_cast<sal_uInt64>(mpImpl->mnLength))) /*reading more than available*/
{
numBytes = mpImpl->mnLength - curpos;
}
@@ -889,7 +894,8 @@ const unsigned char *WPXSvInputStream::read(unsigned long numBytes, unsigned lon
long WPXSvInputStream::tell()
{
long retVal = mpImpl->tell();
- return retVal - static_cast<long>(mpImpl->mnReadBufferLength) + static_cast<long>(mpImpl->mnReadBufferPos);
+ return retVal - static_cast<long>(mpImpl->mnReadBufferLength)
+ + static_cast<long>(mpImpl->mnReadBufferPos);
}
int WPXSvInputStream::seek(long offset, librevenge::RVNG_SEEK_TYPE seekType)
@@ -912,9 +918,12 @@ int WPXSvInputStream::seek(long offset, librevenge::RVNG_SEEK_TYPE seekType)
retVal = -1;
}
- if (tmpOffset < mpImpl->tell() && static_cast<unsigned long>(tmpOffset) >= static_cast<unsigned long>(mpImpl->tell()) - mpImpl->mnReadBufferLength)
+ if (tmpOffset < mpImpl->tell()
+ && static_cast<unsigned long>(tmpOffset)
+ >= static_cast<unsigned long>(mpImpl->tell()) - mpImpl->mnReadBufferLength)
{
- mpImpl->mnReadBufferPos = static_cast<unsigned long>(tmpOffset + static_cast<long>(mpImpl->mnReadBufferLength) - mpImpl->tell());
+ mpImpl->mnReadBufferPos = static_cast<unsigned long>(
+ tmpOffset + static_cast<long>(mpImpl->mnReadBufferLength) - mpImpl->tell());
return retVal;
}
@@ -942,30 +951,29 @@ unsigned WPXSvInputStream::subStreamCount()
return mpImpl->subStreamCount();
}
-const char *WPXSvInputStream::subStreamName(const unsigned id)
+const char* WPXSvInputStream::subStreamName(const unsigned id)
{
mpImpl->invalidateReadBuffer();
return mpImpl->subStreamName(id);
}
-bool WPXSvInputStream::existsSubStream(const char *const name)
+bool WPXSvInputStream::existsSubStream(const char* const name)
{
mpImpl->invalidateReadBuffer();
return mpImpl->existsSubStream(name);
}
-librevenge::RVNGInputStream *WPXSvInputStream::getSubStreamByName(const char *name)
+librevenge::RVNGInputStream* WPXSvInputStream::getSubStreamByName(const char* name)
{
mpImpl->invalidateReadBuffer();
return mpImpl->getSubStreamByName(name);
}
-librevenge::RVNGInputStream *WPXSvInputStream::getSubStreamById(const unsigned id)
+librevenge::RVNGInputStream* WPXSvInputStream::getSubStreamById(const unsigned id)
{
mpImpl->invalidateReadBuffer();
return mpImpl->getSubStreamById(id);
}
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */