summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-02-10 13:48:36 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-02-13 08:17:42 +0200
commite14aab54bdfec517aabea2c7afb5b36bd6ebc36b (patch)
treeb871ae57c7144d273abda0591a298a91d7e72f92 /sw
parentf052855343430327d3f92a66e14e9a445ee5fa0a (diff)
convert Master_CollConditions to scoped enum
And drop read-only enumerator USRFLD_EXPRESSION. And drop the bitfield values, this enum is never used as a combination of flags. Change-Id: Iaae1b30439a7d1bb5d3526d9aee52dbc78e635dc
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/ccoll.hxx4
-rw-r--r--sw/inc/fmtcol.hxx46
-rw-r--r--sw/source/core/doc/fmtcol.cxx67
-rw-r--r--sw/source/core/docnode/node.cxx30
-rw-r--r--sw/source/filter/xml/xmlfmt.cxx43
-rw-r--r--sw/source/uibase/chrdlg/ccoll.cxx56
6 files changed, 101 insertions, 145 deletions
diff --git a/sw/inc/ccoll.hxx b/sw/inc/ccoll.hxx
index f5bc84274b48..d2d02a99ded3 100644
--- a/sw/inc/ccoll.hxx
+++ b/sw/inc/ccoll.hxx
@@ -30,11 +30,13 @@
#include "swdllapi.h"
#include "cmdid.h"
+enum class Master_CollCondition;
+
#define COND_COMMAND_COUNT 28
struct CommandStruct
{
- sal_uLong nCnd;
+ Master_CollCondition nCnd;
sal_uLong nSubCond;
};
diff --git a/sw/inc/fmtcol.hxx b/sw/inc/fmtcol.hxx
index 78688f02e528..da393086e662 100644
--- a/sw/inc/fmtcol.hxx
+++ b/sw/inc/fmtcol.hxx
@@ -155,37 +155,31 @@ public:
// FEATURE::CONDCOLL
/// Conditional styles.
-enum Master_CollConditions
+enum class Master_CollCondition
{
- PARA_IN_LIST = 0x0001,
- PARA_IN_OUTLINE = 0x0002,
- PARA_IN_FRAME = 0x0004,
- PARA_IN_TABLEHEAD = 0x0008,
- PARA_IN_TABLEBODY = 0x0010,
- PARA_IN_SECTION = 0x0020,
- PARA_IN_FOOTENOTE = 0x0040,
- PARA_IN_FOOTER = 0x0080,
- PARA_IN_HEADER = 0x0100,
- PARA_IN_ENDNOTE = 0x0200,
-
- USRFLD_EXPRESSION = (int)0x8000
+ NONE,
+ PARA_IN_LIST,
+ PARA_IN_OUTLINE,
+ PARA_IN_FRAME,
+ PARA_IN_TABLEHEAD,
+ PARA_IN_TABLEBODY,
+ PARA_IN_SECTION,
+ PARA_IN_FOOTENOTE,
+ PARA_IN_FOOTER,
+ PARA_IN_HEADER,
+ PARA_IN_ENDNOTE
};
class SW_DLLPUBLIC SwCollCondition : public SwClient
{
- sal_uLong m_nCondition;
- union
- {
- sal_uLong nSubCondition;
- OUString* pFieldExpression;
- } m_aSubCondition;
+ Master_CollCondition m_nCondition;
+ sal_uLong m_nSubCondition;
public:
- SwCollCondition( SwTextFormatColl* pColl, sal_uLong nMasterCond,
+ SwCollCondition( SwTextFormatColl* pColl, Master_CollCondition nMasterCond,
sal_uLong nSubCond );
- SwCollCondition( SwTextFormatColl* pColl, sal_uLong nMasterCond,
- const OUString& rSubExp );
+ SwCollCondition( SwTextFormatColl* pColl, Master_CollCondition nMasterCond );
virtual ~SwCollCondition() override;
/// @@@ public copy ctor, but no copy assignment?
@@ -197,12 +191,10 @@ public:
bool operator==( const SwCollCondition& rCmp ) const;
- sal_uLong GetCondition() const { return m_nCondition; }
- sal_uLong GetSubCondition() const { return m_aSubCondition.nSubCondition; }
- const OUString* GetFieldExpression() const
- { return m_aSubCondition.pFieldExpression; }
+ Master_CollCondition GetCondition() const { return m_nCondition; }
+ sal_uLong GetSubCondition() const { return m_nSubCondition; }
- void SetCondition( sal_uLong nCond, sal_uLong nSubCond );
+ void SetCondition( Master_CollCondition nCond, sal_uLong nSubCond );
SwTextFormatColl* GetTextFormatColl() const { return const_cast<SwTextFormatColl*>(static_cast<const SwTextFormatColl*>(GetRegisteredIn())); }
void RegisterToFormat( SwFormat& );
};
diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx
index 27a6c39f47cc..b5d789fdef24 100644
--- a/sw/source/core/doc/fmtcol.cxx
+++ b/sw/source/core/doc/fmtcol.cxx
@@ -477,36 +477,28 @@ void SwTextFormatColls::dumpAsXml(xmlTextWriterPtr pWriter) const
//FEATURE::CONDCOLL
-SwCollCondition::SwCollCondition( SwTextFormatColl* pColl, sal_uLong nMasterCond,
+SwCollCondition::SwCollCondition( SwTextFormatColl* pColl, Master_CollCondition nMasterCond,
sal_uLong nSubCond )
- : SwClient( pColl ), m_nCondition( nMasterCond )
+ : SwClient( pColl ), m_nCondition( nMasterCond ),
+ m_nSubCondition( nSubCond )
{
- m_aSubCondition.nSubCondition = nSubCond;
}
-SwCollCondition::SwCollCondition( SwTextFormatColl* pColl, sal_uLong nMasterCond,
- const OUString& rSubExp )
- : SwClient( pColl ), m_nCondition( nMasterCond )
+SwCollCondition::SwCollCondition( SwTextFormatColl* pColl, Master_CollCondition nMasterCond )
+ : SwClient( pColl ), m_nCondition( nMasterCond ),
+ m_nSubCondition( 0 )
{
- if( USRFLD_EXPRESSION & m_nCondition )
- m_aSubCondition.pFieldExpression = new OUString( rSubExp );
- else
- m_aSubCondition.nSubCondition = 0;
}
SwCollCondition::SwCollCondition( const SwCollCondition& rCopy )
- : SwClient( const_cast<SwModify*>(rCopy.GetRegisteredIn()) ), m_nCondition( rCopy.m_nCondition )
+ : SwClient( const_cast<SwModify*>(rCopy.GetRegisteredIn()) ),
+ m_nCondition( rCopy.m_nCondition ),
+ m_nSubCondition( rCopy.m_nSubCondition )
{
- if( USRFLD_EXPRESSION & rCopy.m_nCondition )
- m_aSubCondition.pFieldExpression = new OUString( *rCopy.GetFieldExpression() );
- else
- m_aSubCondition.nSubCondition = rCopy.m_aSubCondition.nSubCondition;
}
SwCollCondition::~SwCollCondition()
{
- if( USRFLD_EXPRESSION & m_nCondition )
- delete m_aSubCondition.pFieldExpression;
}
void SwCollCondition::RegisterToFormat( SwFormat& rFormat )
@@ -516,41 +508,14 @@ void SwCollCondition::RegisterToFormat( SwFormat& rFormat )
bool SwCollCondition::operator==( const SwCollCondition& rCmp ) const
{
- bool bRet = false;
- if( m_nCondition == rCmp.m_nCondition )
- {
- if( USRFLD_EXPRESSION & m_nCondition )
- {
- // The SubCondition contains the expression for the UserField
- const OUString* pTmp = m_aSubCondition.pFieldExpression;
- if( !pTmp )
- pTmp = rCmp.m_aSubCondition.pFieldExpression;
- if( pTmp )
- {
- SwTextFormatColl* pColl = GetTextFormatColl();
- if( !pColl )
- pColl = rCmp.GetTextFormatColl();
-
- if( pColl )
- {
- SwCalc aCalc( *pColl->GetDoc() );
- bRet = aCalc.Calculate( *pTmp ).GetBool();
- }
- }
- }
- else if( m_aSubCondition.nSubCondition ==
- rCmp.m_aSubCondition.nSubCondition )
- bRet = true;
- }
- return bRet;
+ return ( m_nCondition == rCmp.m_nCondition )
+ && ( m_nSubCondition == rCmp.m_nSubCondition );
}
-void SwCollCondition::SetCondition( sal_uLong nCond, sal_uLong nSubCond )
+void SwCollCondition::SetCondition( Master_CollCondition nCond, sal_uLong nSubCond )
{
- if( USRFLD_EXPRESSION & m_nCondition )
- delete m_aSubCondition.pFieldExpression;
m_nCondition = nCond;
- m_aSubCondition.nSubCondition = nSubCond;
+ m_nSubCondition = nSubCond;
}
SwConditionTextFormatColl::~SwConditionTextFormatColl()
@@ -610,11 +575,7 @@ void SwConditionTextFormatColl::SetConditions( const SwFormatCollConditions& rCn
? rDoc.CopyTextColl( *rpFnd->GetTextFormatColl() )
: nullptr;
std::unique_ptr<SwCollCondition> pNew;
- if (USRFLD_EXPRESSION & rpFnd->GetCondition())
- pNew.reset(new SwCollCondition( pTmpColl, rpFnd->GetCondition(),
- *rpFnd->GetFieldExpression() ));
- else
- pNew.reset(new SwCollCondition( pTmpColl, rpFnd->GetCondition(),
+ pNew.reset(new SwCollCondition( pTmpColl, rpFnd->GetCondition(),
rpFnd->GetSubCondition() ));
m_CondColls.push_back( std::move(pNew) );
}
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index fa98422c937b..31a68ef8d405 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -1810,33 +1810,33 @@ bool SwContentNode::IsAnyCondition( SwCollCondition& rTmp ) const
{
const SwNodes& rNds = GetNodes();
{
- int nCond = 0;
+ Master_CollCondition nCond = Master_CollCondition::NONE;
const SwStartNode* pSttNd = StartOfSectionNode();
while( pSttNd )
{
switch( pSttNd->GetNodeType() )
{
- case SwNodeType::Table: nCond = PARA_IN_TABLEBODY; break;
- case SwNodeType::Section: nCond = PARA_IN_SECTION; break;
+ case SwNodeType::Table: nCond = Master_CollCondition::PARA_IN_TABLEBODY; break;
+ case SwNodeType::Section: nCond = Master_CollCondition::PARA_IN_SECTION; break;
default:
switch( pSttNd->GetStartNodeType() )
{
case SwTableBoxStartNode:
{
- nCond = PARA_IN_TABLEBODY;
+ nCond = Master_CollCondition::PARA_IN_TABLEBODY;
const SwTableNode* pTableNd = pSttNd->FindTableNode();
const SwTableBox* pBox;
if( pTableNd && nullptr != ( pBox = pTableNd->GetTable().
GetTableBox( pSttNd->GetIndex() ) ) && pBox &&
pBox->IsInHeadline( &pTableNd->GetTable() ) )
- nCond = PARA_IN_TABLEHEAD;
+ nCond = Master_CollCondition::PARA_IN_TABLEHEAD;
}
break;
- case SwFlyStartNode: nCond = PARA_IN_FRAME; break;
+ case SwFlyStartNode: nCond = Master_CollCondition::PARA_IN_FRAME; break;
case SwFootnoteStartNode:
{
- nCond = PARA_IN_FOOTENOTE;
+ nCond = Master_CollCondition::PARA_IN_FOOTENOTE;
const SwFootnoteIdxs& rFootnoteArr = rNds.GetDoc()->GetFootnoteIdxs();
const SwTextFootnote* pTextFootnote;
const SwNode* pSrchNd = pSttNd;
@@ -1846,20 +1846,20 @@ bool SwContentNode::IsAnyCondition( SwCollCondition& rTmp ) const
pSrchNd == &pTextFootnote->GetStartNode()->GetNode() )
{
if( pTextFootnote->GetFootnote().IsEndNote() )
- nCond = PARA_IN_ENDNOTE;
+ nCond = Master_CollCondition::PARA_IN_ENDNOTE;
break;
}
}
break;
- case SwHeaderStartNode: nCond = PARA_IN_HEADER; break;
- case SwFooterStartNode: nCond = PARA_IN_FOOTER; break;
+ case SwHeaderStartNode: nCond = Master_CollCondition::PARA_IN_HEADER; break;
+ case SwFooterStartNode: nCond = Master_CollCondition::PARA_IN_FOOTER; break;
case SwNormalStartNode: break;
}
}
- if( nCond )
+ if( nCond != Master_CollCondition::NONE )
{
- rTmp.SetCondition( (Master_CollConditions)nCond, 0 );
+ rTmp.SetCondition( nCond, 0 );
return true;
}
pSttNd = pSttNd->GetIndex()
@@ -1882,7 +1882,7 @@ bool SwContentNode::IsAnyCondition( SwCollCondition& rTmp ) const
if( pOutlNd->IsOutline())
{
- rTmp.SetCondition( PARA_IN_OUTLINE, pOutlNd->GetAttrOutlineLevel() - 1 );
+ rTmp.SetCondition( Master_CollCondition::PARA_IN_OUTLINE, pOutlNd->GetAttrOutlineLevel() - 1 );
return true;
}
}
@@ -1897,7 +1897,7 @@ void SwContentNode::ChkCondColl()
// Check, just to be sure
if( RES_CONDTXTFMTCOLL == GetFormatColl()->Which() )
{
- SwCollCondition aTmp( nullptr, 0, 0 );
+ SwCollCondition aTmp( nullptr, Master_CollCondition::NONE, 0 );
const SwCollCondition* pCColl;
bool bDone = false;
@@ -1919,7 +1919,7 @@ void SwContentNode::ChkCondColl()
if( IsTextNode() && static_cast<SwTextNode*>(this)->GetNumRule())
{
// Is at which Level in a list?
- aTmp.SetCondition( PARA_IN_LIST,
+ aTmp.SetCondition( Master_CollCondition::PARA_IN_LIST,
static_cast<SwTextNode*>(this)->GetActualListLevel() );
pCColl = static_cast<SwConditionTextFormatColl*>(GetFormatColl())->
HasCondition( aTmp );
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
index fbe0ff77878b..fdcd4e48c333 100644
--- a/sw/source/filter/xml/xmlfmt.cxx
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -61,7 +61,7 @@ class SwXMLConditionParser_Impl
{
OUString sInput;
- sal_uInt32 nCondition;
+ Master_CollCondition nCondition;
sal_uInt32 nSubCondition;
sal_Int32 nPos;
@@ -76,9 +76,9 @@ public:
explicit SwXMLConditionParser_Impl( const OUString& rInp );
- bool IsValid() const { return 0 != nCondition; }
+ bool IsValid() const { return Master_CollCondition::NONE != nCondition; }
- sal_uInt32 GetCondition() const { return nCondition; }
+ Master_CollCondition GetCondition() const { return nCondition; }
sal_uInt32 GetSubCondition() const { return nSubCondition; }
};
@@ -131,7 +131,7 @@ inline bool SwXMLConditionParser_Impl::MatchNumber( sal_uInt32& rNumber )
SwXMLConditionParser_Impl::SwXMLConditionParser_Impl( const OUString& rInp ) :
sInput( rInp ),
- nCondition( 0 ),
+ nCondition( Master_CollCondition::NONE ),
nSubCondition( 0 ),
nPos( 0 ),
nLength( rInp.getLength() )
@@ -152,47 +152,47 @@ SwXMLConditionParser_Impl::SwXMLConditionParser_Impl( const OUString& rInp ) :
if( bOK )
{
if( IsXMLToken( sFunc, XML_ENDNOTE ) && !bHasSub )
- nCondition = PARA_IN_ENDNOTE;
+ nCondition = Master_CollCondition::PARA_IN_ENDNOTE;
else if( IsXMLToken( sFunc, XML_FOOTER ) && !bHasSub )
- nCondition = PARA_IN_FOOTER;
+ nCondition = Master_CollCondition::PARA_IN_FOOTER;
else if( IsXMLToken( sFunc, XML_FOOTNOTE ) && !bHasSub )
- nCondition = PARA_IN_FOOTENOTE;
+ nCondition = Master_CollCondition::PARA_IN_FOOTENOTE;
else if( IsXMLToken( sFunc, XML_HEADER ) && !bHasSub )
- nCondition = PARA_IN_HEADER;
+ nCondition = Master_CollCondition::PARA_IN_HEADER;
else if( IsXMLToken( sFunc, XML_LIST_LEVEL) &&
nSub >=1 && nSub <= MAXLEVEL )
{
- nCondition = PARA_IN_LIST;
+ nCondition = Master_CollCondition::PARA_IN_LIST;
nSubCondition = nSub-1;
}
else if( IsXMLToken( sFunc, XML_OUTLINE_LEVEL) &&
nSub >=1 && nSub <= MAXLEVEL )
{
- nCondition = PARA_IN_OUTLINE;
+ nCondition = Master_CollCondition::PARA_IN_OUTLINE;
nSubCondition = nSub-1;
}
else if( IsXMLToken( sFunc, XML_SECTION ) && !bHasSub )
{
- nCondition = PARA_IN_SECTION;
+ nCondition = Master_CollCondition::PARA_IN_SECTION;
}
else if( IsXMLToken( sFunc, XML_TABLE ) && !bHasSub )
{
- nCondition = PARA_IN_TABLEBODY;
+ nCondition = Master_CollCondition::PARA_IN_TABLEBODY;
}
else if( IsXMLToken( sFunc, XML_TABLE_HEADER ) && !bHasSub )
{
- nCondition = PARA_IN_TABLEHEAD;
+ nCondition = Master_CollCondition::PARA_IN_TABLEHEAD;
}
else if( IsXMLToken( sFunc, XML_TEXT_BOX ) && !bHasSub )
{
- nCondition = PARA_IN_FRAME;
+ nCondition = Master_CollCondition::PARA_IN_FRAME;
}
}
}
class SwXMLConditionContext_Impl : public SvXMLImportContext
{
- sal_uInt32 nCondition;
+ Master_CollCondition nCondition;
sal_uInt32 nSubCondition;
OUString sApplyStyle;
@@ -204,7 +204,7 @@ public:
const OUString& rLName,
const uno::Reference< xml::sax::XAttributeList > & xAttrList );
- bool IsValid() const { return 0 != nCondition; }
+ bool IsValid() const { return Master_CollCondition::NONE != nCondition; }
};
SwXMLConditionContext_Impl::SwXMLConditionContext_Impl(
@@ -212,7 +212,7 @@ SwXMLConditionContext_Impl::SwXMLConditionContext_Impl(
const OUString& rLName,
const uno::Reference< xml::sax::XAttributeList > & xAttrList ) :
SvXMLImportContext( rImport, nPrfx, rLName ),
- nCondition( 0 ),
+ nCondition( Master_CollCondition::NONE ),
nSubCondition( 0 )
{
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
@@ -945,12 +945,13 @@ void SwXMLImport::UpdateTextCollConditions( SwDoc *pDoc )
const SwCollCondition& rCond = *rConditions[j];
switch( rCond.GetCondition() )
{
- case PARA_IN_TABLEHEAD:
- case PARA_IN_TABLEBODY:
- case PARA_IN_FOOTER:
- case PARA_IN_HEADER:
+ case Master_CollCondition::PARA_IN_TABLEHEAD:
+ case Master_CollCondition::PARA_IN_TABLEBODY:
+ case Master_CollCondition::PARA_IN_FOOTER:
+ case Master_CollCondition::PARA_IN_HEADER:
bSendModify = true;
break;
+ default: break;
}
}
if( bSendModify )
diff --git a/sw/source/uibase/chrdlg/ccoll.cxx b/sw/source/uibase/chrdlg/ccoll.cxx
index 5bcac8fdb9c2..f2ab69ead456 100644
--- a/sw/source/uibase/chrdlg/ccoll.cxx
+++ b/sw/source/uibase/chrdlg/ccoll.cxx
@@ -99,34 +99,34 @@ OUString GetCommandContextByIndex( sal_Int16 nIndex )
const CommandStruct SwCondCollItem::aCmds[] =
{
- { PARA_IN_TABLEHEAD, 0 },
- { PARA_IN_TABLEBODY, 0 },
- { PARA_IN_FRAME, 0 },
- { PARA_IN_SECTION, 0 },
- { PARA_IN_FOOTENOTE, 0 },
- { PARA_IN_ENDNOTE, 0 },
- { PARA_IN_HEADER, 0 },
- { PARA_IN_FOOTER, 0 },
- { PARA_IN_OUTLINE, 0 },
- { PARA_IN_OUTLINE, 1 },
- { PARA_IN_OUTLINE, 2 },
- { PARA_IN_OUTLINE, 3 },
- { PARA_IN_OUTLINE, 4 },
- { PARA_IN_OUTLINE, 5 },
- { PARA_IN_OUTLINE, 6 },
- { PARA_IN_OUTLINE, 7 },
- { PARA_IN_OUTLINE, 8 },
- { PARA_IN_OUTLINE, 9 },
- { PARA_IN_LIST, 0 },
- { PARA_IN_LIST, 1 },
- { PARA_IN_LIST, 2 },
- { PARA_IN_LIST, 3 },
- { PARA_IN_LIST, 4 },
- { PARA_IN_LIST, 5 },
- { PARA_IN_LIST, 6 },
- { PARA_IN_LIST, 7 },
- { PARA_IN_LIST, 8 },
- { PARA_IN_LIST, 9 }
+ { Master_CollCondition::PARA_IN_TABLEHEAD, 0 },
+ { Master_CollCondition::PARA_IN_TABLEBODY, 0 },
+ { Master_CollCondition::PARA_IN_FRAME, 0 },
+ { Master_CollCondition::PARA_IN_SECTION, 0 },
+ { Master_CollCondition::PARA_IN_FOOTENOTE, 0 },
+ { Master_CollCondition::PARA_IN_ENDNOTE, 0 },
+ { Master_CollCondition::PARA_IN_HEADER, 0 },
+ { Master_CollCondition::PARA_IN_FOOTER, 0 },
+ { Master_CollCondition::PARA_IN_OUTLINE, 0 },
+ { Master_CollCondition::PARA_IN_OUTLINE, 1 },
+ { Master_CollCondition::PARA_IN_OUTLINE, 2 },
+ { Master_CollCondition::PARA_IN_OUTLINE, 3 },
+ { Master_CollCondition::PARA_IN_OUTLINE, 4 },
+ { Master_CollCondition::PARA_IN_OUTLINE, 5 },
+ { Master_CollCondition::PARA_IN_OUTLINE, 6 },
+ { Master_CollCondition::PARA_IN_OUTLINE, 7 },
+ { Master_CollCondition::PARA_IN_OUTLINE, 8 },
+ { Master_CollCondition::PARA_IN_OUTLINE, 9 },
+ { Master_CollCondition::PARA_IN_LIST, 0 },
+ { Master_CollCondition::PARA_IN_LIST, 1 },
+ { Master_CollCondition::PARA_IN_LIST, 2 },
+ { Master_CollCondition::PARA_IN_LIST, 3 },
+ { Master_CollCondition::PARA_IN_LIST, 4 },
+ { Master_CollCondition::PARA_IN_LIST, 5 },
+ { Master_CollCondition::PARA_IN_LIST, 6 },
+ { Master_CollCondition::PARA_IN_LIST, 7 },
+ { Master_CollCondition::PARA_IN_LIST, 8 },
+ { Master_CollCondition::PARA_IN_LIST, 9 }
};