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