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

sw: store Outline Numbering as ODF fragment instead of SfxPoolItems

This should be less fragile and re-uses some xmloff and unocore code.

Storing from ~SwBaseNumRules() does not work because other gobals that
the export code relies on are already dead at the time it is called from
a terminate() listener, so store when the dialog updates a format.

Change-Id: I4e148b82d0a338ec7ffa6429c6e162db79f8c44e
üst 5c3cf76f
......@@ -37,7 +37,7 @@ class SvXMLExportItemMapper;
class SvXMLExport;
class XMLTextListAutoStylePool;
class SvxXMLNumRuleExport
class XMLOFF_DLLPUBLIC SvxXMLNumRuleExport
{
SvXMLExport& rExport;
const OUString sNumberingRules;
......@@ -49,12 +49,7 @@ class SvxXMLNumRuleExport
// to be suppressed on writing ODF 1.0 respectively ODF 1.1
bool mbExportPositionAndSpaceModeLabelAlignment;
void exportLevelStyles(
const ::com::sun::star::uno::Reference<
::com::sun::star::container::XIndexReplace > & xNumRule,
bool bOutline=false );
void exportLevelStyle(
SAL_DLLPRIVATE void exportLevelStyle(
sal_Int32 nLevel,
const ::com::sun::star::uno::Sequence<
::com::sun::star::beans::PropertyValue>& rProps,
......@@ -64,11 +59,11 @@ protected:
// This method may be overloaded to add attributes to the <list-style>
// element.
virtual void AddListStyleAttributes();
SAL_DLLPRIVATE virtual void AddListStyleAttributes();
bool exportStyle( const ::com::sun::star::uno::Reference<
SAL_DLLPRIVATE bool exportStyle( const ::com::sun::star::uno::Reference<
::com::sun::star::style::XStyle >& rStyle );
void exportOutline();
SAL_DLLPRIVATE void exportOutline();
SvXMLExport& GetExport() { return rExport; }
......@@ -77,6 +72,12 @@ public:
SvxXMLNumRuleExport( SvXMLExport& rExport );
virtual ~SvxXMLNumRuleExport();
// should be private but sw::StoredChapterNumberingExport needs it
void exportLevelStyles(
const ::com::sun::star::uno::Reference<
::com::sun::star::container::XIndexReplace > & xNumRule,
bool bOutline=false );
void exportStyles( bool bUsed,
XMLTextListAutoStylePool *pPool,
bool bExportChapterNumbering = true );
......
......@@ -30,7 +30,8 @@ class SvI18NMap;
class SvxXMLListLevelStyleContext_Impl;
typedef std::vector<SvxXMLListLevelStyleContext_Impl *> SvxXMLListStyle_Impl;
class SvxXMLListStyleContext : public SvXMLStyleContext
class XMLOFF_DLLPUBLIC SvxXMLListStyleContext
: public SvXMLStyleContext
{
const OUString sIsPhysical;
const OUString sNumberingRules;
......@@ -47,7 +48,7 @@ class SvxXMLListStyleContext : public SvXMLStyleContext
protected:
virtual void SetAttribute( sal_uInt16 nPrefixKey,
SAL_DLLPRIVATE virtual void SetAttribute( sal_uInt16 nPrefixKey,
const OUString& rLocalName,
const OUString& rValue ) SAL_OVERRIDE;
......
......@@ -574,6 +574,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/uibase/cctrl/popbox \
sw/source/uibase/cctrl/swlbox \
sw/source/uibase/chrdlg/ccoll \
sw/source/uibase/config/StoredChapterNumbering \
sw/source/uibase/config/barcfg \
sw/source/uibase/config/caption \
sw/source/uibase/config/cfgitems \
......
This diff is collapsed.
......@@ -63,7 +63,7 @@ SwBaseNumRules::SwBaseNumRules( const OUString& rFileName )
Init();
}
SwBaseNumRules::~SwBaseNumRules()
void SwBaseNumRules::Save()
{
if( bModified )
{
......@@ -78,14 +78,17 @@ SwBaseNumRules::~SwBaseNumRules()
bool bRet = (pStream && pStream->GetError() == 0);
if (bRet)
{
Store( *pStream );
sw::ExportStoredChapterNumberingRules(*this, *pStream, sFileName);
pStream->Flush();
aMedium.Commit();
}
}
}
SwBaseNumRules::~SwBaseNumRules()
{
for( sal_uInt16 i = 0; i < nMaxRules; ++i )
delete pNumRules[i];
}
......@@ -100,10 +103,17 @@ void SwBaseNumRules::Init()
if( aOpt.SearchFile( sNm, SvtPathOptions::PATH_USERCONFIG ))
{
SfxMedium aStrm( sNm, STREAM_STD_READ );
Load( *aStrm.GetInStream() );
sw::ImportStoredChapterNumberingRules(*this, *aStrm.GetInStream(), sFileName);
}
}
void SwBaseNumRules::CreateEmptyNumRule(sal_uInt16 const nIndex)
{
assert(nIndex < nMaxRules);
assert(!pNumRules[nIndex]);
pNumRules[nIndex] = new SwNumRulesWithName;
}
void SwBaseNumRules::ApplyNumRules(const SwNumRulesWithName &rCopy, sal_uInt16 nIdx)
{
OSL_ENSURE(nIdx < nMaxRules, "Array der NumRules ueberindiziert.");
......@@ -111,6 +121,7 @@ void SwBaseNumRules::ApplyNumRules(const SwNumRulesWithName &rCopy, sal_uInt16 n
pNumRules[nIdx] = new SwNumRulesWithName( rCopy );
else
*pNumRules[nIdx] = rCopy;
Save(); // store it immediately
}
bool SwBaseNumRules::Store(SvStream &rStream)
......@@ -191,6 +202,11 @@ SwNumRulesWithName::SwNumRulesWithName( const SwNumRule &rCopy,
}
}
SwNumRulesWithName::SwNumRulesWithName()
{
memset(aFmts, 0, sizeof(aFmts));
}
SwNumRulesWithName::SwNumRulesWithName( const SwNumRulesWithName& rCopy )
{
memset( aFmts, 0, sizeof( aFmts ));
......@@ -279,6 +295,23 @@ void SwNumRulesWithName::Store( SvStream &rStream )
}
}
void SwNumRulesWithName::GetNumFmt(
size_t const nIndex, SwNumFmt const*& rpNumFmt, OUString const*& rpName) const
{
rpNumFmt = (aFmts[nIndex]) ? &aFmts[nIndex]->aFmt : 0;
rpName = (aFmts[nIndex]) ? &aFmts[nIndex]->sCharFmtName : 0;
}
void SwNumRulesWithName::SetNumFmt(
size_t const nIndex, SwNumFmt const& rNumFmt, OUString const& rName)
{
delete aFmts[nIndex];
aFmts[nIndex] = new _SwNumFmtGlobal(rNumFmt);
aFmts[nIndex]->sCharFmtName = rName;
aFmts[nIndex]->nCharPoolId = USHRT_MAX;
aFmts[nIndex]->aItems.clear();
}
SwNumRulesWithName::_SwNumFmtGlobal::_SwNumFmtGlobal( const SwNumFmt& rFmt )
: aFmt( rFmt ), nCharPoolId( USHRT_MAX )
{
......
......@@ -27,6 +27,8 @@ class SfxPoolItem;
class SwWrtShell;
class SvStream;
namespace sw { class StoredChapterNumberingRules; }
#define MAX_NUM_RULES 9
typedef boost::ptr_vector<SfxPoolItem> _SwNumFmtsAttrs;
......@@ -38,6 +40,7 @@ class SW_DLLPUBLIC SwNumRulesWithName
// (They should always be there!)
class SAL_DLLPRIVATE _SwNumFmtGlobal
{
friend class SwNumRulesWithName;
SwNumFmt aFmt;
OUString sCharFmtName;
sal_uInt16 nCharPoolId;
......@@ -58,7 +61,11 @@ class SW_DLLPUBLIC SwNumRulesWithName
_SwNumFmtGlobal* aFmts[ MAXLEVEL ];
protected:
friend class sw::StoredChapterNumberingRules;
friend class SwBaseNumRules;
void SetName(const OUString& rSet) {maName = rSet;}
void SetNumFmt(size_t, SwNumFmt const&, OUString const&);
SwNumRulesWithName();
public:
SwNumRulesWithName(const SwNumRule &, const OUString &);
......@@ -72,6 +79,8 @@ public:
void MakeNumRule( SwWrtShell& rSh, SwNumRule& rChg ) const;
void Store( SvStream& );
void GetNumFmt(size_t, SwNumFmt const*&, OUString const*&) const;
};
class SwBaseNumRules
......@@ -88,12 +97,14 @@ protected:
virtual bool Store(SvStream&);
void Init();
void Save();
public:
SwBaseNumRules(const OUString& rFileName);
virtual ~SwBaseNumRules();
inline const SwNumRulesWithName* GetRules(sal_uInt16 nIdx) const;
void CreateEmptyNumRule(sal_uInt16 nIdx); // for import
virtual void ApplyNumRules(
const SwNumRulesWithName &rCopy,
sal_uInt16 nIdx);
......@@ -117,6 +128,17 @@ inline const SwNumRulesWithName *SwBaseNumRules::GetRules(sal_uInt16 nIdx) const
return pNumRules[nIdx];
}
namespace sw
{
void ExportStoredChapterNumberingRules(
SwBaseNumRules & rRules, SvStream & rStream, OUString const&);
void ImportStoredChapterNumberingRules(
SwBaseNumRules & rRules, SvStream & rStream, OUString const&);
} // namespace sw
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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