Kaydet (Commit) e377a65a authored tarafından Michael Stahl's avatar Michael Stahl

sw: remove pointless inheritance of SwChapterNumRules from SwBaseNumRules

Change-Id: I5426977d4ed5539d79335df0aa4bcccd71dd8966
üst f7c14f57
...@@ -91,13 +91,13 @@ IMPL_LINK_INLINE_END( SwNumNamesDlg, SelectHdl, ListBox *, pBox ) ...@@ -91,13 +91,13 @@ IMPL_LINK_INLINE_END( SwNumNamesDlg, SelectHdl, ListBox *, pBox )
void SwNumNamesDlg::SetUserNames(const OUString *pList[]) void SwNumNamesDlg::SetUserNames(const OUString *pList[])
{ {
sal_uInt16 nSelect = 0; sal_uInt16 nSelect = 0;
for(sal_uInt16 i = 0; i < SwBaseNumRules::nMaxRules; ++i) for (sal_uInt16 i = 0; i < SwChapterNumRules::nMaxRules; ++i)
{ {
if(pList[i]) if(pList[i])
{ {
m_pFormBox->RemoveEntry(i); m_pFormBox->RemoveEntry(i);
m_pFormBox->InsertEntry(*pList[i], i); m_pFormBox->InsertEntry(*pList[i], i);
if(i == nSelect && nSelect < SwBaseNumRules::nMaxRules) if (i == nSelect && nSelect < SwChapterNumRules::nMaxRules)
nSelect++; nSelect++;
} }
} }
......
...@@ -46,7 +46,7 @@ class StoredChapterNumberingRules ...@@ -46,7 +46,7 @@ class StoredChapterNumberingRules
{ {
private: private:
// TODO in case this ever becomes accessible via api need a invalidate // TODO in case this ever becomes accessible via api need a invalidate
SwBaseNumRules & m_rNumRules; SwChapterNumRules & m_rNumRules;
sal_uInt16 const m_nIndex; sal_uInt16 const m_nIndex;
SwNumRulesWithName * GetOrCreateRules() SwNumRulesWithName * GetOrCreateRules()
...@@ -63,11 +63,11 @@ private: ...@@ -63,11 +63,11 @@ private:
public: public:
StoredChapterNumberingRules( StoredChapterNumberingRules(
SwBaseNumRules & rNumRules, sal_uInt16 const nIndex) SwChapterNumRules & rNumRules, sal_uInt16 const nIndex)
: m_rNumRules(rNumRules) : m_rNumRules(rNumRules)
, m_nIndex(nIndex) , m_nIndex(nIndex)
{ {
assert(m_nIndex < SwBaseNumRules::nMaxRules); assert(m_nIndex < SwChapterNumRules::nMaxRules);
} }
// XNamed // XNamed
...@@ -324,13 +324,13 @@ class StoredChapterNumberingRootContext ...@@ -324,13 +324,13 @@ class StoredChapterNumberingRootContext
: public SvXMLImportContext : public SvXMLImportContext
{ {
private: private:
SwBaseNumRules & m_rNumRules; SwChapterNumRules & m_rNumRules;
size_t m_nCounter; size_t m_nCounter;
::std::vector<tools::SvRef<SvxXMLListStyleContext>> m_Contexts; ::std::vector<tools::SvRef<SvxXMLListStyleContext>> m_Contexts;
public: public:
StoredChapterNumberingRootContext( StoredChapterNumberingRootContext(
SwBaseNumRules & rNumRules, SvXMLImport & rImport, SwChapterNumRules & rNumRules, SvXMLImport & rImport,
sal_uInt16 const nPrefix, OUString const& rLocalName) sal_uInt16 const nPrefix, OUString const& rLocalName)
: SvXMLImportContext(rImport, nPrefix, rLocalName) : SvXMLImportContext(rImport, nPrefix, rLocalName)
, m_rNumRules(rNumRules) , m_rNumRules(rNumRules)
...@@ -340,7 +340,7 @@ public: ...@@ -340,7 +340,7 @@ public:
virtual void EndElement() SAL_OVERRIDE virtual void EndElement() SAL_OVERRIDE
{ {
assert(m_Contexts.size() < SwBaseNumRules::nMaxRules); assert(m_Contexts.size() < SwChapterNumRules::nMaxRules);
for (auto iter = m_Contexts.begin(); iter != m_Contexts.end(); ++iter) for (auto iter = m_Contexts.begin(); iter != m_Contexts.end(); ++iter)
{ {
uno::Reference<container::XIndexReplace> const xRule( uno::Reference<container::XIndexReplace> const xRule(
...@@ -360,7 +360,7 @@ public: ...@@ -360,7 +360,7 @@ public:
if (XML_NAMESPACE_TEXT == nPrefix && IsXMLToken(rLocalName, XML_OUTLINE_STYLE)) if (XML_NAMESPACE_TEXT == nPrefix && IsXMLToken(rLocalName, XML_OUTLINE_STYLE))
{ {
++m_nCounter; ++m_nCounter;
if (m_nCounter <= SwBaseNumRules::nMaxRules) if (m_nCounter <= SwChapterNumRules::nMaxRules)
{ {
SvxXMLListStyleContext *const pContext( SvxXMLListStyleContext *const pContext(
new SvxXMLListStyleContext(GetImport(), new SvxXMLListStyleContext(GetImport(),
...@@ -384,12 +384,12 @@ class StoredChapterNumberingImport ...@@ -384,12 +384,12 @@ class StoredChapterNumberingImport
: public SvXMLImport : public SvXMLImport
{ {
private: private:
SwBaseNumRules & m_rNumRules; SwChapterNumRules & m_rNumRules;
public: public:
StoredChapterNumberingImport( StoredChapterNumberingImport(
uno::Reference<uno::XComponentContext> const& xContext, uno::Reference<uno::XComponentContext> const& xContext,
SwBaseNumRules & rNumRules) SwChapterNumRules & rNumRules)
: SvXMLImport(xContext, "sw::StoredChapterNumberingImport", IMPORT_ALL) : SvXMLImport(xContext, "sw::StoredChapterNumberingImport", IMPORT_ALL)
, m_rNumRules(rNumRules) , m_rNumRules(rNumRules)
{ {
...@@ -408,7 +408,7 @@ public: ...@@ -408,7 +408,7 @@ public:
} }
}; };
void ExportStoredChapterNumberingRules(SwBaseNumRules & rRules, void ExportStoredChapterNumberingRules(SwChapterNumRules & rRules,
SvStream & rStream, OUString const& rFileName) SvStream & rStream, OUString const& rFileName)
{ {
uno::Reference<uno::XComponentContext> const xContext( uno::Reference<uno::XComponentContext> const xContext(
...@@ -432,7 +432,7 @@ void ExportStoredChapterNumberingRules(SwBaseNumRules & rRules, ...@@ -432,7 +432,7 @@ void ExportStoredChapterNumberingRules(SwBaseNumRules & rRules,
// ... and the import needs to map from name to display-name then! // ... and the import needs to map from name to display-name then!
std::set<OUString> charStyles; std::set<OUString> charStyles;
std::vector<uno::Reference<container::XIndexReplace>> numRules; std::vector<uno::Reference<container::XIndexReplace>> numRules;
for (size_t i = 0; i < SwBaseNumRules::nMaxRules; ++i) for (size_t i = 0; i < SwChapterNumRules::nMaxRules; ++i)
{ {
if (SwNumRulesWithName const* pRule = rRules.GetRules(i)) if (SwNumRulesWithName const* pRule = rRules.GetRules(i))
{ {
...@@ -461,7 +461,7 @@ void ExportStoredChapterNumberingRules(SwBaseNumRules & rRules, ...@@ -461,7 +461,7 @@ void ExportStoredChapterNumberingRules(SwBaseNumRules & rRules,
} }
} }
void ImportStoredChapterNumberingRules(SwBaseNumRules & rRules, void ImportStoredChapterNumberingRules(SwChapterNumRules & rRules,
SvStream & rStream, OUString const& rFileName) SvStream & rStream, OUString const& rFileName)
{ {
uno::Reference<uno::XComponentContext> const xContext( uno::Reference<uno::XComponentContext> const xContext(
......
...@@ -54,16 +54,16 @@ using namespace ::com::sun::star; ...@@ -54,16 +54,16 @@ using namespace ::com::sun::star;
An old rule at that position will be overwritten. An old rule at that position will be overwritten.
*/ */
SwBaseNumRules::SwBaseNumRules( const OUString& rFileName ) SwChapterNumRules::SwChapterNumRules()
: : sFileName(OUString(CHAPTER_FILENAME))
sFileName( rFileName ), ,
nVersion(0), nVersion(0),
bModified( false ) bModified( false )
{ {
Init(); Init();
} }
void SwBaseNumRules::Save() void SwChapterNumRules::Save()
{ {
if( bModified ) if( bModified )
{ {
...@@ -87,13 +87,13 @@ void SwBaseNumRules::Save() ...@@ -87,13 +87,13 @@ void SwBaseNumRules::Save()
} }
} }
SwBaseNumRules::~SwBaseNumRules() SwChapterNumRules::~SwChapterNumRules()
{ {
for( sal_uInt16 i = 0; i < nMaxRules; ++i ) for( sal_uInt16 i = 0; i < nMaxRules; ++i )
delete pNumRules[i]; delete pNumRules[i];
} }
void SwBaseNumRules::Init() void SwChapterNumRules::Init()
{ {
for(sal_uInt16 i = 0; i < nMaxRules; ++i ) for(sal_uInt16 i = 0; i < nMaxRules; ++i )
pNumRules[i] = 0; pNumRules[i] = 0;
...@@ -107,15 +107,16 @@ void SwBaseNumRules::Init() ...@@ -107,15 +107,16 @@ void SwBaseNumRules::Init()
} }
} }
void SwBaseNumRules::CreateEmptyNumRule(sal_uInt16 const nIndex) void SwChapterNumRules::CreateEmptyNumRule(sal_uInt16 const nIndex)
{ {
assert(nIndex < nMaxRules); assert(nIndex < nMaxRules);
assert(!pNumRules[nIndex]); assert(!pNumRules[nIndex]);
pNumRules[nIndex] = new SwNumRulesWithName; pNumRules[nIndex] = new SwNumRulesWithName;
} }
void SwBaseNumRules::ApplyNumRules(const SwNumRulesWithName &rCopy, sal_uInt16 nIdx) void SwChapterNumRules::ApplyNumRules(const SwNumRulesWithName &rCopy, sal_uInt16 nIdx)
{ {
bModified = true;
OSL_ENSURE(nIdx < nMaxRules, "Array der NumRules ueberindiziert."); OSL_ENSURE(nIdx < nMaxRules, "Array der NumRules ueberindiziert.");
if( !pNumRules[nIdx] ) if( !pNumRules[nIdx] )
pNumRules[nIdx] = new SwNumRulesWithName( rCopy ); pNumRules[nIdx] = new SwNumRulesWithName( rCopy );
...@@ -124,7 +125,7 @@ void SwBaseNumRules::ApplyNumRules(const SwNumRulesWithName &rCopy, sal_uInt16 n ...@@ -124,7 +125,7 @@ void SwBaseNumRules::ApplyNumRules(const SwNumRulesWithName &rCopy, sal_uInt16 n
Save(); // store it immediately Save(); // store it immediately
} }
bool SwBaseNumRules::Store(SvStream &rStream) bool SwChapterNumRules::Store(SvStream &rStream)
{ {
rStream.WriteUInt16( ACT_NUM_VERSION ); rStream.WriteUInt16( ACT_NUM_VERSION );
// Write, what positions are occupied by a rule // Write, what positions are occupied by a rule
...@@ -142,7 +143,7 @@ bool SwBaseNumRules::Store(SvStream &rStream) ...@@ -142,7 +143,7 @@ bool SwBaseNumRules::Store(SvStream &rStream)
return true; return true;
} }
int SwBaseNumRules::Load(SvStream &rStream) int SwChapterNumRules::Load(SvStream &rStream)
{ {
int rc = 0; int rc = 0;
...@@ -173,21 +174,6 @@ int SwBaseNumRules::Load(SvStream &rStream) ...@@ -173,21 +174,6 @@ int SwBaseNumRules::Load(SvStream &rStream)
return rc; return rc;
} }
SwChapterNumRules::SwChapterNumRules() :
SwBaseNumRules(OUString(CHAPTER_FILENAME))
{
}
SwChapterNumRules::~SwChapterNumRules()
{
}
void SwChapterNumRules::ApplyNumRules(const SwNumRulesWithName &rCopy, sal_uInt16 nIdx)
{
bModified = true;
SwBaseNumRules::ApplyNumRules(rCopy, nIdx);
}
SwNumRulesWithName::SwNumRulesWithName( const SwNumRule &rCopy, SwNumRulesWithName::SwNumRulesWithName( const SwNumRule &rCopy,
const OUString &rName ) const OUString &rName )
: maName(rName) : maName(rName)
......
...@@ -62,7 +62,7 @@ class SW_DLLPUBLIC SwNumRulesWithName ...@@ -62,7 +62,7 @@ class SW_DLLPUBLIC SwNumRulesWithName
protected: protected:
friend class sw::StoredChapterNumberingRules; friend class sw::StoredChapterNumberingRules;
friend class SwBaseNumRules; friend class SwChapterNumRules;
void SetName(const OUString& rSet) {maName = rSet;} void SetName(const OUString& rSet) {maName = rSet;}
void SetNumFmt(size_t, SwNumFmt const&, OUString const&); void SetNumFmt(size_t, SwNumFmt const&, OUString const&);
SwNumRulesWithName(); SwNumRulesWithName();
...@@ -83,7 +83,7 @@ public: ...@@ -83,7 +83,7 @@ public:
void GetNumFmt(size_t, SwNumFmt const*&, OUString const*&) const; void GetNumFmt(size_t, SwNumFmt const*&, OUString const*&) const;
}; };
class SwBaseNumRules class SwChapterNumRules
{ {
public: public:
enum { nMaxRules = MAX_NUM_RULES }; // currently 9 defined forms enum { nMaxRules = MAX_NUM_RULES }; // currently 9 defined forms
...@@ -100,8 +100,8 @@ protected: ...@@ -100,8 +100,8 @@ protected:
void Save(); void Save();
public: public:
SwBaseNumRules(const OUString& rFileName); SwChapterNumRules();
virtual ~SwBaseNumRules(); virtual ~SwChapterNumRules();
inline const SwNumRulesWithName* GetRules(sal_uInt16 nIdx) const; inline const SwNumRulesWithName* GetRules(sal_uInt16 nIdx) const;
void CreateEmptyNumRule(sal_uInt16 nIdx); // for import void CreateEmptyNumRule(sal_uInt16 nIdx); // for import
...@@ -111,18 +111,7 @@ public: ...@@ -111,18 +111,7 @@ public:
}; };
class SwChapterNumRules : public SwBaseNumRules inline const SwNumRulesWithName *SwChapterNumRules::GetRules(sal_uInt16 nIdx) const
{
public:
SwChapterNumRules();
virtual ~SwChapterNumRules();
virtual void ApplyNumRules( const SwNumRulesWithName &rCopy,
sal_uInt16 nIdx) SAL_OVERRIDE;
};
inline const SwNumRulesWithName *SwBaseNumRules::GetRules(sal_uInt16 nIdx) const
{ {
OSL_ENSURE(nIdx < nMaxRules, "Array der NumRules ueberindiziert."); OSL_ENSURE(nIdx < nMaxRules, "Array der NumRules ueberindiziert.");
return pNumRules[nIdx]; return pNumRules[nIdx];
...@@ -133,9 +122,9 @@ namespace sw ...@@ -133,9 +122,9 @@ namespace sw
{ {
void ExportStoredChapterNumberingRules( void ExportStoredChapterNumberingRules(
SwBaseNumRules & rRules, SvStream & rStream, OUString const&); SwChapterNumRules & rRules, SvStream & rStream, OUString const&);
void ImportStoredChapterNumberingRules( void ImportStoredChapterNumberingRules(
SwBaseNumRules & rRules, SvStream & rStream, OUString const&); SwChapterNumRules & rRules, SvStream & rStream, OUString const&);
} // namespace sw } // namespace sw
......
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