summaryrefslogtreecommitdiff
path: root/writerperfect/source
diff options
context:
space:
mode:
authorLaurent Alonso <alonso@loria.fr>2011-10-28 13:15:55 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2011-10-28 15:18:24 +0200
commit50398808552c3c79c7c4a32e6c3e1ab96ec7d425 (patch)
tree6d78603935f09f92ab7ebc1f74d6ce6f97a0b3d0 /writerperfect/source
parent2a91e5bf2bce5ec932ac712e77e18b3efe2509a8 (diff)
Use shared_ptr to avoid leaks
Diffstat (limited to 'writerperfect/source')
-rw-r--r--writerperfect/source/filter/FilterInternal.cxx (renamed from writerperfect/source/filter/libwriterperfect_filter.cxx)9
-rw-r--r--writerperfect/source/filter/FilterInternal.hxx44
-rw-r--r--writerperfect/source/filter/FontStyle.cxx24
-rw-r--r--writerperfect/source/filter/FontStyle.hxx8
-rw-r--r--writerperfect/source/filter/ListStyle.hxx1
-rw-r--r--writerperfect/source/filter/OdgGenerator.cxx3
-rw-r--r--writerperfect/source/filter/OdtGenerator.cxx71
-rw-r--r--writerperfect/source/filter/SectionStyle.hxx1
-rw-r--r--writerperfect/source/filter/Style.hxx2
-rw-r--r--writerperfect/source/filter/TableStyle.hxx1
-rw-r--r--writerperfect/source/filter/TextRunStyle.cxx76
-rw-r--r--writerperfect/source/filter/TextRunStyle.hxx27
-rw-r--r--writerperfect/source/filter/libwriterperfect_filter.hxx48
13 files changed, 155 insertions, 160 deletions
diff --git a/writerperfect/source/filter/libwriterperfect_filter.cxx b/writerperfect/source/filter/FilterInternal.cxx
index db976efcabd8..898b9ce45538 100644
--- a/writerperfect/source/filter/libwriterperfect_filter.cxx
+++ b/writerperfect/source/filter/FilterInternal.cxx
@@ -1,5 +1,4 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* libwriterperfect_filter.hxx: define basic functions for libwriterperfect/fileter
+/* FilterInternal.hxx: define basic functions for libwriterperfect/fileter
*
* Copyright (C) 2002-2004 William Lachance (wrlach@gmail.com)
* Copyright (C) 2004 Net Integration Technologies, Inc. (http://www.net-itech.com)
@@ -29,7 +28,7 @@
#include <libwpd/WPXPropertyList.h>
-#include "libwriterperfect_filter.hxx"
+#include "FilterInternal.hxx"
WPXString propListToStyleKey(const WPXPropertyList &xPropList)
{
@@ -43,6 +42,4 @@ WPXString propListToStyleKey(const WPXPropertyList &xPropList)
}
return sKey;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+} \ No newline at end of file
diff --git a/writerperfect/source/filter/FilterInternal.hxx b/writerperfect/source/filter/FilterInternal.hxx
index eb8c6e6a879a..880ad2882612 100644
--- a/writerperfect/source/filter/FilterInternal.hxx
+++ b/writerperfect/source/filter/FilterInternal.hxx
@@ -23,17 +23,53 @@
#ifndef __FILTERINTERNAL_HXX__
#define __FILTERINTERNAL_HXX__
+#include <string.h> // for strcmp
+
+#include <libwpd/libwpd.h>
+#include <libwpd/WPXString.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// used by FontStyle.cxx
+#define IMP_DEFAULT_FONT_PITCH "variable"
+
+#if 0
+const double fDefaultSideMargin = 1.0; // inches
+const double fDefaultPageWidth = 8.5f; // inches (OOo required default: we will handle this later)
+const double fDefaultPageHeight = 11.0; // inches
+#endif
+
#ifdef DEBUG
#include <stdio.h>
#define WRITER_DEBUG_MSG(M) printf M
#else
#define WRITER_DEBUG_MSG(M)
#endif
-#include <libwpd/libwpd.h>
-const double fDefaultSideMargin = 1.0; // inches
-const double fDefaultPageWidth = 8.5f; // inches (OOo required default: we will handle this later)
-const double fDefaultPageHeight = 11.0; // inches
+#if defined(SHAREDPTR_TR1)
+#include <tr1/memory>
+using std::tr1::shared_ptr;
+#elif defined(SHAREDPTR_STD)
+#include <memory>
+using std::shared_ptr;
+#else
+#include <boost/shared_ptr.hpp>
+using boost::shared_ptr;
+#endif
+
+
+class WPXPropertyList;
+WPXString propListToStyleKey(const WPXPropertyList &xPropList);
+
+struct ltstr
+{
+ bool operator()(const WPXString &s1, const WPXString &s2) const
+ {
+ return strcmp(s1.cstr(), s2.cstr()) < 0;
+ }
+};
#endif
diff --git a/writerperfect/source/filter/FontStyle.cxx b/writerperfect/source/filter/FontStyle.cxx
index de1bd2ecb859..b2d0080bc243 100644
--- a/writerperfect/source/filter/FontStyle.cxx
+++ b/writerperfect/source/filter/FontStyle.cxx
@@ -25,8 +25,11 @@
/* "This product is not manufactured, approved, or supported by
* Corel Corporation or Corel Corporation Limited."
*/
+
+#include "FilterInternal.hxx"
+
#include "FontStyle.hxx"
-#include "WriterProperties.hxx"
+
#include "DocumentElement.hxx"
FontStyle::FontStyle(const char *psName, const char *psFontFamily) : Style(psName),
@@ -51,19 +54,14 @@ void FontStyle::write(OdfDocumentHandler *pHandler) const
void FontStyleManager::clean()
{
- for (std::map<WPXString, FontStyle *, ltstr>::iterator iter = mHash.begin();
- iter != mHash.end(); ++iter)
- {
- delete(iter->second);
- }
- mHash.clear();
+ mStyleHash.clear();
}
void FontStyleManager::writeFontsDeclaration(OdfDocumentHandler *pHandler) const
{
TagOpenElement("office:font-face-decls").write(pHandler);
- for (std::map<WPXString, FontStyle *, ltstr>::const_iterator iter = mHash.begin();
- iter != mHash.end(); ++iter)
+ std::map<WPXString, shared_ptr<FontStyle>, ltstr>::const_iterator iter;
+ for (iter = mStyleHash.begin(); iter != mStyleHash.end(); iter++)
{
(iter->second)->write(pHandler);
}
@@ -80,11 +78,13 @@ void FontStyleManager::writeFontsDeclaration(OdfDocumentHandler *pHandler) const
WPXString FontStyleManager::findOrAdd(const char *psFontFamily)
{
- std::map<WPXString, FontStyle *, ltstr>::const_iterator iter = mHash.find(psFontFamily);
- if (iter!=mHash.end()) return iter->second->getName();
+ std::map<WPXString, shared_ptr<FontStyle>, ltstr>::const_iterator iter =
+ mStyleHash.find(psFontFamily);
+ if (iter!=mStyleHash.end()) return psFontFamily;
// ok create a new font
- mHash[psFontFamily] = new FontStyle(psFontFamily, psFontFamily);
+ shared_ptr<FontStyle> font(new FontStyle(psFontFamily, psFontFamily));
+ mStyleHash[psFontFamily] = font;
return psFontFamily;
}
diff --git a/writerperfect/source/filter/FontStyle.hxx b/writerperfect/source/filter/FontStyle.hxx
index f58bdf6b7783..82efa7403bef 100644
--- a/writerperfect/source/filter/FontStyle.hxx
+++ b/writerperfect/source/filter/FontStyle.hxx
@@ -31,8 +31,9 @@
#include <libwpd/libwpd.h>
+#include "FilterInternal.hxx"
+
#include "Style.hxx"
-#include "WriterProperties.hxx"
class FontStyle : public Style
{
@@ -53,7 +54,7 @@ private:
class FontStyleManager : public StyleManager
{
public:
- FontStyleManager() : mHash() {}
+ FontStyleManager() : mStyleHash() {}
virtual ~FontStyleManager()
{
FontStyleManager::clean();
@@ -71,7 +72,8 @@ public:
protected:
- std::map<WPXString, FontStyle *, ltstr> mHash;
+ // style name -> SpanStyle
+ std::map<WPXString, shared_ptr<FontStyle>, ltstr> mStyleHash;
};
#endif
diff --git a/writerperfect/source/filter/ListStyle.hxx b/writerperfect/source/filter/ListStyle.hxx
index 68d314f25bc9..759057d42c1a 100644
--- a/writerperfect/source/filter/ListStyle.hxx
+++ b/writerperfect/source/filter/ListStyle.hxx
@@ -32,7 +32,6 @@
#define WP6_NUM_LIST_LEVELS 8 // see WP6FileStructure.h (we shouldn't need to reference this)
#include "Style.hxx"
-#include "WriterProperties.hxx"
class DocumentElement;
diff --git a/writerperfect/source/filter/OdgGenerator.cxx b/writerperfect/source/filter/OdgGenerator.cxx
index 2ead68de4e11..6b08af872a8c 100644
--- a/writerperfect/source/filter/OdgGenerator.cxx
+++ b/writerperfect/source/filter/OdgGenerator.cxx
@@ -25,12 +25,11 @@
* Corel Corporation or Corel Corporation Limited."
*/
-#include "libwriterperfect_filter.hxx"
+#include "FilterInternal.hxx"
#include "OdgGenerator.hxx"
#include "DocumentElement.hxx"
#include "OdfDocumentHandler.hxx"
-#include "FilterInternal.hxx"
#include "TextRunStyle.hxx"
#include "FontStyle.hxx"
#include <locale.h>
diff --git a/writerperfect/source/filter/OdtGenerator.cxx b/writerperfect/source/filter/OdtGenerator.cxx
index 95338036e225..7c1e19e2357a 100644
--- a/writerperfect/source/filter/OdtGenerator.cxx
+++ b/writerperfect/source/filter/OdtGenerator.cxx
@@ -35,7 +35,6 @@
#include <stack>
#include <string>
-#include "libwriterperfect_filter.hxx"
#include "OdtGenerator.hxx"
#include "DocumentElement.hxx"
#include "TextRunStyle.hxx"
@@ -45,7 +44,6 @@
#include "SectionStyle.hxx"
#include "TableStyle.hxx"
#include "FilterInternal.hxx"
-#include "WriterProperties.hxx"
#include "InternalHandler.hxx"
// the state we use for writing the final document
@@ -122,7 +120,6 @@ public:
OdfEmbeddedObject _findEmbeddedObjectHandler(const WPXString &mimeType);
- WPXInputStream *mpInput;
OdfDocumentHandler *mpHandler;
bool mbUsed; // whether or not it has been before (you can only use me once!)
@@ -185,7 +182,6 @@ public:
};
OdtGeneratorPrivate::OdtGeneratorPrivate(OdfDocumentHandler *pHandler, const OdfStreamType streamType) :
- mpInput(0),
mpHandler(pHandler),
mbUsed(false),
mWriterDocumentStates(),
@@ -966,28 +962,27 @@ void OdtGenerator::openTable(const WPXPropertyList &propList, const WPXPropertyL
void OdtGenerator::openTableRow(const WPXPropertyList &propList)
{
+ if (mpImpl->mWriterDocumentStates.top().mbInNote)
+ return;
if (!mpImpl->mpCurrentTableStyle)
{
WRITER_DEBUG_MSG(("OdtGenerator::openTableRow called with no table\n"));
return;
}
- if (!mpImpl->mWriterDocumentStates.top().mbInNote)
+ if (propList["libwpd:is-header-row"] && (propList["libwpd:is-header-row"]->getInt()))
{
- if (propList["libwpd:is-header-row"] && (propList["libwpd:is-header-row"]->getInt()))
- {
- mpImpl->mpCurrentContentElements->push_back(new TagOpenElement("table:table-header-rows"));
- mpImpl->mWriterDocumentStates.top().mbHeaderRow = true;
- }
+ mpImpl->mpCurrentContentElements->push_back(new TagOpenElement("table:table-header-rows"));
+ mpImpl->mWriterDocumentStates.top().mbHeaderRow = true;
+ }
- WPXString sTableRowStyleName;
- sTableRowStyleName.sprintf("%s.Row%i", mpImpl->mpCurrentTableStyle->getName().cstr(), mpImpl->mpCurrentTableStyle->getNumTableRowStyles());
- TableRowStyle *pTableRowStyle = new TableRowStyle(propList, sTableRowStyleName.cstr());
- mpImpl->mpCurrentTableStyle->addTableRowStyle(pTableRowStyle);
+ WPXString sTableRowStyleName;
+ sTableRowStyleName.sprintf("%s.Row%i", mpImpl->mpCurrentTableStyle->getName().cstr(), mpImpl->mpCurrentTableStyle->getNumTableRowStyles());
+ TableRowStyle *pTableRowStyle = new TableRowStyle(propList, sTableRowStyleName.cstr());
+ mpImpl->mpCurrentTableStyle->addTableRowStyle(pTableRowStyle);
- TagOpenElement *pTableRowOpenElement = new TagOpenElement("table:table-row");
- pTableRowOpenElement->addAttribute("table:style-name", sTableRowStyleName);
- mpImpl->mpCurrentContentElements->push_back(pTableRowOpenElement);
- }
+ TagOpenElement *pTableRowOpenElement = new TagOpenElement("table:table-row");
+ pTableRowOpenElement->addAttribute("table:style-name", sTableRowStyleName);
+ mpImpl->mpCurrentContentElements->push_back(pTableRowOpenElement);
}
void OdtGenerator::closeTableRow()
@@ -1005,31 +1000,31 @@ void OdtGenerator::closeTableRow()
void OdtGenerator::openTableCell(const WPXPropertyList &propList)
{
+ if (mpImpl->mWriterDocumentStates.top().mbInNote)
+ return;
if (!mpImpl->mpCurrentTableStyle)
{
WRITER_DEBUG_MSG(("OdtGenerator::openTableCell called with no table\n"));
return;
}
- if (!mpImpl->mWriterDocumentStates.top().mbInNote)
- {
- WPXString sTableCellStyleName;
- sTableCellStyleName.sprintf( "%s.Cell%i", mpImpl->mpCurrentTableStyle->getName().cstr(), mpImpl->mpCurrentTableStyle->getNumTableCellStyles());
- TableCellStyle *pTableCellStyle = new TableCellStyle(propList, sTableCellStyleName.cstr());
- mpImpl->mpCurrentTableStyle->addTableCellStyle(pTableCellStyle);
-
- TagOpenElement *pTableCellOpenElement = new TagOpenElement("table:table-cell");
- pTableCellOpenElement->addAttribute("table:style-name", sTableCellStyleName);
- if (propList["table:number-columns-spanned"])
- pTableCellOpenElement->addAttribute("table:number-columns-spanned",
- propList["table:number-columns-spanned"]->getStr().cstr());
- if (propList["table:number-rows-spanned"])
- pTableCellOpenElement->addAttribute("table:number-rows-spanned",
- propList["table:number-rows-spanned"]->getStr().cstr());
- // pTableCellOpenElement->addAttribute("table:value-type", "string");
- mpImpl->mpCurrentContentElements->push_back(pTableCellOpenElement);
-
- mpImpl->mWriterDocumentStates.top().mbTableCellOpened = true;
- }
+
+ WPXString sTableCellStyleName;
+ sTableCellStyleName.sprintf( "%s.Cell%i", mpImpl->mpCurrentTableStyle->getName().cstr(), mpImpl->mpCurrentTableStyle->getNumTableCellStyles());
+ TableCellStyle *pTableCellStyle = new TableCellStyle(propList, sTableCellStyleName.cstr());
+ mpImpl->mpCurrentTableStyle->addTableCellStyle(pTableCellStyle);
+
+ TagOpenElement *pTableCellOpenElement = new TagOpenElement("table:table-cell");
+ pTableCellOpenElement->addAttribute("table:style-name", sTableCellStyleName);
+ if (propList["table:number-columns-spanned"])
+ pTableCellOpenElement->addAttribute("table:number-columns-spanned",
+ propList["table:number-columns-spanned"]->getStr().cstr());
+ if (propList["table:number-rows-spanned"])
+ pTableCellOpenElement->addAttribute("table:number-rows-spanned",
+ propList["table:number-rows-spanned"]->getStr().cstr());
+ // pTableCellOpenElement->addAttribute("table:value-type", "string");
+ mpImpl->mpCurrentContentElements->push_back(pTableCellOpenElement);
+
+ mpImpl->mWriterDocumentStates.top().mbTableCellOpened = true;
}
void OdtGenerator::closeTableCell()
diff --git a/writerperfect/source/filter/SectionStyle.hxx b/writerperfect/source/filter/SectionStyle.hxx
index df9a57639c03..2efaef14cff5 100644
--- a/writerperfect/source/filter/SectionStyle.hxx
+++ b/writerperfect/source/filter/SectionStyle.hxx
@@ -31,7 +31,6 @@
#include <libwpd/WPXPropertyListVector.h>
#include "Style.hxx"
-#include "WriterProperties.hxx"
class SectionStyle : public Style
diff --git a/writerperfect/source/filter/Style.hxx b/writerperfect/source/filter/Style.hxx
index 2dd41a49b20d..0957e840ffcb 100644
--- a/writerperfect/source/filter/Style.hxx
+++ b/writerperfect/source/filter/Style.hxx
@@ -29,7 +29,7 @@
#ifndef _STYLE_H
#define _STYLE_H
#include <libwpd/libwpd.h>
-#include "libwriterperfect_filter.hxx"
+
#include "DocumentElement.hxx"
class TopLevelElementStyle
diff --git a/writerperfect/source/filter/TableStyle.hxx b/writerperfect/source/filter/TableStyle.hxx
index dd20f93b2996..5e81601cffd8 100644
--- a/writerperfect/source/filter/TableStyle.hxx
+++ b/writerperfect/source/filter/TableStyle.hxx
@@ -32,7 +32,6 @@
#include <vector>
#include "Style.hxx"
-#include "WriterProperties.hxx"
class DocumentElement;
class OdfDocumentHandler;
diff --git a/writerperfect/source/filter/TextRunStyle.cxx b/writerperfect/source/filter/TextRunStyle.cxx
index e3ef8bbe66d0..092d3a2df5a1 100644
--- a/writerperfect/source/filter/TextRunStyle.cxx
+++ b/writerperfect/source/filter/TextRunStyle.cxx
@@ -1,4 +1,3 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* TextRunStyle: Stores (and writes) paragraph/span-style-based information
* (e.g.: a paragraph might be bold) that is needed at the head of an OO
* document.
@@ -30,7 +29,6 @@
*/
#include "FilterInternal.hxx"
#include "TextRunStyle.hxx"
-#include "WriterProperties.hxx"
#include "DocumentElement.hxx"
#ifdef _MSC_VER
@@ -181,18 +179,14 @@ void SpanStyle::write(OdfDocumentHandler *pHandler) const
void ParagraphStyleManager::clean()
{
- for (std::map<WPXString, ParagraphStyle *, ltstr>::iterator iter = mHash.begin();
- iter != mHash.end(); ++iter)
- {
- delete(iter->second);
- }
- mHash.clear();
+ mNameHash.clear();
+ mStyleHash.clear();
}
void ParagraphStyleManager::write(OdfDocumentHandler *pHandler) const
{
- for (std::map<WPXString, ParagraphStyle *, ltstr>::const_iterator iter = mHash.begin();
- iter != mHash.end(); ++iter)
+ for (std::map<WPXString, shared_ptr<ParagraphStyle>, ltstr>::const_iterator iter = mStyleHash.begin();
+ iter != mStyleHash.end(); iter++)
{
if (strcmp(iter->second->getName().cstr(), "Standard") == 0)
continue;
@@ -200,7 +194,7 @@ void ParagraphStyleManager::write(OdfDocumentHandler *pHandler) const
}
}
-WPXString ParagraphStyleManager::getKey(WPXPropertyList const &xPropList, WPXPropertyListVector const &tabStops) const
+WPXString ParagraphStyleManager::getKey(const WPXPropertyList &xPropList, const WPXPropertyListVector &tabStops) const
{
WPXString sKey = propListToStyleKey(xPropList);
@@ -216,58 +210,70 @@ WPXString ParagraphStyleManager::getKey(WPXPropertyList const &xPropList, WPXPro
return sKey;
}
-WPXString ParagraphStyleManager::findOrAdd(WPXPropertyList const &propList, WPXPropertyListVector const &tabStops)
+WPXString ParagraphStyleManager::findOrAdd(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops)
{
WPXString hashKey = getKey(propList, tabStops);
- std::map<WPXString, ParagraphStyle *, ltstr>::const_iterator iter = mHash.find(hashKey);
- if (iter!=mHash.end())
- return iter->second->getName();
+ std::map<WPXString, WPXString, ltstr>::const_iterator iter =
+ mNameHash.find(hashKey);
+ if (iter!=mNameHash.end()) return iter->second;
// ok create a new list
WRITER_DEBUG_MSG(("ParagraphStyleManager::findOrAdd: Paragraph Hash Key: %s\n", hashKey.cstr()));
WPXString sName;
- sName.sprintf("S%i", mHash.size());
- ParagraphStyle *pStyle =
- new ParagraphStyle(propList, tabStops, sName);
- mHash[hashKey] = pStyle;
+ sName.sprintf("S%i", mStyleHash.size());
+ shared_ptr<ParagraphStyle> parag(new ParagraphStyle(propList, tabStops, sName));
+ mStyleHash[sName] =parag;
+ mNameHash[hashKey] = sName;
return sName;
}
+shared_ptr<ParagraphStyle> const ParagraphStyleManager::get(const WPXString &name) const
+{
+ std::map<WPXString, shared_ptr<ParagraphStyle>, ltstr>::const_iterator iter
+ = mStyleHash.find(name);
+ if (iter == mStyleHash.end()) return shared_ptr<ParagraphStyle>();
+ return iter->second;
+}
+
void SpanStyleManager::clean()
{
- for (std::map<WPXString, SpanStyle *, ltstr>::iterator iter = mHash.begin();
- iter != mHash.end(); ++iter)
- {
- delete(iter->second);
- }
- mHash.clear();
+ mNameHash.clear();
+ mStyleHash.clear();
}
void SpanStyleManager::write(OdfDocumentHandler *pHandler) const
{
- for (std::map<WPXString, SpanStyle *, ltstr>::const_iterator iter = mHash.begin();
- iter != mHash.end(); ++iter)
+ for (std::map<WPXString, shared_ptr<SpanStyle>, ltstr>::const_iterator iter = mStyleHash.begin();
+ iter != mStyleHash.end(); iter++)
{
(iter->second)->write(pHandler);
}
}
-WPXString SpanStyleManager::findOrAdd(WPXPropertyList const &propList)
+WPXString SpanStyleManager::findOrAdd(const WPXPropertyList &propList)
{
WPXString hashKey = propListToStyleKey(propList);
- std::map<WPXString, SpanStyle *, ltstr>::const_iterator iter = mHash.find(hashKey);
- if (iter!=mHash.end())
- return iter->second->getName();
+ std::map<WPXString, WPXString, ltstr>::const_iterator iter =
+ mNameHash.find(hashKey);
+ if (iter!=mNameHash.end()) return iter->second;
// ok create a new list
WRITER_DEBUG_MSG(("SpanStyleManager::findOrAdd: Span Hash Key: %s\n", hashKey.cstr()));
WPXString sName;
- sName.sprintf("Span%i", mHash.size());
- SpanStyle *pStyle = new SpanStyle(sName.cstr(), propList);
- mHash[hashKey] = pStyle;
+ sName.sprintf("Span%i", mStyleHash.size());
+ shared_ptr<SpanStyle> span(new SpanStyle(sName.cstr(), propList));
+ mStyleHash[sName] = span;
+ mNameHash[hashKey] = sName;
return sName;
}
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+shared_ptr<SpanStyle> const SpanStyleManager::get(const WPXString &name) const
+{
+ std::map<WPXString, shared_ptr<SpanStyle>, ltstr>::const_iterator iter
+ = mStyleHash.find(name);
+ if (iter == mStyleHash.end()) return shared_ptr<SpanStyle>();
+ return iter->second;
+}
+
diff --git a/writerperfect/source/filter/TextRunStyle.hxx b/writerperfect/source/filter/TextRunStyle.hxx
index 0ae670dca2d0..98fc6b40b352 100644
--- a/writerperfect/source/filter/TextRunStyle.hxx
+++ b/writerperfect/source/filter/TextRunStyle.hxx
@@ -35,6 +35,8 @@
#include <libwpd/libwpd.h>
+#include "FilterInternal.hxx"
+
#include "Style.hxx"
class TagOpenElement;
@@ -71,7 +73,7 @@ private:
class ParagraphStyleManager : public StyleManager
{
public:
- ParagraphStyleManager() : mHash() {}
+ ParagraphStyleManager() : mNameHash(), mStyleHash() {}
virtual ~ParagraphStyleManager()
{
ParagraphStyleManager::clean();
@@ -82,22 +84,27 @@ public:
Note: using S%i as new name*/
WPXString findOrAdd(const WPXPropertyList &xPropList, const WPXPropertyListVector &tabStops);
+ /* returns the style corresponding to a given name ( if it exists ) */
+ shared_ptr<ParagraphStyle> const get(const WPXString &name) const;
+
virtual void clean();
virtual void write(OdfDocumentHandler *) const;
protected:
// return a unique key
- WPXString getKey(WPXPropertyList const &xPropList, WPXPropertyListVector const &tabStops) const;
+ WPXString getKey(const WPXPropertyList &xPropList, const WPXPropertyListVector &tabStops) const;
- // paragraph styles
- std::map<WPXString, ParagraphStyle *, ltstr> mHash;
+ // hash key -> name
+ std::map<WPXString, WPXString, ltstr> mNameHash;
+ // style name -> paragraph style
+ std::map<WPXString, shared_ptr<ParagraphStyle>, ltstr> mStyleHash;
};
class SpanStyleManager : public StyleManager
{
public:
- SpanStyleManager() : mHash() {}
+ SpanStyleManager() : mNameHash(), mStyleHash() {}
virtual ~SpanStyleManager()
{
SpanStyleManager::clean();
@@ -106,15 +113,19 @@ public:
/* create a new style if it does not exists. In all case, returns the name of the style
Note: using Span%i as new name*/
- WPXString findOrAdd(WPXPropertyList const &xPropList);
+ WPXString findOrAdd(const WPXPropertyList &xPropList);
+ /* returns the style corresponding to a given name ( if it exists ) */
+ shared_ptr<SpanStyle> const get(const WPXString &name) const;
virtual void clean();
virtual void write(OdfDocumentHandler *) const;
protected:
- // span styles
- std::map<WPXString, SpanStyle *, ltstr> mHash;
+ // hash key -> style name
+ std::map<WPXString, WPXString, ltstr> mNameHash;
+ // style name -> SpanStyle
+ std::map<WPXString, shared_ptr<SpanStyle>, ltstr> mStyleHash;
};
#endif
diff --git a/writerperfect/source/filter/libwriterperfect_filter.hxx b/writerperfect/source/filter/libwriterperfect_filter.hxx
deleted file mode 100644
index f99026cb6d0c..000000000000
--- a/writerperfect/source/filter/libwriterperfect_filter.hxx
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* libwriterperfect_filter.hxx: define basic functions for libwriterperfect/fileter
- *
- * Copyright (C) 2002-2003 William Lachance (wrlach@gmail.com)
- * Copyright (C) 2004 Fridrich Strba (fridrich.strba@bluewin.ch)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * For further information visit http://libwpd.sourceforge.net
- *
- */
-
-/* "This product is not manufactured, approved, or supported by
- * Corel Corporation or Corel Corporation Limited."
- */
-
-#ifndef _LIBWRITERPERFECT_FILTER_H
-#define _LIBWRITERPERFECT_FILTER_H
-#include <string.h> // for strcmp
-
-#include <libwpd/libwpd.h>
-#include <libwpd/WPXString.h>
-
-WPXString propListToStyleKey(const WPXPropertyList &xPropList);
-
-struct ltstr
-{
- bool operator()(const WPXString &s1, const WPXString &s2) const
- {
- return strcmp(s1.cstr(), s2.cstr()) < 0;
- }
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */