summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@me.com>2019-04-18 19:25:06 +0200
committerArmin Le Grand <Armin.Le.Grand@me.com>2019-04-25 19:59:04 +0200
commit1e2682235cded9a7cd90e55f0bfc60a1285e9a46 (patch)
tree17457bc49d6faf37270c8a481b94765f58a5f434 /sw/source/core
parent5e4c1e6ba425ce0b75864e4584a846957b032e61 (diff)
WIP: Further preparations for deeper Item changes
(1) Migrated all still existing binary load/save stuff in SfxPoolItem to legacy files. Isolated from Item implementations. Adapted all usages. No more methods Create/Store needed, also GetVersion removed (2) Removed operator= for SfxPoolItem. Adapted all usages. Goal ist to handle Items more as Objects ('Object-Oriented') in the sense to move/handle instances, not to copy one instance over another one (which is more and more problematic with hard to copy content as UNO API stuff or similar). This lead to much more usages of std::shared_ptr which correlates well with future plans fr Items (see dev branch). Next logic step will be to also remove copy constructor Linux build and corrections done Fixed Writer test and removed unused defines Fixed another unused m,acro Started to unify the AutoFormat stuff Changes to OUString constructor usages, tests completely No idea why, but SfxStringItem constructor which takes a OUString& now insists of not getting ::OUString's handed in - changed all 'SfxStringItem.*OUString.*".*"' accordingly Change-Id: Ibed7358b18fb019994a7490332b9d797a6694c29 Reviewed-on: https://gerrit.libreoffice.org/71075 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/attr/format.cxx17
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx31
-rw-r--r--sw/source/core/doc/DocumentStylePoolManager.cxx37
-rw-r--r--sw/source/core/doc/doclay.cxx14
-rw-r--r--sw/source/core/doc/tblafmt.cxx478
-rw-r--r--sw/source/core/doc/tblrwcl.cxx35
-rw-r--r--sw/source/core/docnode/ndtbl1.cxx48
-rw-r--r--sw/source/core/frmedt/fefly1.cxx12
-rw-r--r--sw/source/core/frmedt/fetab.cxx18
-rw-r--r--sw/source/core/inc/frmtool.hxx2
-rw-r--r--sw/source/core/layout/atrfrm.cxx58
-rw-r--r--sw/source/core/layout/flylay.cxx4
-rw-r--r--sw/source/core/layout/frmtool.cxx12
-rwxr-xr-xsw/source/core/layout/legacyitem.cxx82
-rw-r--r--sw/source/core/layout/pagedesc.cxx2
-rw-r--r--sw/source/core/layout/paintfrm.cxx7
-rw-r--r--sw/source/core/layout/tabfrm.cxx4
-rw-r--r--sw/source/core/layout/wsfrm.cxx12
-rw-r--r--sw/source/core/text/porfld.cxx2
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx5
-rw-r--r--sw/source/core/unocore/unoframe.cxx26
-rw-r--r--sw/source/core/unocore/unoparagraph.cxx4
-rw-r--r--sw/source/core/unocore/unostyle.cxx44
-rw-r--r--sw/source/core/unocore/unotbl.cxx42
24 files changed, 401 insertions, 595 deletions
diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx
index af0ebc16bc1c..300118c72abb 100644
--- a/sw/source/core/attr/format.cxx
+++ b/sw/source/core/attr/format.cxx
@@ -382,14 +382,14 @@ const SfxPoolItem& SwFormat::GetFormatAttr( sal_uInt16 nWhich, bool bInParents )
{
// FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes or makeBackgroundBrushItem (simple fallback is in place and used)");
- static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
+ static std::shared_ptr<SvxBrushItem> aSvxBrushItem; //(std::make_shared<SvxBrushItem>(RES_BACKGROUND));
// fill the local static SvxBrushItem from the current ItemSet so that
// the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
// as good as possible to create a fallback representation and return that
aSvxBrushItem = getSvxBrushItemFromSourceSet(m_aSet, RES_BACKGROUND, bInParents);
- return aSvxBrushItem;
+ return *aSvxBrushItem;
}
return m_aSet.Get( nWhich, bInParents );
@@ -409,12 +409,11 @@ SfxItemState SwFormat::GetItemState( sal_uInt16 nWhich, bool bSrchInParent, cons
// if yes, fill the local SvxBrushItem using the new fill attributes
// as good as possible to have an instance for the pointer to point
// to and return as state that it is set
-
- static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
+ static std::shared_ptr<SvxBrushItem> aSvxBrushItem; //(RES_BACKGROUND);
aSvxBrushItem = getSvxBrushItemFromSourceSet(m_aSet, RES_BACKGROUND, bSrchInParent);
if( ppItem )
- *ppItem = &aSvxBrushItem;
+ *ppItem = aSvxBrushItem.get();
return SfxItemState::SET;
}
@@ -430,7 +429,7 @@ SfxItemState SwFormat::GetItemState( sal_uInt16 nWhich, bool bSrchInParent, cons
return m_aSet.GetItemState( nWhich, bSrchInParent, ppItem );
}
-SfxItemState SwFormat::GetBackgroundState(SvxBrushItem &rItem) const
+SfxItemState SwFormat::GetBackgroundState(std::shared_ptr<SvxBrushItem>& rItem) const
{
if (supportsFullDrawingLayerFillAttributeSet())
{
@@ -454,7 +453,7 @@ SfxItemState SwFormat::GetBackgroundState(SvxBrushItem &rItem) const
const SfxPoolItem* pItem = nullptr;
SfxItemState eRet = m_aSet.GetItemState(RES_BACKGROUND, true, &pItem);
if (pItem)
- rItem = *static_cast<const SvxBrushItem*>(pItem);
+ rItem.reset(static_cast<SvxBrushItem*>(pItem->Clone()));
return eRet;
}
@@ -782,7 +781,7 @@ void SwFormat::SetGrabBagItem(const uno::Any& rVal)
m_pGrabBagItem->PutValue(rVal, 0);
}
-SvxBrushItem SwFormat::makeBackgroundBrushItem(bool bInP) const
+std::shared_ptr<SvxBrushItem> SwFormat::makeBackgroundBrushItem(bool bInP) const
{
if (supportsFullDrawingLayerFillAttributeSet())
{
@@ -795,7 +794,7 @@ SvxBrushItem SwFormat::makeBackgroundBrushItem(bool bInP) const
return getSvxBrushItemFromSourceSet(m_aSet, RES_BACKGROUND, bInP);
}
- return m_aSet.GetBackground(bInP);
+ return std::shared_ptr<SvxBrushItem>(static_cast<SvxBrushItem*>(m_aSet.GetBackground(bInP).Clone()));
}
drawinglayer::attribute::SdrAllFillAttributesHelperPtr SwFormat::getSdrAllFillAttributesHelper() const
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index c6ff7c163462..1fe99be1dd2a 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -4306,9 +4306,9 @@ SwFlyFrameFormat* DocumentContentOperationsManager::InsNoTextNode( const SwPosit
#define NUMRULE_STATE \
SfxItemState aNumRuleState = SfxItemState::UNKNOWN; \
- SwNumRuleItem aNumRuleItem; \
+ std::shared_ptr<SwNumRuleItem> aNumRuleItem; \
SfxItemState aListIdState = SfxItemState::UNKNOWN; \
- SfxStringItem aListIdItem( RES_PARATR_LIST_ID, OUString() ); \
+ std::shared_ptr<SfxStringItem> aListIdItem; \
#define PUSH_NUMRULE_STATE \
lcl_PushNumruleState( aNumRuleState, aNumRuleItem, aListIdState, aListIdItem, pDestTextNd );
@@ -4316,9 +4316,10 @@ SwFlyFrameFormat* DocumentContentOperationsManager::InsNoTextNode( const SwPosit
#define POP_NUMRULE_STATE \
lcl_PopNumruleState( aNumRuleState, aNumRuleItem, aListIdState, aListIdItem, pDestTextNd, rPam );
-static void lcl_PushNumruleState( SfxItemState &aNumRuleState, SwNumRuleItem &aNumRuleItem,
- SfxItemState &aListIdState, SfxStringItem &aListIdItem,
- const SwTextNode *pDestTextNd )
+static void lcl_PushNumruleState(
+ SfxItemState &aNumRuleState, std::shared_ptr<SwNumRuleItem>& aNumRuleItem,
+ SfxItemState &aListIdState, std::shared_ptr<SfxStringItem>& aListIdItem,
+ const SwTextNode *pDestTextNd )
{
// Safe numrule item at destination.
// #i86492# - Safe also <ListId> item of destination.
@@ -4328,20 +4329,22 @@ static void lcl_PushNumruleState( SfxItemState &aNumRuleState, SwNumRuleItem &aN
const SfxPoolItem * pItem = nullptr;
aNumRuleState = pAttrSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem);
if (SfxItemState::SET == aNumRuleState)
- aNumRuleItem = *static_cast<const SwNumRuleItem *>( pItem);
+ {
+ aNumRuleItem.reset(static_cast<SwNumRuleItem*>(pItem->Clone()));
+ }
- aListIdState =
- pAttrSet->GetItemState(RES_PARATR_LIST_ID, false, &pItem);
+ aListIdState = pAttrSet->GetItemState(RES_PARATR_LIST_ID, false, &pItem);
if (SfxItemState::SET == aListIdState)
{
- aListIdItem.SetValue( static_cast<const SfxStringItem*>(pItem)->GetValue() );
+ aListIdItem.reset(static_cast<SfxStringItem*>(pItem->Clone()));
}
}
}
-static void lcl_PopNumruleState( SfxItemState aNumRuleState, const SwNumRuleItem &aNumRuleItem,
- SfxItemState aListIdState, const SfxStringItem &aListIdItem,
- SwTextNode *pDestTextNd, const SwPaM& rPam )
+static void lcl_PopNumruleState(
+ SfxItemState aNumRuleState, const std::shared_ptr<SwNumRuleItem>& aNumRuleItem,
+ SfxItemState aListIdState, const std::shared_ptr<SfxStringItem>& aListIdItem,
+ SwTextNode *pDestTextNd, const SwPaM& rPam )
{
/* If only a part of one paragraph is copied
restore the numrule at the destination. */
@@ -4350,7 +4353,7 @@ static void lcl_PopNumruleState( SfxItemState aNumRuleState, const SwNumRuleItem
{
if (SfxItemState::SET == aNumRuleState)
{
- pDestTextNd->SetAttr(aNumRuleItem);
+ pDestTextNd->SetAttr(*aNumRuleItem);
}
else
{
@@ -4358,7 +4361,7 @@ static void lcl_PopNumruleState( SfxItemState aNumRuleState, const SwNumRuleItem
}
if (SfxItemState::SET == aListIdState)
{
- pDestTextNd->SetAttr(aListIdItem);
+ pDestTextNd->SetAttr(*aListIdItem);
}
else
{
diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx
index 097f8479239e..a7a0a68850f5 100644
--- a/sw/source/core/doc/DocumentStylePoolManager.cxx
+++ b/sw/source/core/doc/DocumentStylePoolManager.cxx
@@ -1317,10 +1317,9 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
aLR.SetLeft( GetMetricVal( CM_1 ));
aLR.SetRight( GetMetricVal( CM_1 ));
aSet.Put( aLR );
- SvxULSpaceItem aUL( RES_UL_SPACE );
- aUL = pNewColl->GetULSpace();
- aUL.SetLower( HTML_PARSPACE );
- aSet.Put( aUL);
+ std::shared_ptr<SvxULSpaceItem> aUL(static_cast<SvxULSpaceItem*>(pNewColl->GetULSpace().Clone()));
+ aUL->SetLower( HTML_PARSPACE );
+ aSet.Put(*aUL);
}
break;
@@ -1333,10 +1332,9 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
// The lower paragraph distance is set explicitly (makes
// assigning hard attributes easier)
- SvxULSpaceItem aULSpaceItem( RES_UL_SPACE );
- aULSpaceItem = pNewColl->GetULSpace();
- aULSpaceItem.SetLower( 0 );
- aSet.Put( aULSpaceItem );
+ std::shared_ptr<SvxULSpaceItem> aULSpaceItem(static_cast<SvxULSpaceItem*>(pNewColl->GetULSpace().Clone()));
+ aULSpaceItem->SetLower( 0 );
+ aSet.Put(*aULSpaceItem);
}
break;
@@ -1351,13 +1349,13 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
aSet.Put( SwParaConnectBorderItem( false ) );
SetAllScriptItem( aSet, SvxFontHeightItem(120, 100, RES_CHRATR_FONTSIZE) );
- SvxULSpaceItem aUL( RES_UL_SPACE );
+ std::shared_ptr<SvxULSpaceItem> aUL;
{
pNewColl->SetNextTextFormatColl( *GetTextCollFromPool( RES_POOLCOLL_TEXT ));
- aUL = pNewColl->GetULSpace();
+ aUL.reset(static_cast<SvxULSpaceItem*>(pNewColl->GetULSpace().Clone()));
}
- aUL.SetLower( HTML_PARSPACE );
- aSet.Put( aUL);
+ aUL->SetLower( HTML_PARSPACE );
+ aSet.Put(*aUL);
SwFormatLineNumber aLN;
aLN.SetCountLines( false );
aSet.Put( aLN );
@@ -1366,23 +1364,22 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
case RES_POOLCOLL_HTML_DD:
{
- SvxLRSpaceItem aLR( RES_LR_SPACE );
- aLR = pNewColl->GetLRSpace();
+ std::shared_ptr<SvxLRSpaceItem> aLR(static_cast<SvxLRSpaceItem*>(pNewColl->GetLRSpace().Clone()));
// We indent by 1 cm. The IDs are always 2 away from each other!
- aLR.SetLeft( GetMetricVal( CM_1 ));
- aSet.Put( aLR );
+ aLR->SetLeft( GetMetricVal( CM_1 ));
+ aSet.Put(*aLR);
}
break;
case RES_POOLCOLL_HTML_DT:
{
- SvxLRSpaceItem aLR( RES_LR_SPACE );
+ std::shared_ptr<SvxLRSpaceItem> aLR;
{
pNewColl->SetNextTextFormatColl( *GetTextCollFromPool( RES_POOLCOLL_HTML_DD ));
- aLR = pNewColl->GetLRSpace();
+ aLR.reset(static_cast<SvxLRSpaceItem*>(pNewColl->GetLRSpace().Clone()));
}
// We indent by 0 cm. The IDs are always 2 away from each other!
- aLR.SetLeft( 0 );
- aSet.Put( aLR );
+ aLR->SetLeft( 0 );
+ aSet.Put( *aLR );
}
break;
}
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 286064fddab8..ec866b0c4e83 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -785,9 +785,9 @@ lcl_InsertLabel(SwDoc & rDoc, SwTextFormatColls *const pTextFormatCollTable,
pNewSet->Put( pOldFormat->GetAnchor() );
// The new one should be changeable in its height.
- SwFormatFrameSize aFrameSize( pOldFormat->GetFrameSize() );
- aFrameSize.SetHeightSizeType( ATT_MIN_SIZE );
- pNewSet->Put( aFrameSize );
+ std::shared_ptr<SwFormatFrameSize> aFrameSize(static_cast<SwFormatFrameSize*>(pOldFormat->GetFrameSize().Clone()));
+ aFrameSize->SetHeightSizeType( ATT_MIN_SIZE );
+ pNewSet->Put( *aFrameSize );
SwStartNode* pSttNd = rDoc.GetNodes().MakeTextSection(
SwNodeIndex( rDoc.GetNodes().GetEndOfAutotext() ),
@@ -834,7 +834,7 @@ lcl_InsertLabel(SwDoc & rDoc, SwTextFormatColls *const pTextFormatCollTable,
pNewSet->Put( SwFormatVertOrient( 0, eVert ) );
pNewSet->Put( SwFormatHoriOrient( 0, text::HoriOrientation::CENTER ) );
- aFrameSize = pOldFormat->GetFrameSize();
+ aFrameSize.reset(static_cast<SwFormatFrameSize*>(pOldFormat->GetFrameSize().Clone()));
SwOLENode* pOleNode = rDoc.GetNodes()[nNdIdx + 1]->GetOLENode();
bool isMath = false;
@@ -847,9 +847,9 @@ lcl_InsertLabel(SwDoc & rDoc, SwTextFormatColls *const pTextFormatCollTable,
isMath = ( SotExchange::IsMath( aCLSID ) != 0 );
}
}
- aFrameSize.SetWidthPercent(isMath ? 0 : 100);
- aFrameSize.SetHeightPercent(SwFormatFrameSize::SYNCED);
- pNewSet->Put( aFrameSize );
+ aFrameSize->SetWidthPercent(isMath ? 0 : 100);
+ aFrameSize->SetHeightPercent(SwFormatFrameSize::SYNCED);
+ pNewSet->Put( *aFrameSize );
// Hard-set the attributes, because they could come from the Template
// and then size calculations could not be correct anymore.
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index fbf6270bdd8c..102ac460111d 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -44,6 +44,11 @@
#include <sal/log.hxx>
#include <osl/diagnose.h>
+#include <svl/legacyitem.hxx>
+#include <editeng/legacyitem.hxx>
+#include <svx/legacyitem.hxx>
+#include <legacyitem.hxx>
+
#include <memory>
#include <vector>
@@ -66,20 +71,9 @@ const sal_uInt16 AUTOFORMAT_DATA_ID_504 = 9802;
const sal_uInt16 AUTOFORMAT_DATA_ID_552 = 9902;
-// --- from 641 on: CJK and CTL font settings
-const sal_uInt16 AUTOFORMAT_DATA_ID_641 = 10002;
-
-// --- from 680/dr14 on: diagonal frame lines
-const sal_uInt16 AUTOFORMAT_ID_680DR14 = 10011;
-const sal_uInt16 AUTOFORMAT_DATA_ID_680DR14 = 10012;
-
// --- from 680/dr25 on: store strings as UTF-8
const sal_uInt16 AUTOFORMAT_ID_680DR25 = 10021;
-// --- from DEV300/overline2 on: overline
-const sal_uInt16 AUTOFORMAT_ID_300OVRLN = 10031;
-const sal_uInt16 AUTOFORMAT_DATA_ID_300OVRLN = 10032;
-
// --- Bug fix to fdo#31005: Table Autoformats does not save/apply all properties (Writer and Calc)
const sal_uInt16 AUTOFORMAT_ID_31005 = 10041;
const sal_uInt16 AUTOFORMAT_DATA_ID_31005 = 10042;
@@ -164,187 +158,109 @@ namespace
// Struct with version numbers of the Items
-struct SwAfVersions
+struct SwAfVersions : public AutoFormatVersions
{
public:
- sal_uInt16 nFontVersion;
- sal_uInt16 nFontHeightVersion;
- sal_uInt16 nWeightVersion;
- sal_uInt16 nPostureVersion;
- sal_uInt16 nUnderlineVersion;
- sal_uInt16 nOverlineVersion;
- sal_uInt16 nCrossedOutVersion;
- sal_uInt16 nContourVersion;
- sal_uInt16 nShadowedVersion;
- sal_uInt16 nColorVersion;
- sal_uInt16 nBoxVersion;
- sal_uInt16 nLineVersion;
- sal_uInt16 nBrushVersion;
-
- sal_uInt16 nAdjustVersion;
sal_uInt16 m_nTextOrientationVersion;
sal_uInt16 m_nVerticalAlignmentVersion;
- sal_uInt16 nHorJustifyVersion;
- sal_uInt16 nVerJustifyVersion;
- sal_uInt16 nOrientationVersion;
- sal_uInt16 nMarginVersion;
- sal_uInt16 nBoolVersion;
- sal_uInt16 nInt32Version;
- sal_uInt16 nRotateModeVersion;
-
- sal_uInt16 nNumFormatVersion;
-
SwAfVersions();
void Load( SvStream& rStream, sal_uInt16 nVer );
+ static void Write(SvStream& rStream, sal_uInt16 fileVersion);
};
-SwAfVersions::SwAfVersions() :
- nFontVersion(0),
- nFontHeightVersion(0),
- nWeightVersion(0),
- nPostureVersion(0),
- nUnderlineVersion(0),
- nOverlineVersion(0),
- nCrossedOutVersion(0),
- nContourVersion(0),
- nShadowedVersion(0),
- nColorVersion(0),
- nBoxVersion(0),
- nLineVersion(0),
- nBrushVersion(0),
- nAdjustVersion(0),
+SwAfVersions::SwAfVersions()
+: AutoFormatVersions(),
m_nTextOrientationVersion(0),
- m_nVerticalAlignmentVersion(0),
- nHorJustifyVersion(0),
- nVerJustifyVersion(0),
- nOrientationVersion(0),
- nMarginVersion(0),
- nBoolVersion(0),
- nInt32Version(0),
- nRotateModeVersion(0),
- nNumFormatVersion(0)
+ m_nVerticalAlignmentVersion(0)
{
}
void SwAfVersions::Load( SvStream& rStream, sal_uInt16 nVer )
{
- rStream.ReadUInt16( nFontVersion );
- rStream.ReadUInt16( nFontHeightVersion );
- rStream.ReadUInt16( nWeightVersion );
- rStream.ReadUInt16( nPostureVersion );
- rStream.ReadUInt16( nUnderlineVersion );
- if ( nVer >= AUTOFORMAT_ID_300OVRLN )
- rStream.ReadUInt16( nOverlineVersion );
- rStream.ReadUInt16( nCrossedOutVersion );
- rStream.ReadUInt16( nContourVersion );
- rStream.ReadUInt16( nShadowedVersion );
- rStream.ReadUInt16( nColorVersion );
- rStream.ReadUInt16( nBoxVersion );
- if ( nVer >= AUTOFORMAT_ID_680DR14 )
- rStream.ReadUInt16( nLineVersion );
- rStream.ReadUInt16( nBrushVersion );
- rStream.ReadUInt16( nAdjustVersion );
+ LoadBlockA(rStream, nVer);
if (nVer >= AUTOFORMAT_ID_31005 && WriterSpecificBlockExists(rStream))
{
rStream.ReadUInt16( m_nTextOrientationVersion );
rStream.ReadUInt16( m_nVerticalAlignmentVersion );
}
+ LoadBlockB(rStream, nVer);
+}
- rStream.ReadUInt16( nHorJustifyVersion );
- rStream.ReadUInt16( nVerJustifyVersion );
- rStream.ReadUInt16( nOrientationVersion );
- rStream.ReadUInt16( nMarginVersion );
- rStream.ReadUInt16( nBoolVersion );
- if ( nVer >= AUTOFORMAT_ID_504 )
+void SwAfVersions::Write(SvStream& rStream, sal_uInt16 fileVersion)
+{
+ AutoFormatVersions::WriteBlockA(rStream, fileVersion);
+
+ if (fileVersion >= SOFFICE_FILEFORMAT_50)
{
- rStream.ReadUInt16( nInt32Version );
- rStream.ReadUInt16( nRotateModeVersion );
+ WriterSpecificAutoFormatBlock block(rStream);
+
+ rStream.WriteUInt16(legacy::SvxFrameDirection::GetVersion(fileVersion));
+ rStream.WriteUInt16(legacy::SwFormatVert::GetVersion(fileVersion));
}
- rStream.ReadUInt16( nNumFormatVersion );
+
+ AutoFormatVersions::WriteBlockB(rStream, fileVersion);
}
+
+
SwBoxAutoFormat::SwBoxAutoFormat()
- : m_aFont( *GetDfltAttr( RES_CHRATR_FONT ) ),
- m_aHeight( 240, 100, RES_CHRATR_FONTSIZE ),
- m_aWeight( WEIGHT_NORMAL, RES_CHRATR_WEIGHT ),
- m_aPosture( ITALIC_NONE, RES_CHRATR_POSTURE ),
-
- m_aCJKFont( *GetDfltAttr( RES_CHRATR_CJK_FONT ) ),
- m_aCJKHeight( 240, 100, RES_CHRATR_CJK_FONTSIZE ),
- m_aCJKWeight( WEIGHT_NORMAL, RES_CHRATR_CJK_WEIGHT ),
- m_aCJKPosture( ITALIC_NONE, RES_CHRATR_CJK_POSTURE ),
-
- m_aCTLFont( *GetDfltAttr( RES_CHRATR_CTL_FONT ) ),
- m_aCTLHeight( 240, 100, RES_CHRATR_CTL_FONTSIZE ),
- m_aCTLWeight( WEIGHT_NORMAL, RES_CHRATR_CTL_WEIGHT ),
- m_aCTLPosture( ITALIC_NONE, RES_CHRATR_CTL_POSTURE ),
-
- m_aUnderline( LINESTYLE_NONE, RES_CHRATR_UNDERLINE ),
- m_aOverline( LINESTYLE_NONE, RES_CHRATR_OVERLINE ),
- m_aCrossedOut( STRIKEOUT_NONE, RES_CHRATR_CROSSEDOUT ),
- m_aContour( false, RES_CHRATR_CONTOUR ),
- m_aShadowed( false, RES_CHRATR_SHADOWED ),
- m_aColor( RES_CHRATR_COLOR ),
- m_aBox( RES_BOX ),
- m_aTLBR( 0 ),
- m_aBLTR( 0 ),
- m_aBackground( RES_BACKGROUND ),
- m_aAdjust( SvxAdjust::Left, RES_PARATR_ADJUST ),
- m_aTextOrientation(SvxFrameDirection::Environment, RES_FRAMEDIR),
- m_aVerticalAlignment(0, css::text::VertOrientation::NONE, css::text::RelOrientation::FRAME),
- m_aHorJustify( SvxCellHorJustify::Standard, 0),
- m_aVerJustify( SvxCellVerJustify::Standard, 0),
- m_aStacked( 0 ),
- m_aMargin( 0 ),
- m_aLinebreak( 0 ),
- m_aRotateAngle( 0 ),
+: AutoFormatBase(),
+ m_aTextOrientation(std::make_shared<SvxFrameDirectionItem>(SvxFrameDirection::Environment, RES_FRAMEDIR)),
+ m_aVerticalAlignment(std::make_shared<SwFormatVertOrient>(0, css::text::VertOrientation::NONE, css::text::RelOrientation::FRAME)),
+ m_sNumFormatString(),
+ m_eSysLanguage(::GetAppLanguage()),
+ m_eNumFormatLanguage(::GetAppLanguage()),
+ m_wXObject()
+{
+ // need to set default instances for base class AutoFormatBase here
+ // due to ressource defines (e.g. RES_CHRATR_FONT) which are not available
+ // in svx and different in the different usages of derivations
+ m_aFont = std::make_shared<SvxFontItem>(*GetDfltAttr( RES_CHRATR_FONT ) );
+ m_aHeight = std::make_shared<SvxFontHeightItem>(240, 100, RES_CHRATR_FONTSIZE );
+ m_aWeight = std::make_shared<SvxWeightItem>(WEIGHT_NORMAL, RES_CHRATR_WEIGHT );
+ m_aPosture = std::make_shared<SvxPostureItem>(ITALIC_NONE, RES_CHRATR_POSTURE );
+ m_aCJKFont = std::make_shared<SvxFontItem>(*GetDfltAttr( RES_CHRATR_CJK_FONT ) );
+ m_aCJKHeight = std::make_shared<SvxFontHeightItem>(240, 100, RES_CHRATR_CJK_FONTSIZE );
+ m_aCJKWeight = std::make_shared<SvxWeightItem>(WEIGHT_NORMAL, RES_CHRATR_CJK_WEIGHT );
+ m_aCJKPosture = std::make_shared<SvxPostureItem>(ITALIC_NONE, RES_CHRATR_CJK_POSTURE );
+ m_aCTLFont = std::make_shared<SvxFontItem>(*GetDfltAttr( RES_CHRATR_CTL_FONT ) );
+ m_aCTLHeight = std::make_shared<SvxFontHeightItem>(240, 100, RES_CHRATR_CTL_FONTSIZE );
+ m_aCTLWeight = std::make_shared<SvxWeightItem>(WEIGHT_NORMAL, RES_CHRATR_CTL_WEIGHT );
+ m_aCTLPosture = std::make_shared<SvxPostureItem>(ITALIC_NONE, RES_CHRATR_CTL_POSTURE );
+ m_aUnderline = std::make_shared<SvxUnderlineItem>(LINESTYLE_NONE, RES_CHRATR_UNDERLINE );
+ m_aOverline = std::make_shared<SvxOverlineItem>(LINESTYLE_NONE, RES_CHRATR_OVERLINE );
+ m_aCrossedOut = std::make_shared<SvxCrossedOutItem>(STRIKEOUT_NONE, RES_CHRATR_CROSSEDOUT );
+ m_aContour = std::make_shared<SvxContourItem>(false, RES_CHRATR_CONTOUR );
+ m_aShadowed = std::make_shared<SvxShadowedItem>(false, RES_CHRATR_SHADOWED );
+ m_aColor = std::make_shared<SvxColorItem>(RES_CHRATR_COLOR );
+ m_aBox = std::make_shared<SvxBoxItem>(RES_BOX );
+ m_aTLBR = std::make_shared<SvxLineItem>(0 );
+ m_aBLTR = std::make_shared<SvxLineItem>(0 );
+ m_aBackground = std::make_shared<SvxBrushItem>(RES_BACKGROUND );
+ m_aAdjust = std::make_shared<SvxAdjustItem>(SvxAdjust::Left, RES_PARATR_ADJUST );
+ m_aHorJustify = std::make_shared<SvxHorJustifyItem>(SvxCellHorJustify::Standard, 0);
+ m_aVerJustify = std::make_shared<SvxVerJustifyItem>(SvxCellVerJustify::Standard, 0);
+ m_aStacked = std::make_shared<SfxBoolItem>(0 );
+ m_aMargin = std::make_shared<SvxMarginItem>(0 );
+ m_aLinebreak = std::make_shared<SfxBoolItem>(0 );
+ m_aRotateAngle = std::make_shared<SfxInt32Item>(0 );
+ m_aRotateMode = std::make_shared<SvxRotateModeItem>(SVX_ROTATE_MODE_STANDARD, 0 );
// FIXME - add attribute IDs for the diagonal line items
// aTLBR( RES_... ),
// aBLTR( RES_... ),
- m_aRotateMode( SVX_ROTATE_MODE_STANDARD, 0 )
-{
- m_eSysLanguage = m_eNumFormatLanguage = ::GetAppLanguage();
- m_aBox.SetAllDistances(55);
+ m_aBox->SetAllDistances(55);
}
SwBoxAutoFormat::SwBoxAutoFormat( const SwBoxAutoFormat& rNew )
- : m_aFont( rNew.m_aFont ),
- m_aHeight( rNew.m_aHeight ),
- m_aWeight( rNew.m_aWeight ),
- m_aPosture( rNew.m_aPosture ),
- m_aCJKFont( rNew.m_aCJKFont ),
- m_aCJKHeight( rNew.m_aCJKHeight ),
- m_aCJKWeight( rNew.m_aCJKWeight ),
- m_aCJKPosture( rNew.m_aCJKPosture ),
- m_aCTLFont( rNew.m_aCTLFont ),
- m_aCTLHeight( rNew.m_aCTLHeight ),
- m_aCTLWeight( rNew.m_aCTLWeight ),
- m_aCTLPosture( rNew.m_aCTLPosture ),
- m_aUnderline( rNew.m_aUnderline ),
- m_aOverline( rNew.m_aOverline ),
- m_aCrossedOut( rNew.m_aCrossedOut ),
- m_aContour( rNew.m_aContour ),
- m_aShadowed( rNew.m_aShadowed ),
- m_aColor( rNew.m_aColor ),
- m_aBox( rNew.m_aBox ),
- m_aTLBR( rNew.m_aTLBR ),
- m_aBLTR( rNew.m_aBLTR ),
- m_aBackground( rNew.m_aBackground ),
- m_aAdjust( rNew.m_aAdjust ),
- m_aTextOrientation(rNew.m_aTextOrientation),
- m_aVerticalAlignment(rNew.m_aVerticalAlignment),
- m_aHorJustify( rNew.m_aHorJustify ),
- m_aVerJustify( rNew.m_aVerJustify ),
- m_aStacked( rNew.m_aStacked ),
- m_aMargin( rNew.m_aMargin ),
- m_aLinebreak( rNew.m_aLinebreak ),
- m_aRotateAngle( rNew.m_aRotateAngle ),
- m_aRotateMode( rNew.m_aRotateMode ),
+: AutoFormatBase(rNew),
+ m_aTextOrientation(static_cast<SvxFrameDirectionItem*>(rNew.m_aTextOrientation->Clone())),
+ m_aVerticalAlignment(static_cast<SwFormatVertOrient*>(rNew.m_aVerticalAlignment->Clone())),
m_sNumFormatString( rNew.m_sNumFormatString ),
m_eSysLanguage( rNew.m_eSysLanguage ),
- m_eNumFormatLanguage( rNew.m_eNumFormatLanguage )
+ m_eNumFormatLanguage( rNew.m_eNumFormatLanguage ),
+ m_wXObject()
{
}
@@ -352,139 +268,27 @@ SwBoxAutoFormat::~SwBoxAutoFormat()
{
}
-SwBoxAutoFormat& SwBoxAutoFormat::operator=( const SwBoxAutoFormat& rNew )
-{
- m_aFont = rNew.m_aFont;
- m_aHeight = rNew.m_aHeight;
- m_aWeight = rNew.m_aWeight;
- m_aPosture = rNew.m_aPosture;
- m_aCJKFont = rNew.m_aCJKFont;
- m_aCJKHeight = rNew.m_aCJKHeight;
- m_aCJKWeight = rNew.m_aCJKWeight;
- m_aCJKPosture = rNew.m_aCJKPosture;
- m_aCTLFont = rNew.m_aCTLFont;
- m_aCTLHeight = rNew.m_aCTLHeight;
- m_aCTLWeight = rNew.m_aCTLWeight;
- m_aCTLPosture = rNew.m_aCTLPosture;
- m_aUnderline = rNew.m_aUnderline;
- m_aOverline = rNew.m_aOverline;
- m_aCrossedOut = rNew.m_aCrossedOut;
- m_aContour = rNew.m_aContour;
- m_aShadowed = rNew.m_aShadowed;
- m_aColor = rNew.m_aColor;
- SetAdjust( rNew.m_aAdjust );
- m_aTextOrientation = rNew.m_aTextOrientation;
- m_aVerticalAlignment = rNew.m_aVerticalAlignment;
- m_aBox = rNew.m_aBox;
- m_aTLBR = rNew.m_aTLBR;
- m_aBLTR = rNew.m_aBLTR;
- m_aBackground = rNew.m_aBackground;
-
- m_aHorJustify = rNew.m_aHorJustify;
- m_aVerJustify = rNew.m_aVerJustify;
- m_aStacked.SetValue( rNew.m_aStacked.GetValue() );
- m_aMargin = rNew.m_aMargin;
- m_aLinebreak.SetValue( rNew.m_aLinebreak.GetValue() );
- m_aRotateAngle.SetValue( rNew.m_aRotateAngle.GetValue() );
- m_aRotateMode.SetValue( rNew.m_aRotateMode.GetValue() );
-
- m_sNumFormatString = rNew.m_sNumFormatString;
- m_eSysLanguage = rNew.m_eSysLanguage;
- m_eNumFormatLanguage = rNew.m_eNumFormatLanguage;
-
- return *this;
-}
-
bool SwBoxAutoFormat::operator==(const SwBoxAutoFormat& rRight)
{
return GetBackground().GetColor() == rRight.GetBackground().GetColor();
}
-#define READ( aItem, aItemType, nVers )\
- pNew = aItem.Create(rStream, nVers ); \
- aItem = *static_cast<aItemType*>(pNew); \
- delete pNew;
-
bool SwBoxAutoFormat::Load( SvStream& rStream, const SwAfVersions& rVersions, sal_uInt16 nVer )
{
- SfxPoolItem* pNew;
- SvxOrientationItem aOrientation( SvxCellOrientation::Standard, 0);
-
- READ( m_aFont, SvxFontItem , rVersions.nFontVersion)
-
- if( rStream.GetStreamCharSet() == m_aFont.GetCharSet() )
- m_aFont.SetCharSet(::osl_getThreadTextEncoding());
-
- READ( m_aHeight, SvxFontHeightItem , rVersions.nFontHeightVersion)
- READ( m_aWeight, SvxWeightItem , rVersions.nWeightVersion)
- READ( m_aPosture, SvxPostureItem , rVersions.nPostureVersion)
- // --- from 641 on: CJK and CTL font settings
- if( AUTOFORMAT_DATA_ID_641 <= nVer )
- {
- READ( m_aCJKFont, SvxFontItem , rVersions.nFontVersion)
- READ( m_aCJKHeight, SvxFontHeightItem , rVersions.nFontHeightVersion)
- READ( m_aCJKWeight, SvxWeightItem , rVersions.nWeightVersion)
- READ( m_aCJKPosture, SvxPostureItem , rVersions.nPostureVersion)
- READ( m_aCTLFont, SvxFontItem , rVersions.nFontVersion)
- READ( m_aCTLHeight, SvxFontHeightItem , rVersions.nFontHeightVersion)
- READ( m_aCTLWeight, SvxWeightItem , rVersions.nWeightVersion)
- READ( m_aCTLPosture, SvxPostureItem , rVersions.nPostureVersion)
- }
- READ( m_aUnderline, SvxUnderlineItem , rVersions.nUnderlineVersion)
- if( nVer >= AUTOFORMAT_DATA_ID_300OVRLN )
- {
- READ( m_aOverline, SvxOverlineItem , rVersions.nOverlineVersion)
- }
- READ( m_aCrossedOut, SvxCrossedOutItem , rVersions.nCrossedOutVersion)
- READ( m_aContour, SvxContourItem , rVersions.nContourVersion)
- READ( m_aShadowed, SvxShadowedItem , rVersions.nShadowedVersion)
- READ( m_aColor, SvxColorItem , rVersions.nColorVersion)
-
- READ( m_aBox, SvxBoxItem , rVersions.nBoxVersion)
-
- // --- from 680/dr14 on: diagonal frame lines
- if( nVer >= AUTOFORMAT_DATA_ID_680DR14 )
- {
- READ( m_aTLBR, SvxLineItem, rVersions.nLineVersion)
- READ( m_aBLTR, SvxLineItem, rVersions.nLineVersion)
- }
-
- READ( m_aBackground, SvxBrushItem , rVersions.nBrushVersion)
-
- pNew = m_aAdjust.Create(rStream, rVersions.nAdjustVersion );
- SetAdjust( *static_cast<SvxAdjustItem*>(pNew) );
- delete pNew;
+ LoadBlockA( rStream, rVersions, nVer );
if (nVer >= AUTOFORMAT_DATA_ID_31005)
{
sal_Int64 const nSize(WriterSpecificBlockExists(rStream));
if (0 < nSize && nSize < std::numeric_limits<sal_uInt16>::max())
{
- READ(m_aTextOrientation, SvxFrameDirectionItem, rVersions.m_nTextOrientationVersion);
+ legacy::SvxFrameDirection::Create(*m_aTextOrientation, rStream, rVersions.m_nTextOrientationVersion);
// HORRIBLE HACK to read both 32-bit and 64-bit "long": abuse nSize
- READ(m_aVerticalAlignment, SwFormatVertOrient, /*rVersions.m_nVerticalAlignmentVersion*/ nSize);
+ legacy::SwFormatVert::Create(*m_aVerticalAlignment, rStream, /*rVersions.m_nVerticalAlignmentVersion*/ nSize);
}
}
- READ( m_aHorJustify, SvxHorJustifyItem , rVersions.nHorJustifyVersion)
- READ( m_aVerJustify, SvxVerJustifyItem , rVersions.nVerJustifyVersion)
-
- READ( aOrientation, SvxOrientationItem , rVersions.nOrientationVersion)
- READ( m_aMargin, SvxMarginItem , rVersions.nMarginVersion)
-
- pNew = m_aLinebreak.Create(rStream, rVersions.nBoolVersion );
- m_aLinebreak.SetValue( static_cast<SfxBoolItem*>(pNew)->GetValue() );
- delete pNew;
-
- if ( nVer >= AUTOFORMAT_DATA_ID_504 )
- {
- pNew = m_aRotateAngle.Create( rStream, rVersions.nInt32Version );
- m_aRotateAngle.SetValue( static_cast<SfxInt32Item*>(pNew)->GetValue() );
- delete pNew;
- pNew = m_aRotateMode.Create( rStream, rVersions.nRotateModeVersion );
- m_aRotateMode.SetValue( static_cast<SvxRotateModeItem*>(pNew)->GetValue() );
- delete pNew;
- }
+ LoadBlockB( rStream, rVersions, nVer );
if( 0 == rVersions.nNumFormatVersion )
{
@@ -499,56 +303,22 @@ bool SwBoxAutoFormat::Load( SvStream& rStream, const SwAfVersions& rVersions, sa
m_eSysLanguage = ::GetAppLanguage();
}
- m_aStacked.SetValue( aOrientation.IsStacked() );
- m_aRotateAngle.SetValue( aOrientation.GetRotation( m_aRotateAngle.GetValue() ) );
-
return ERRCODE_NONE == rStream.GetError();
}
bool SwBoxAutoFormat::Save( SvStream& rStream, sal_uInt16 fileVersion ) const
{
- SvxOrientationItem aOrientation( m_aRotateAngle.GetValue(), m_aStacked.GetValue(), 0 );
-
- m_aFont.Store( rStream, m_aFont.GetVersion(fileVersion) );
- m_aHeight.Store( rStream, m_aHeight.GetVersion(fileVersion) );
- m_aWeight.Store( rStream, m_aWeight.GetVersion(fileVersion) );
- m_aPosture.Store( rStream, m_aPosture.GetVersion(fileVersion) );
- m_aCJKFont.Store( rStream, m_aCJKFont.GetVersion(fileVersion) );
- m_aCJKHeight.Store( rStream, m_aCJKHeight.GetVersion(fileVersion) );
- m_aCJKWeight.Store( rStream, m_aCJKWeight.GetVersion(fileVersion) );
- m_aCJKPosture.Store( rStream, m_aCJKPosture.GetVersion(fileVersion) );
- m_aCTLFont.Store( rStream, m_aCTLFont.GetVersion(fileVersion) );
- m_aCTLHeight.Store( rStream, m_aCTLHeight.GetVersion(fileVersion) );
- m_aCTLWeight.Store( rStream, m_aCTLWeight.GetVersion(fileVersion) );
- m_aCTLPosture.Store( rStream, m_aCTLPosture.GetVersion(fileVersion) );
- m_aUnderline.Store( rStream, m_aUnderline.GetVersion(fileVersion) );
- m_aOverline.Store( rStream, m_aOverline.GetVersion(fileVersion) );
- m_aCrossedOut.Store( rStream, m_aCrossedOut.GetVersion(fileVersion) );
- m_aContour.Store( rStream, m_aContour.GetVersion(fileVersion) );
- m_aShadowed.Store( rStream, m_aShadowed.GetVersion(fileVersion) );
- m_aColor.Store( rStream, m_aColor.GetVersion(fileVersion) );
- m_aBox.Store( rStream, m_aBox.GetVersion(fileVersion) );
- m_aTLBR.Store( rStream, m_aTLBR.GetVersion(fileVersion) );
- m_aBLTR.Store( rStream, m_aBLTR.GetVersion(fileVersion) );
- m_aBackground.Store( rStream, m_aBackground.GetVersion(fileVersion) );
-
- m_aAdjust.Store( rStream, m_aAdjust.GetVersion(fileVersion) );
+ SaveBlockA( rStream, fileVersion );
+
if (fileVersion >= SOFFICE_FILEFORMAT_50)
{
WriterSpecificAutoFormatBlock block(rStream);
- m_aTextOrientation.Store(rStream, m_aTextOrientation.GetVersion(fileVersion));
- m_aVerticalAlignment.Store(rStream, m_aVerticalAlignment.GetVersion(fileVersion));
+ legacy::SvxFrameDirection::Store(*m_aTextOrientation, rStream, legacy::SvxFrameDirection::GetVersion(fileVersion));
+ legacy::SwFormatVert::Store(*m_aVerticalAlignment, rStream, legacy::SwFormatVert::GetVersion(fileVersion));
}
- m_aHorJustify.Store( rStream, m_aHorJustify.GetVersion(fileVersion) );
- m_aVerJustify.Store( rStream, m_aVerJustify.GetVersion(fileVersion) );
- aOrientation.Store( rStream, aOrientation.GetVersion(fileVersion) );
- m_aMargin.Store( rStream, m_aMargin.GetVersion(fileVersion) );
- m_aLinebreak.Store( rStream, m_aLinebreak.GetVersion(fileVersion) );
- // Calc Rotation from SO5
- m_aRotateAngle.Store( rStream, m_aRotateAngle.GetVersion(fileVersion) );
- m_aRotateMode.Store( rStream, m_aRotateMode.GetVersion(fileVersion) );
+ SaveBlockB( rStream, fileVersion );
// --- from 680/dr25 on: store strings as UTF-8
write_uInt16_lenPrefixed_uInt8s_FromOUString(rStream, m_sNumFormatString,
@@ -558,53 +328,16 @@ bool SwBoxAutoFormat::Save( SvStream& rStream, sal_uInt16 fileVersion ) const
return ERRCODE_NONE == rStream.GetError();
}
-void SwBoxAutoFormat::SaveVersionNo( SvStream& rStream, sal_uInt16 fileVersion ) const
-{
- rStream.WriteUInt16( m_aFont.GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aHeight.GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aWeight.GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aPosture.GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aUnderline.GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aOverline.GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aCrossedOut.GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aContour.GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aShadowed.GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aColor.GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aBox.GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aTLBR.GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aBackground.GetVersion( fileVersion ) );
-
- rStream.WriteUInt16( m_aAdjust.GetVersion( fileVersion ) );
-
- if (fileVersion >= SOFFICE_FILEFORMAT_50)
- {
- WriterSpecificAutoFormatBlock block(rStream);
-
- rStream.WriteUInt16( m_aTextOrientation.GetVersion(fileVersion) );
- rStream.WriteUInt16( m_aVerticalAlignment.GetVersion(fileVersion) );
- }
-
- rStream.WriteUInt16( m_aHorJustify.GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aVerJustify.GetVersion( fileVersion ) );
- rStream.WriteUInt16( SvxOrientationItem(SvxCellOrientation::Standard, 0).GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aMargin.GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aLinebreak.GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aRotateAngle.GetVersion( fileVersion ) );
- rStream.WriteUInt16( m_aRotateMode.GetVersion( fileVersion ) );
-
- rStream.WriteUInt16( 0 ); // NumberFormat
-}
-
SwTableAutoFormat::SwTableAutoFormat( const OUString& rName )
: m_aName( rName )
, m_nStrResId( USHRT_MAX )
- , m_aBreak( SvxBreak::NONE, RES_BREAK )
- , m_aKeepWithNextPara( false, RES_KEEP )
+ , m_aBreak(std::make_shared<SvxFormatBreakItem>(SvxBreak::NONE, RES_BREAK))
+ , m_aKeepWithNextPara(std::make_shared<SvxFormatKeepItem>(false, RES_KEEP))
, m_aRepeatHeading( 0 )
, m_bLayoutSplit( true )
, m_bRowSplit( true )
, m_bCollapsingBorders(true)
- , m_aShadow( RES_SHADOW )
+ , m_aShadow(std::make_shared<SvxShadowItem>(RES_SHADOW))
, m_bHidden( false )
, m_bUserDefined( true )
{
@@ -619,9 +352,9 @@ SwTableAutoFormat::SwTableAutoFormat( const OUString& rName )
}
SwTableAutoFormat::SwTableAutoFormat( const SwTableAutoFormat& rNew )
- : m_aBreak( rNew.m_aBreak )
- , m_aKeepWithNextPara( false, RES_KEEP )
- , m_aShadow( RES_SHADOW )
+ : m_aBreak()
+ , m_aKeepWithNextPara()
+ , m_aShadow(std::make_shared<SvxShadowItem>(RES_SHADOW))
{
for(SwBoxAutoFormat* & rp : m_aBoxAutoFormat)
rp = nullptr;
@@ -654,14 +387,14 @@ SwTableAutoFormat& SwTableAutoFormat::operator=( const SwTableAutoFormat& rNew )
m_bInclValueFormat = rNew.m_bInclValueFormat;
m_bInclWidthHeight = rNew.m_bInclWidthHeight;
- m_aBreak = rNew.m_aBreak;
+ m_aBreak.reset(static_cast<SvxFormatBreakItem*>(rNew.m_aBreak->Clone()));
m_aPageDesc = rNew.m_aPageDesc;
- m_aKeepWithNextPara = rNew.m_aKeepWithNextPara;
+ m_aKeepWithNextPara.reset(static_cast<SvxFormatKeepItem*>(rNew.m_aKeepWithNextPara->Clone()));
m_aRepeatHeading = rNew.m_aRepeatHeading;
m_bLayoutSplit = rNew.m_bLayoutSplit;
m_bRowSplit = rNew.m_bRowSplit;
m_bCollapsingBorders = rNew.m_bCollapsingBorders;
- m_aShadow = rNew.m_aShadow;
+ m_aShadow.reset(static_cast<SvxShadowItem*>(rNew.m_aShadow->Clone()));
m_bHidden = rNew.m_bHidden;
m_bUserDefined = rNew.m_bUserDefined;
@@ -904,12 +637,12 @@ void SwTableAutoFormat::RestoreTableProperties(SwTable &table) const
SfxItemSet rSet(pDoc->GetAttrPool(), aTableSetRange);
- rSet.Put(m_aBreak);
+ rSet.Put(*m_aBreak);
rSet.Put(m_aPageDesc);
rSet.Put(SwFormatLayoutSplit(m_bLayoutSplit));
rSet.Put(SfxBoolItem(RES_COLLAPSING_BORDERS, m_bCollapsingBorders));
- rSet.Put(m_aKeepWithNextPara);
- rSet.Put(m_aShadow);
+ rSet.Put(*m_aKeepWithNextPara);
+ rSet.Put(*m_aShadow);
pFormat->SetFormatAttr(rSet);
@@ -936,15 +669,15 @@ void SwTableAutoFormat::StoreTableProperties(const SwTable &table)
const SfxItemSet &rSet = pFormat->GetAttrSet();
- m_aBreak = rSet.Get(RES_BREAK);
+ m_aBreak.reset(static_cast<SvxFormatBreakItem*>(rSet.Get(RES_BREAK).Clone()));
m_aPageDesc = rSet.Get(RES_PAGEDESC);
const SwFormatLayoutSplit &layoutSplit = rSet.Get(RES_LAYOUT_SPLIT);
m_bLayoutSplit = layoutSplit.GetValue();
m_bCollapsingBorders = rSet.Get(RES_COLLAPSING_BORDERS).GetValue();
- m_aKeepWithNextPara = rSet.Get(RES_KEEP);
+ m_aKeepWithNextPara.reset(static_cast<SvxFormatKeepItem*>(rSet.Get(RES_KEEP).Clone()));
m_aRepeatHeading = table.GetRowsToRepeat();
- m_aShadow = rSet.Get(RES_SHADOW);
+ m_aShadow.reset(static_cast<SvxShadowItem*>(rSet.Get(RES_SHADOW).Clone()));
}
bool SwTableAutoFormat::FirstRowEndColumnIsRow()
@@ -997,15 +730,13 @@ bool SwTableAutoFormat::Load( SvStream& rStream, const SwAfVersions& rVersions )
if (nVal >= AUTOFORMAT_DATA_ID_31005 && WriterSpecificBlockExists(rStream))
{
- SfxPoolItem* pNew = nullptr;
-
- READ(m_aBreak, SvxFormatBreakItem, AUTOFORMAT_FILE_VERSION);
+ legacy::SvxFormatBreak::Create(*m_aBreak, rStream, AUTOFORMAT_FILE_VERSION);
//unimplemented READ(m_aPageDesc, SwFormatPageDesc, AUTOFORMAT_FILE_VERSION);
- READ(m_aKeepWithNextPara, SvxFormatKeepItem, AUTOFORMAT_FILE_VERSION);
+ legacy::SvxFormatKeep::Create(*m_aKeepWithNextPara, rStream, AUTOFORMAT_FILE_VERSION);
rStream.ReadUInt16( m_aRepeatHeading ).ReadCharAsBool( m_bLayoutSplit ).ReadCharAsBool( m_bRowSplit ).ReadCharAsBool( m_bCollapsingBorders );
- READ(m_aShadow, SvxShadowItem, AUTOFORMAT_FILE_VERSION);
+ legacy::SvxShadow::Create(*m_aShadow, rStream, AUTOFORMAT_FILE_VERSION);
}
bRet = ERRCODE_NONE== rStream.GetError();
@@ -1044,11 +775,11 @@ bool SwTableAutoFormat::Save( SvStream& rStream, sal_uInt16 fileVersion ) const
{
WriterSpecificAutoFormatBlock block(rStream);
- m_aBreak.Store(rStream, m_aBreak.GetVersion(fileVersion));
+ legacy::SvxFormatBreak::Store(*m_aBreak, rStream, legacy::SvxFormatBreak::GetVersion(fileVersion));
//unimplemented m_aPageDesc.Store(rStream, m_aPageDesc.GetVersion(fileVersion));
- m_aKeepWithNextPara.Store(rStream, m_aKeepWithNextPara.GetVersion(fileVersion));
+ legacy::SvxFormatKeep::Store(*m_aKeepWithNextPara, rStream, legacy::SvxFormatKeep::GetVersion(fileVersion));
rStream.WriteUInt16( m_aRepeatHeading ).WriteBool( m_bLayoutSplit ).WriteBool( m_bRowSplit ).WriteBool( m_bCollapsingBorders );
- m_aShadow.Store(rStream, m_aShadow.GetVersion(fileVersion));
+ legacy::SvxShadow::Store(*m_aShadow, rStream, legacy::SvxShadow::GetVersion(fileVersion));
}
bool bRet = ERRCODE_NONE == rStream.GetError();
@@ -1373,8 +1104,7 @@ bool SwTableAutoFormatTable::Save( SvStream& rStream ) const
return false;
// Write this version number for all attributes
- m_pImpl->m_AutoFormats[0]->GetBoxFormat(0).SaveVersionNo(
- rStream, AUTOFORMAT_FILE_VERSION);
+ SwAfVersions::Write(rStream, AUTOFORMAT_FILE_VERSION);
rStream.WriteUInt16( m_pImpl->m_AutoFormats.size() - 1 );
bRet = ERRCODE_NONE == rStream.GetError();
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index f6c0bb60e715..b414d65847f7 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -1803,20 +1803,43 @@ static void lcl_CopyBoxToDoc(FndBox_ const& rFndBox, CpyPara *const pCpyPara)
// Find the Frame Format in the list of all Frame Formats
CpyTabFrame aFindFrame(static_cast<SwTableBoxFormat*>(rFndBox.GetBox()->GetFrameFormat()));
- SwFormatFrameSize aFrameSz;
+ std::shared_ptr<SwFormatFrameSize> aFrameSz(std::make_shared<SwFormatFrameSize>());
CpyTabFrames::const_iterator itFind = pCpyPara->rTabFrameArr.lower_bound( aFindFrame );
const CpyTabFrames::size_type nFndPos = itFind - pCpyPara->rTabFrameArr.begin();
- if( itFind == pCpyPara->rTabFrameArr.end() || !(*itFind == aFindFrame) ||
- ( aFrameSz = ( aFindFrame = pCpyPara->rTabFrameArr[ nFndPos ]).pNewFrameFormat->
- GetFrameSize()).GetWidth() != static_cast<SwTwips>(nSize) )
+
+ // It *is* sometimes cool to have multiple tests/if's and assignments
+ // in a single statement, and it is technically possible. But it is definitely
+ // not simply readable - where from my POV reading code is done 1000 times
+ // more often than writing it. Thus I dismantled the expression in smaller
+ // chunks to keep it handy/understandable/changeable (hopefully without error)
+ // The original for reference:
+ // if( itFind == pCpyPara->rTabFrameArr.end() || !(*itFind == aFindFrame) ||
+ // ( aFrameSz = ( aFindFrame = pCpyPara->rTabFrameArr[ nFndPos ]).pNewFrameFormat->
+ // GetFrameSize()).GetWidth() != static_cast<SwTwips>(nSize) )
+
+ bool DoCopyIt(itFind == pCpyPara->rTabFrameArr.end());
+
+ if(!DoCopyIt)
+ {
+ DoCopyIt = !(*itFind == aFindFrame);
+ }
+
+ if(!DoCopyIt)
+ {
+ aFindFrame = pCpyPara->rTabFrameArr[ nFndPos ];
+ aFrameSz.reset(static_cast<SwFormatFrameSize*>(aFindFrame.pNewFrameFormat->GetFrameSize().Clone()));
+ DoCopyIt = aFrameSz->GetWidth() != static_cast<SwTwips>(nSize);
+ }
+
+ if(DoCopyIt)
{
// It doesn't exist yet, so copy it
aFindFrame.pNewFrameFormat = pCpyPara->pDoc->MakeTableBoxFormat();
aFindFrame.pNewFrameFormat->CopyAttrs( *rFndBox.GetBox()->GetFrameFormat() );
if( !pCpyPara->bCpyContent )
aFindFrame.pNewFrameFormat->ResetFormatAttr( RES_BOXATR_FORMULA, RES_BOXATR_VALUE );
- aFrameSz.SetWidth( nSize );
- aFindFrame.pNewFrameFormat->SetFormatAttr( aFrameSz );
+ aFrameSz->SetWidth( nSize );
+ aFindFrame.pNewFrameFormat->SetFormatAttr( *aFrameSz );
pCpyPara->rTabFrameArr.insert( aFindFrame );
}
diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx
index daf52e4047a9..9781ccd87911 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -498,7 +498,7 @@ void SwDoc::SetRowBackground( const SwCursor& rCursor, const SvxBrushItem &rNew
}
}
-bool SwDoc::GetRowBackground( const SwCursor& rCursor, SvxBrushItem &rToFill )
+bool SwDoc::GetRowBackground( const SwCursor& rCursor, std::shared_ptr<SvxBrushItem>& rToFill )
{
bool bRet = false;
SwTableNode* pTableNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
@@ -513,11 +513,15 @@ bool SwDoc::GetRowBackground( const SwCursor& rCursor, SvxBrushItem &rToFill )
bRet = true;
for ( std::vector<SwTableLine*>::size_type i = 1; i < aRowArr.size(); ++i )
- if ( rToFill != aRowArr[i]->GetFrameFormat()->makeBackgroundBrushItem() )
+ {
+ std::shared_ptr<SvxBrushItem> aAlternative(aRowArr[i]->GetFrameFormat()->makeBackgroundBrushItem());
+
+ if ( rToFill != aAlternative && rToFill && aAlternative && *rToFill != *aAlternative )
{
bRet = false;
break;
}
+ }
}
}
return bRet;
@@ -875,26 +879,28 @@ void SwDoc::SetTabLineStyle( const SwCursor& rCursor,
const_cast<SwTableBox*>(pCell->GetTabBox())->ClaimFrameFormat();
SwFrameFormat *pFormat = pCell->GetFormat();
- SvxBoxItem aBox( pFormat->GetBox() );
+ std::shared_ptr<SvxBoxItem> aBox(static_cast<SvxBoxItem*>(pFormat->GetBox().Clone()));
if ( !pBorderLine && bSetLine )
- aBox = *::GetDfltAttr( RES_BOX );
+ {
+ aBox.reset(static_cast<SvxBoxItem*>(::GetDfltAttr(RES_BOX)->Clone()));
+ }
else
{
- if ( aBox.GetTop() )
- ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox.GetTop()),
+ if ( aBox->GetTop() )
+ ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox->GetTop()),
pColor, pBorderLine );
- if ( aBox.GetBottom() )
- ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox.GetBottom()),
+ if ( aBox->GetBottom() )
+ ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox->GetBottom()),
pColor, pBorderLine );
- if ( aBox.GetLeft() )
- ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox.GetLeft()),
+ if ( aBox->GetLeft() )
+ ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox->GetLeft()),
pColor, pBorderLine );
- if ( aBox.GetRight() )
- ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox.GetRight()),
+ if ( aBox->GetRight() )
+ ::lcl_SetLineStyle( const_cast<SvxBorderLine*>(aBox->GetRight()),
pColor, pBorderLine );
}
- pFormat->SetFormatAttr( aBox );
+ pFormat->SetFormatAttr( *aBox );
}
}
@@ -1178,7 +1184,7 @@ void SwDoc::SetBoxAttr( const SwCursor& rCursor, const SfxPoolItem &rNew )
}
}
-bool SwDoc::GetBoxAttr( const SwCursor& rCursor, SfxPoolItem& rToFill )
+bool SwDoc::GetBoxAttr( const SwCursor& rCursor, std::shared_ptr<SfxPoolItem>& rToFill )
{
bool bRet = false;
SwTableNode* pTableNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
@@ -1187,18 +1193,18 @@ bool SwDoc::GetBoxAttr( const SwCursor& rCursor, SfxPoolItem& rToFill )
{
bRet = true;
bool bOneFound = false;
- const sal_uInt16 nWhich = rToFill.Which();
+ const sal_uInt16 nWhich = rToFill->Which();
for (size_t i = 0; i < aBoxes.size(); ++i)
{
switch ( nWhich )
{
case RES_BACKGROUND:
{
- SvxBrushItem aBack =
+ std::shared_ptr<SvxBrushItem> aBack =
aBoxes[i]->GetFrameFormat()->makeBackgroundBrushItem();
if( !bOneFound )
{
- static_cast<SvxBrushItem&>(rToFill) = aBack;
+ rToFill.reset(aBack->Clone());
bOneFound = true;
}
else if( rToFill != aBack )
@@ -1212,10 +1218,10 @@ bool SwDoc::GetBoxAttr( const SwCursor& rCursor, SfxPoolItem& rToFill )
aBoxes[i]->GetFrameFormat()->GetFrameDir();
if( !bOneFound )
{
- static_cast<SvxFrameDirectionItem&>(rToFill) = rDir;
+ rToFill.reset(rDir.Clone());
bOneFound = true;
}
- else if( rToFill != rDir )
+ else if( rToFill && *rToFill != rDir )
bRet = false;
}
break;
@@ -1225,10 +1231,10 @@ bool SwDoc::GetBoxAttr( const SwCursor& rCursor, SfxPoolItem& rToFill )
aBoxes[i]->GetFrameFormat()->GetVertOrient();
if( !bOneFound )
{
- static_cast<SwFormatVertOrient&>(rToFill) = rOrient;
+ rToFill.reset(rOrient.Clone());
bOneFound = true;
}
- else if( rToFill != rOrient )
+ else if( rToFill && *rToFill != rOrient )
bRet = false;
}
break;
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index 363f1056583a..f81fb14a647c 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -701,8 +701,8 @@ const SwFrameFormat *SwFEShell::NewFlyFrame( const SfxItemSet& rSet, bool bAnchV
GetDoc()->GetIDocumentUndoRedo().StartUndo( SwUndoId::INSLAYFMT, nullptr );
std::unique_ptr<SwFormatAnchor> pOldAnchor;
bool bHOriChgd = false, bVOriChgd = false;
- SwFormatVertOrient aOldV;
- SwFormatHoriOrient aOldH;
+ std::shared_ptr<SwFormatVertOrient> aOldV;
+ std::shared_ptr<SwFormatHoriOrient> aOldH;
if ( RndStdIds::FLY_AT_PAGE != eRndId )
{
@@ -718,14 +718,14 @@ const SwFrameFormat *SwFEShell::NewFlyFrame( const SfxItemSet& rSet, bool bAnchV
&& text::HoriOrientation::NONE == static_cast<const SwFormatHoriOrient*>(pItem)->GetHoriOrient() )
{
bHOriChgd = true;
- aOldH = *static_cast<const SwFormatHoriOrient*>(pItem);
+ aOldH.reset(static_cast<SwFormatHoriOrient*>(pItem->Clone()));
const_cast<SfxItemSet&>(rSet).Put( SwFormatHoriOrient( 0, text::HoriOrientation::LEFT ) );
}
if( SfxItemState::SET == rSet.GetItemState( RES_VERT_ORIENT, false, &pItem )
&& text::VertOrientation::NONE == static_cast<const SwFormatVertOrient*>(pItem)->GetVertOrient() )
{
bVOriChgd = true;
- aOldV = *static_cast<const SwFormatVertOrient*>(pItem);
+ aOldV.reset(static_cast<SwFormatVertOrient*>(pItem->Clone()));
const_cast<SfxItemSet&>(rSet).Put( SwFormatVertOrient( 0, text::VertOrientation::TOP ) );
}
}
@@ -773,9 +773,9 @@ const SwFrameFormat *SwFEShell::NewFlyFrame( const SfxItemSet& rSet, bool bAnchV
const_cast<SfxItemSet&>(rSet).Put( *pOldAnchor );
if( bHOriChgd )
- const_cast<SfxItemSet&>(rSet).Put( aOldH );
+ const_cast<SfxItemSet&>(rSet).Put( *aOldH );
if( bVOriChgd )
- const_cast<SfxItemSet&>(rSet).Put( aOldV );
+ const_cast<SfxItemSet&>(rSet).Put( *aOldV );
GetDoc()->SetFlyFrameAttr( *pRet, const_cast<SfxItemSet&>(rSet) );
GetDoc()->GetIDocumentUndoRedo().DoUndo(bDoesUndo);
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index 61a995381a52..a60eff107e9a 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -754,7 +754,7 @@ void SwFEShell::SetRowBackground( const SvxBrushItem &rNew )
EndAllActionAndCall();
}
-bool SwFEShell::GetRowBackground( SvxBrushItem &rToFill ) const
+bool SwFEShell::GetRowBackground( std::shared_ptr<SvxBrushItem>& rToFill ) const
{
return SwDoc::GetRowBackground( *getShellCursor( false ), rToFill );
}
@@ -790,9 +790,12 @@ void SwFEShell::SetBoxBackground( const SvxBrushItem &rNew )
EndAllActionAndCall();
}
-bool SwFEShell::GetBoxBackground( SvxBrushItem &rToFill ) const
+bool SwFEShell::GetBoxBackground( std::shared_ptr<SvxBrushItem>& rToFill ) const
{
- return SwDoc::GetBoxAttr( *getShellCursor( false ), rToFill );
+ std::shared_ptr<SfxPoolItem> aTemp(rToFill);
+ bool bRetval(SwDoc::GetBoxAttr(*getShellCursor( false ), aTemp));
+ rToFill = std::static_pointer_cast<SvxBrushItem>(aTemp);
+ return bRetval;
}
void SwFEShell::SetBoxDirection( const SvxFrameDirectionItem& rNew )
@@ -803,9 +806,12 @@ void SwFEShell::SetBoxDirection( const SvxFrameDirectionItem& rNew )
EndAllActionAndCall();
}
-bool SwFEShell::GetBoxDirection( SvxFrameDirectionItem& rToFill ) const
+bool SwFEShell::GetBoxDirection( std::shared_ptr<SvxFrameDirectionItem>& rToFill ) const
{
- return SwDoc::GetBoxAttr( *getShellCursor( false ), rToFill );
+ std::shared_ptr<SfxPoolItem> aTemp(rToFill);
+ bool bRetval(SwDoc::GetBoxAttr(*getShellCursor( false ), aTemp));
+ rToFill = std::static_pointer_cast<SvxFrameDirectionItem>(aTemp);
+ return bRetval;
}
void SwFEShell::SetBoxAlign( sal_uInt16 nAlign )
@@ -834,7 +840,7 @@ void SwFEShell::SetTabBackground( const SvxBrushItem &rNew )
GetDoc()->getIDocumentState().SetModified();
}
-void SwFEShell::GetTabBackground( SvxBrushItem &rToFill ) const
+void SwFEShell::GetTabBackground( std::shared_ptr<SvxBrushItem>& rToFill ) const
{
SwFrame *pFrame = GetCurrFrame();
if( pFrame && pFrame->IsInTab() )
diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx
index 18048e34112b..8765dd034b6f 100644
--- a/sw/source/core/inc/frmtool.hxx
+++ b/sw/source/core/inc/frmtool.hxx
@@ -281,7 +281,7 @@ class SwBorderAttrs : public SwCacheObj
const SwAttrSet &m_rAttrSet;
const SvxULSpaceItem &m_rUL;
// #i96772#
- SvxLRSpaceItem m_rLR;
+ std::shared_ptr<SvxLRSpaceItem> m_rLR;
const SvxBoxItem &m_rBox;
const SvxShadowItem &m_rShadow;
const Size m_aFrameSize;
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 7c77560c8e33..0cbb44249644 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -1265,48 +1265,6 @@ void SwFormatSurround::dumpAsXml(xmlTextWriterPtr pWriter) const
xmlTextWriterEndElement(pWriter);
}
-SvStream& SwFormatVertOrient::Store(SvStream &rStream, sal_uInt16 /*version*/) const
-{
-#if SAL_TYPES_SIZEOFLONG == 8
- rStream.WriteInt64(m_nYPos);
-#else
- rStream.WriteInt32(m_nYPos);
-#endif
- rStream.WriteInt16( m_eOrient ).WriteInt16( m_eRelation );
- return rStream;
-}
-
-SfxPoolItem* SwFormatVertOrient::Create(SvStream &rStream, sal_uInt16 nVersionAbusedAsSize) const
-{
- SwTwips yPos(0);
- sal_Int16 orient(0);
- sal_Int16 relation(0);
- switch (nVersionAbusedAsSize)
- {
- // compatibility hack for Table Auto Format: SwTwips is "long" :(
- // (this means that the file format is platform dependent)
- case 14:
- {
- sal_Int64 n(0);
- rStream.ReadInt64(n);
- yPos = n;
- }
- break;
- case 10:
- {
- sal_Int32 n(0);
- rStream.ReadInt32(n);
- yPos = n;
- }
- break;
- default:
- SAL_WARN("sw.core", "SwFormatVertOrient::Create: unknown size");
- }
- rStream.ReadInt16( orient ).ReadInt16( relation );
-
- return new SwFormatVertOrient(yPos, orient, relation);
-}
-
// Partially implemented inline in hxx
SwFormatVertOrient::SwFormatVertOrient( SwTwips nY, sal_Int16 eVert,
sal_Int16 eRel )
@@ -3210,16 +3168,17 @@ bool SwFlyFrameFormat::IsBackgroundTransparent() const
// NOTE: If background color is "no fill"/"auto fill" (COL_TRANSPARENT)
// and there is no background graphic, it "inherites" the background
// from its anchor.
- SvxBrushItem aBackground(makeBackgroundBrushItem());
- if ( (aBackground.GetColor().GetTransparency() != 0) &&
- (aBackground.GetColor() != COL_TRANSPARENT)
+ std::shared_ptr<SvxBrushItem> aBackground(makeBackgroundBrushItem());
+ if ( aBackground &&
+ (aBackground->GetColor().GetTransparency() != 0) &&
+ (aBackground->GetColor() != COL_TRANSPARENT)
)
{
return true;
}
else
{
- const GraphicObject *pTmpGrf = aBackground.GetGraphicObject();
+ const GraphicObject *pTmpGrf = aBackground->GetGraphicObject();
if ( pTmpGrf &&
(pTmpGrf->GetAttr().GetTransparency() != 0)
)
@@ -3249,9 +3208,10 @@ bool SwFlyFrameFormat::IsBackgroundBrushInherited() const
}
else
{
- SvxBrushItem aBackground(makeBackgroundBrushItem());
- if ( (aBackground.GetColor() == COL_TRANSPARENT) &&
- !(aBackground.GetGraphicObject()) )
+ std::shared_ptr<SvxBrushItem> aBackground(makeBackgroundBrushItem());
+ if ( aBackground &&
+ (aBackground->GetColor() == COL_TRANSPARENT) &&
+ !(aBackground->GetGraphicObject()) )
{
return true;
}
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index 16a610847978..e7d19227fd88 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -358,9 +358,9 @@ bool SwFlyFreeFrame::supportsAutoContour() const
}
else
{
- const SvxBrushItem aBack(GetFormat()->makeBackgroundBrushItem());
+ const std::shared_ptr<SvxBrushItem> aBack(GetFormat()->makeBackgroundBrushItem());
- if(aBack.isUsed())
+ if(aBack && aBack->isUsed())
{
return false;
}
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index 5c33911727bf..8e7c4a3700ff 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -1977,7 +1977,7 @@ SwBorderAttrs::SwBorderAttrs(const SwModify *pMod, const SwFrame *pConstructor)
, m_rUL(m_rAttrSet.GetULSpace())
// #i96772#
// LRSpaceItem is copied due to the possibility that it is adjusted - see below
- , m_rLR(m_rAttrSet.GetLRSpace())
+ , m_rLR(static_cast<SvxLRSpaceItem*>(m_rAttrSet.GetLRSpace().Clone()))
, m_rBox(m_rAttrSet.GetBox())
, m_rShadow(m_rAttrSet.GetShadow())
, m_aFrameSize(m_rAttrSet.GetFrameSize().GetSize())
@@ -2001,7 +2001,7 @@ SwBorderAttrs::SwBorderAttrs(const SwModify *pMod, const SwFrame *pConstructor)
}
else if ( pConstructor->IsNoTextFrame() )
{
- m_rLR = SvxLRSpaceItem ( RES_LR_SPACE );
+ m_rLR = std::make_shared<SvxLRSpaceItem>(RES_LR_SPACE);
}
// Caution: The USHORTs for the cached values are not initialized by intention!
@@ -2054,9 +2054,9 @@ long SwBorderAttrs::CalcRight( const SwFrame* pCaller ) const
}
// for paragraphs, "left" is "before text" and "right" is "after text"
if ( pCaller->IsTextFrame() && pCaller->IsRightToLeft() )
- nRight += m_rLR.GetLeft();
+ nRight += m_rLR->GetLeft();
else
- nRight += m_rLR.GetRight();
+ nRight += m_rLR->GetRight();
// correction: retrieve left margin for numbering in R2L-layout
if ( pCaller->IsTextFrame() && pCaller->IsRightToLeft() )
@@ -2103,7 +2103,7 @@ long SwBorderAttrs::CalcLeft( const SwFrame *pCaller ) const
// for paragraphs, "left" is "before text" and "right" is "after text"
if ( pCaller->IsTextFrame() && pCaller->IsRightToLeft() )
- nLeft += m_rLR.GetRight();
+ nLeft += m_rLR->GetRight();
else
{
bool bIgnoreMargin = false;
@@ -2121,7 +2121,7 @@ long SwBorderAttrs::CalcLeft( const SwFrame *pCaller ) const
}
}
if (!bIgnoreMargin)
- nLeft += m_rLR.GetLeft();
+ nLeft += m_rLR->GetLeft();
}
// correction: do not retrieve left margin for numbering in R2L-layout
diff --git a/sw/source/core/layout/legacyitem.cxx b/sw/source/core/layout/legacyitem.cxx
new file mode 100755
index 000000000000..9dea0dca8cf6
--- /dev/null
+++ b/sw/source/core/layout/legacyitem.cxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <legacyitem.hxx>
+#include <tools/stream.hxx>
+#include <sal/log.hxx>
+#include <fmtornt.hxx>
+
+namespace legacy
+{
+ namespace SwFormatVert
+ {
+ sal_uInt16 GetVersion(sal_uInt16)
+ {
+ return 0;
+ }
+
+ void Create(SwFormatVertOrient& rItem, SvStream& rStrm, sal_uInt16 nVersionAbusedAsSize)
+ {
+ SwTwips yPos(0);
+ sal_Int16 orient(0);
+ sal_Int16 relation(0);
+
+ switch (nVersionAbusedAsSize)
+ {
+ // compatibility hack for Table Auto Format: SwTwips is "long" :(
+ // (this means that the file format is platform dependent)
+ case 14:
+ {
+ sal_Int64 n(0);
+ rStrm.ReadInt64(n);
+ yPos = n;
+ break;
+ }
+ case 10:
+ {
+ sal_Int32 n(0);
+ rStrm.ReadInt32(n);
+ yPos = n;
+ break;
+ }
+ default:
+ SAL_WARN("sw.core", "SwFormatVertOrient::Create: unknown size");
+ }
+
+ rStrm.ReadInt16( orient ).ReadInt16( relation );
+
+ rItem.SetPos(yPos);
+ rItem.SetVertOrient(orient);
+ rItem.SetRelationOrient(relation);
+ }
+
+ SvStream& Store(const SwFormatVertOrient& rItem, SvStream& rStrm, sal_uInt16)
+ {
+#if SAL_TYPES_SIZEOFLONG == 8
+ rStrm.WriteInt64(rItem.GetPos());
+#else
+ rStrm.WriteInt32(rItem.GetPos());
+#endif
+ rStrm.WriteInt16(rItem.GetVertOrient()).WriteInt16(rItem.GetRelationOrient());
+ return rStrm;
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx
index 2e3a122655e6..a0c7e08ee45b 100644
--- a/sw/source/core/layout/pagedesc.cxx
+++ b/sw/source/core/layout/pagedesc.cxx
@@ -159,7 +159,7 @@ void SwPageDesc::Mirror()
aSet.Put( m_Master.GetPaperBin() );
aSet.Put( m_Master.GetULSpace() );
aSet.Put( m_Master.GetBox() );
- aSet.Put( m_Master.makeBackgroundBrushItem() );
+ aSet.Put( *m_Master.makeBackgroundBrushItem() );
aSet.Put( m_Master.GetShadow() );
aSet.Put( m_Master.GetCol() );
aSet.Put( m_Master.GetFrameDir() );
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index e8f0613cf942..ad7530657e4e 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3920,13 +3920,14 @@ void SwFlyFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect const&
}
else
{
- SvxBrushItem aBack = GetFormat()->makeBackgroundBrushItem();
+ std::shared_ptr<SvxBrushItem> aBack = GetFormat()->makeBackgroundBrushItem();
// OD 07.08.2002 #99657# #GetTransChg#
// to determine, if background has to be painted, by checking, if
// background color is not COL_TRANSPARENT ("no fill"/"auto fill")
// or a background graphic exists.
- bPaintCompleteBack = (aBack.GetColor() != COL_TRANSPARENT) ||
- aBack.GetGraphicPos() != GPOS_NONE;
+ bPaintCompleteBack = aBack &&
+ ((aBack->GetColor() != COL_TRANSPARENT) ||
+ aBack->GetGraphicPos() != GPOS_NONE);
}
}
// paint of margin needed.
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 5c2158d415cb..060a8dcf6de3 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -3130,8 +3130,8 @@ SwTwips SwTabFrame::GrowFrame( SwTwips nDist, bool bTst, bool bInfo )
InvalidatePage( pPage );
SetComplete();
- SvxBrushItem aBack = GetFormat()->makeBackgroundBrushItem();
- const SvxGraphicPosition ePos = aBack.GetGraphicPos();
+ std::shared_ptr<SvxBrushItem> aBack = GetFormat()->makeBackgroundBrushItem();
+ const SvxGraphicPosition ePos = aBack ? aBack->GetGraphicPos() : GPOS_NONE;
if ( GPOS_NONE != ePos && GPOS_TILED != ePos )
SetCompletePaint();
}
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 0f486b4f3f4b..187f64e797a5 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -1678,8 +1678,8 @@ SwTwips SwFrame::AdjustNeighbourhood( SwTwips nDiff, bool bTst )
GetNext()->InvalidatePos_();
//Trigger a repaint if necessary.
- SvxBrushItem aBack(pUp->GetFormat()->makeBackgroundBrushItem());
- const SvxGraphicPosition ePos = aBack.GetGraphicPos();
+ std::shared_ptr<SvxBrushItem> aBack(pUp->GetFormat()->makeBackgroundBrushItem());
+ const SvxGraphicPosition ePos = aBack ? aBack->GetGraphicPos() : GPOS_NONE;
if ( ePos != GPOS_NONE && ePos != GPOS_TILED )
pViewShell->InvalidateWindows( pUp->getFrameArea() );
@@ -2717,8 +2717,8 @@ SwTwips SwLayoutFrame::GrowFrame( SwTwips nDist, bool bTst, bool bInfo )
if( IsCellFrame() )
InvaPercentLowers( nReal );
- SvxBrushItem aBack(GetFormat()->makeBackgroundBrushItem());
- const SvxGraphicPosition ePos = aBack.GetGraphicPos();
+ std::shared_ptr<SvxBrushItem> aBack(GetFormat()->makeBackgroundBrushItem());
+ const SvxGraphicPosition ePos = aBack ? aBack->GetGraphicPos() : GPOS_NONE;
if ( GPOS_NONE != ePos && GPOS_TILED != ePos )
SetCompletePaint();
}
@@ -2903,8 +2903,8 @@ SwTwips SwLayoutFrame::ShrinkFrame( SwTwips nDist, bool bTst, bool bInfo )
const SwFrameFormat* pFormat = GetFormat();
if (pFormat)
{
- SvxBrushItem aBack(pFormat->makeBackgroundBrushItem());
- const SvxGraphicPosition ePos = aBack.GetGraphicPos();
+ std::shared_ptr<SvxBrushItem> aBack(pFormat->makeBackgroundBrushItem());
+ const SvxGraphicPosition ePos = aBack ? aBack->GetGraphicPos() : GPOS_NONE;
if ( GPOS_NONE == ePos || GPOS_TILED == ePos )
bCompletePaint = false;
}
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index bfb547d31487..760a0a8774bf 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -765,7 +765,7 @@ SwGrfNumPortion::SwGrfNumPortion(
m_bReplace = false;
if( pGrfBrush )
{
- *pBrush = *pGrfBrush;
+ pBrush.reset(static_cast<SvxBrushItem*>(pGrfBrush->Clone()));
const Graphic* pGraph = pGrfBrush->GetGraphic();
if( pGraph )
SetAnimated( pGraph->IsAnimated() );
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index c044b4903112..ff94c1848b1b 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -3289,7 +3289,7 @@ SwTwips SwTextNode::GetAdditionalIndentForStartingNewList() const
}
// #i96772#
-void SwTextNode::ClearLRSpaceItemDueToListLevelIndents( SvxLRSpaceItem& o_rLRSpaceItem ) const
+void SwTextNode::ClearLRSpaceItemDueToListLevelIndents( std::shared_ptr<SvxLRSpaceItem>& o_rLRSpaceItem ) const
{
if ( AreListLevelIndentsApplicable() )
{
@@ -3299,8 +3299,7 @@ void SwTextNode::ClearLRSpaceItemDueToListLevelIndents( SvxLRSpaceItem& o_rLRSpa
const SwNumFormat& rFormat = pRule->Get(lcl_BoundListLevel(GetActualListLevel()));
if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
{
- SvxLRSpaceItem aLR( RES_LR_SPACE );
- o_rLRSpaceItem = aLR;
+ o_rLRSpaceItem = std::make_shared<SvxLRSpaceItem>(RES_LR_SPACE);
}
}
}
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index dc6db2ab7438..d5dfc5681fb6 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -355,7 +355,7 @@ bool BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet& rToSet, const SfxI
if(bXFillStyleItemUsed)
{
XFillStyleItem aXFillStyleItem;
- SvxBrushItem aBrush(RES_BACKGROUND);
+ std::shared_ptr<SvxBrushItem> aBrush(std::make_shared<SvxBrushItem>(RES_BACKGROUND));
if(pXFillStyleItem)
{
@@ -379,10 +379,10 @@ bool BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet& rToSet, const SfxI
// Fill style is set to solid, but no fill color is given.
// On the other hand, we have a BackColor, so use that.
if (pCol)
- aBrush.PutValue(*pCol, MID_BACK_COLOR);
+ aBrush->PutValue(*pCol, MID_BACK_COLOR);
else
- aBrush.PutValue(*pRGBCol, MID_BACK_COLOR_R_G_B);
- setSvxBrushItemAsFillAttributesToTargetSet(aBrush, rToSet);
+ aBrush->PutValue(*pRGBCol, MID_BACK_COLOR_R_G_B);
+ setSvxBrushItemAsFillAttributesToTargetSet(*aBrush, rToSet);
}
if(pXFillGradientItem || pXFillGradientNameItem)
@@ -490,8 +490,8 @@ bool BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet& rToSet, const SfxI
}
if (aXFillStyleItem.GetValue() == drawing::FillStyle_SOLID)
{
- aBrush.PutValue(*pColTrans, MID_BACK_COLOR_TRANSPARENCY);
- setSvxBrushItemAsFillAttributesToTargetSet(aBrush, rToSet);
+ aBrush->PutValue(*pColTrans, MID_BACK_COLOR_TRANSPARENCY);
+ setSvxBrushItemAsFillAttributesToTargetSet(*aBrush, rToSet);
}
}
@@ -1767,14 +1767,14 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any&
if(RES_BACKGROUND == pEntry->nWID)
{
const SwAttrSet& rSet = pFormat->GetAttrSet();
- const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND, true, pDoc->IsInXMLImport()));
- SvxBrushItem aChangedBrushItem(aOriginalBrushItem);
+ const std::shared_ptr<SvxBrushItem> aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND, true, pDoc->IsInXMLImport()));
+ std::shared_ptr<SvxBrushItem> aChangedBrushItem(static_cast<SvxBrushItem*>(aOriginalBrushItem->Clone()));
- aChangedBrushItem.PutValue(aValue, nMemberId);
+ aChangedBrushItem->PutValue(aValue, nMemberId);
- if(aChangedBrushItem != aOriginalBrushItem)
+ if(*aChangedBrushItem != *aOriginalBrushItem)
{
- setSvxBrushItemAsFillAttributesToTargetSet(aChangedBrushItem, aSet);
+ setSvxBrushItemAsFillAttributesToTargetSet(*aChangedBrushItem, aSet);
pFormat->GetDoc()->SetFlyFrameAttr( *pFormat, aSet );
}
@@ -2217,9 +2217,9 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName)
if(RES_BACKGROUND == pEntry->nWID)
{
- const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
+ const std::shared_ptr<SvxBrushItem> aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
- if(!aOriginalBrushItem.QueryValue(aAny, nMemberId))
+ if(!aOriginalBrushItem->QueryValue(aAny, nMemberId))
{
OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
}
diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx
index bf9abc3bf68c..2e1201675697 100644
--- a/sw/source/core/unocore/unoparagraph.cxx
+++ b/sw/source/core/unocore/unoparagraph.cxx
@@ -450,9 +450,9 @@ void SwXParagraph::Impl::GetSinglePropertyValue_Impl(
{
case RES_BACKGROUND:
{
- const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
+ const std::shared_ptr<SvxBrushItem> aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
- if(!aOriginalBrushItem.QueryValue(rAny, rEntry.nMemberId))
+ if(!aOriginalBrushItem->QueryValue(rAny, rEntry.nMemberId))
{
OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
}
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 2dfc44ef08c3..56f991b53364 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1647,20 +1647,20 @@ template<>
void SwXStyle::SetPropertyValue<sal_uInt16(RES_BACKGROUND)>(const SfxItemPropertySimpleEntry& rEntry, const SfxItemPropertySet&, const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
{
SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
- const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rStyleSet, RES_BACKGROUND, true, m_pDoc->IsInXMLImport()));
- SvxBrushItem aChangedBrushItem(aOriginalBrushItem);
+ const std::shared_ptr<SvxBrushItem> aOriginalBrushItem(getSvxBrushItemFromSourceSet(rStyleSet, RES_BACKGROUND, true, m_pDoc->IsInXMLImport()));
+ std::shared_ptr<SvxBrushItem> aChangedBrushItem(static_cast<SvxBrushItem*>(aOriginalBrushItem->Clone()));
uno::Any aValue(rValue);
const auto nMemberId(lcl_TranslateMetric(rEntry, m_pDoc, aValue));
- aChangedBrushItem.PutValue(aValue, nMemberId);
+ aChangedBrushItem->PutValue(aValue, nMemberId);
// 0xff is already the default - but if BackTransparent is set
// to true, it must be applied in the item set on ODF import
// to potentially override parent style, which is unknown yet
- if(aChangedBrushItem == aOriginalBrushItem && (MID_GRAPHIC_TRANSPARENT != nMemberId || !aValue.has<bool>() || !aValue.get<bool>()))
+ if(*aChangedBrushItem == *aOriginalBrushItem && (MID_GRAPHIC_TRANSPARENT != nMemberId || !aValue.has<bool>() || !aValue.get<bool>()))
return;
- setSvxBrushItemAsFillAttributesToTargetSet(aChangedBrushItem, rStyleSet);
+ setSvxBrushItemAsFillAttributesToTargetSet(*aChangedBrushItem, rStyleSet);
}
template<>
void SwXStyle::SetPropertyValue<OWN_ATTR_FILLBMP_MODE>(const SfxItemPropertySimpleEntry&, const SfxItemPropertySet&, const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
@@ -2281,9 +2281,9 @@ uno::Any SwXStyle::GetStyleProperty<sal_uInt16(RES_BACKGROUND)>(const SfxItemPro
{
PrepareStyleBase(rBase);
const SfxItemSet& rSet = rBase.GetItemSet();
- const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
+ const std::shared_ptr<SvxBrushItem> aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
uno::Any aResult;
- if(!aOriginalBrushItem.QueryValue(aResult, rEntry.nMemberId))
+ if(!aOriginalBrushItem->QueryValue(aResult, rEntry.nMemberId))
SAL_WARN("sw.uno", "error getting attribute from RES_BACKGROUND.");
return aResult;
}
@@ -2682,7 +2682,7 @@ void SAL_CALL SwXStyle::setAllPropertiesToDefault()
pPageFormat->SetFormatAttr(aLR);
pPageFormat->SetFormatAttr(aUL);
SwPageDesc* pStdPgDsc = m_pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD);
- SwFormatFrameSize aFrameSz(ATT_FIX_SIZE);
+ std::shared_ptr<SwFormatFrameSize> aFrameSz(std::make_shared<SwFormatFrameSize>(ATT_FIX_SIZE));
if(RES_POOLPAGE_STANDARD == rPageDesc.GetPoolFormatId())
{
@@ -2690,27 +2690,27 @@ void SAL_CALL SwXStyle::setAllPropertiesToDefault()
{
const Size aPhysSize( SvxPaperInfo::GetPaperSize(
static_cast<Printer*>(m_pDoc->getIDocumentDeviceAccess().getPrinter(false))));
- aFrameSz.SetSize(aPhysSize);
+ aFrameSz->SetSize(aPhysSize);
}
else
{
- aFrameSz.SetSize(SvxPaperInfo::GetDefaultPaperSize());
+ aFrameSz->SetSize(SvxPaperInfo::GetDefaultPaperSize());
}
}
else
{
- aFrameSz = pStdPgDsc->GetMaster().GetFrameSize();
+ aFrameSz.reset(static_cast<SwFormatFrameSize*>(pStdPgDsc->GetMaster().GetFrameSize().Clone()));
}
if(pStdPgDsc->GetLandscape())
{
- SwTwips nTmp = aFrameSz.GetHeight();
- aFrameSz.SetHeight(aFrameSz.GetWidth());
- aFrameSz.SetWidth(nTmp);
+ SwTwips nTmp = aFrameSz->GetHeight();
+ aFrameSz->SetHeight(aFrameSz->GetWidth());
+ aFrameSz->SetWidth(nTmp);
}
- pPageFormat->SetFormatAttr(aFrameSz);
+ pPageFormat->SetFormatAttr(*aFrameSz);
m_pDoc->ChgPageDesc(nPgDscPos, m_pDoc->GetPageDesc(nPgDscPos));
return;
}
@@ -3641,14 +3641,14 @@ uno::Reference< style::XAutoStyle > SwXAutoStyleFamily::insertStyle(
}
case RES_BACKGROUND:
{
- const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND, true, m_pDocShell->GetDoc()->IsInXMLImport()));
- SvxBrushItem aChangedBrushItem(aOriginalBrushItem);
+ const std::shared_ptr<SvxBrushItem> aOriginalBrushItem(getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND, true, m_pDocShell->GetDoc()->IsInXMLImport()));
+ std::shared_ptr<SvxBrushItem> aChangedBrushItem(static_cast<SvxBrushItem*>(aOriginalBrushItem->Clone()));
- aChangedBrushItem.PutValue(aValue, nMemberId);
+ aChangedBrushItem->PutValue(aValue, nMemberId);
- if(aChangedBrushItem != aOriginalBrushItem)
+ if(*aChangedBrushItem != *aOriginalBrushItem)
{
- setSvxBrushItemAsFillAttributesToTargetSet(aChangedBrushItem, aSet);
+ setSvxBrushItemAsFillAttributesToTargetSet(*aChangedBrushItem, aSet);
}
bDone = true;
@@ -3969,9 +3969,9 @@ uno::Sequence< uno::Any > SwXAutoStyle::GetPropertyValues_Impl(
{
case RES_BACKGROUND:
{
- const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(*mpSet, RES_BACKGROUND));
+ const std::shared_ptr<SvxBrushItem> aOriginalBrushItem(getSvxBrushItemFromSourceSet(*mpSet, RES_BACKGROUND));
- if(!aOriginalBrushItem.QueryValue(aTarget, pEntry->nMemberId))
+ if(!aOriginalBrushItem->QueryValue(aTarget, pEntry->nMemberId))
{
OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
}
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 26f6dab13353..6843d98d75cd 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1674,10 +1674,10 @@ void SwXTextTableCursor::setPropertyValue(const OUString& rPropertyName, const u
{
case FN_UNO_TABLE_CELL_BACKGROUND:
{
- SvxBrushItem aBrush(RES_BACKGROUND);
+ std::shared_ptr<SfxPoolItem> aBrush(std::make_shared<SvxBrushItem>(RES_BACKGROUND));
SwDoc::GetBoxAttr(rUnoCursor, aBrush);
- aBrush.PutValue(aValue, pEntry->nMemberId);
- pDoc->SetBoxAttr(rUnoCursor, aBrush);
+ aBrush->PutValue(aValue, pEntry->nMemberId);
+ pDoc->SetBoxAttr(rUnoCursor, *aBrush);
}
break;
@@ -1727,9 +1727,9 @@ uno::Any SwXTextTableCursor::getPropertyValue(const OUString& rPropertyName)
{
case FN_UNO_TABLE_CELL_BACKGROUND:
{
- SvxBrushItem aBrush(RES_BACKGROUND);
+ std::shared_ptr<SfxPoolItem> aBrush(std::make_shared<SvxBrushItem>(RES_BACKGROUND));
if (SwDoc::GetBoxAttr(rUnoCursor, aBrush))
- aBrush.QueryValue(aResult, pEntry->nMemberId);
+ aBrush->QueryValue(aResult, pEntry->nMemberId);
}
break;
case RES_BOXATR_FORMAT:
@@ -1814,8 +1814,8 @@ void SwTableProperties_Impl::AddItemToSet(SfxItemSet& rSet, std::function<Tpooli
{
Tpoolitem aItem = aItemFactory();
for(auto& aMemberAndAny : vMemberAndAny)
- aItem.PutValue(*aMemberAndAny.second, aMemberAndAny.first | (bAddTwips ? CONVERT_TWIPS : 0) );
- rSet.Put(aItem);
+ aItem->PutValue(*aMemberAndAny.second, aMemberAndAny.first | (bAddTwips ? CONVERT_TWIPS : 0) );
+ rSet.Put(*aItem);
}
}
void SwTableProperties_Impl::ApplyTableAttr(const SwTable& rTable, SwDoc& rDoc)
@@ -1837,7 +1837,7 @@ void SwTableProperties_Impl::ApplyTableAttr(const SwTable& rTable, SwDoc& rDoc)
const_cast<SwTable&>(rTable).SetRowsToRepeat( bVal ? 1 : 0 ); // TODO: MULTIHEADER
}
- AddItemToSet<SvxBrushItem>(aSet, [&rFrameFormat]() { return rFrameFormat.makeBackgroundBrushItem(); }, RES_BACKGROUND, {
+ AddItemToSet<std::shared_ptr<SvxBrushItem>>(aSet, [&rFrameFormat]() { return rFrameFormat.makeBackgroundBrushItem(); }, RES_BACKGROUND, {
MID_BACK_COLOR,
MID_GRAPHIC_TRANSPARENT,
MID_GRAPHIC_POSITION,
@@ -1869,10 +1869,10 @@ void SwTableProperties_Impl::ApplyTableAttr(const SwTable& rTable, SwDoc& rDoc)
}
if(bPutBreak)
- AddItemToSet<SvxFormatBreakItem>(aSet, [&rFrameFormat]() { return rFrameFormat.GetBreak(); }, RES_BREAK, {0});
- AddItemToSet<SvxShadowItem>(aSet, [&rFrameFormat]() { return rFrameFormat.GetShadow(); }, RES_SHADOW, {0}, true);
- AddItemToSet<SvxFormatKeepItem>(aSet, [&rFrameFormat]() { return rFrameFormat.GetKeep(); }, RES_KEEP, {0});
- AddItemToSet<SwFormatHoriOrient>(aSet, [&rFrameFormat]() { return rFrameFormat.GetHoriOrient(); }, RES_HORI_ORIENT, {MID_HORIORIENT_ORIENT}, true);
+ AddItemToSet<std::shared_ptr<SvxFormatBreakItem>>(aSet, [&rFrameFormat]() { return std::shared_ptr<SvxFormatBreakItem>(static_cast<SvxFormatBreakItem*>(rFrameFormat.GetBreak().Clone())); }, RES_BREAK, {0});
+ AddItemToSet<std::shared_ptr<SvxShadowItem>>(aSet, [&rFrameFormat]() { return std::shared_ptr<SvxShadowItem>(static_cast<SvxShadowItem*>(rFrameFormat.GetShadow().Clone())); }, RES_SHADOW, {0}, true);
+ AddItemToSet<std::shared_ptr<SvxFormatKeepItem>>(aSet, [&rFrameFormat]() { return std::shared_ptr<SvxFormatKeepItem>(static_cast<SvxFormatKeepItem*>(rFrameFormat.GetKeep().Clone())); }, RES_KEEP, {0});
+ AddItemToSet<std::shared_ptr<SwFormatHoriOrient>>(aSet, [&rFrameFormat]() { return std::shared_ptr<SwFormatHoriOrient>(static_cast<SwFormatHoriOrient*>(rFrameFormat.GetHoriOrient().Clone())); }, RES_HORI_ORIENT, {MID_HORIORIENT_ORIENT}, true);
const uno::Any* pSzRel(nullptr);
GetProperty(FN_TABLE_IS_RELATIVE_WIDTH, 0xff, pSzRel);
@@ -1899,10 +1899,10 @@ void SwTableProperties_Impl::ApplyTableAttr(const SwTable& rTable, SwDoc& rDoc)
aSz.SetWidth(MINLAY);
aSet.Put(aSz);
}
- AddItemToSet<SvxLRSpaceItem>(aSet, [&rFrameFormat]() { return rFrameFormat.GetLRSpace(); }, RES_LR_SPACE, {
+ AddItemToSet<std::shared_ptr<SvxLRSpaceItem>>(aSet, [&rFrameFormat]() { return std::shared_ptr<SvxLRSpaceItem>(static_cast<SvxLRSpaceItem*>(rFrameFormat.GetLRSpace().Clone())); }, RES_LR_SPACE, {
MID_L_MARGIN|CONVERT_TWIPS,
MID_R_MARGIN|CONVERT_TWIPS });
- AddItemToSet<SvxULSpaceItem>(aSet, [&rFrameFormat]() { return rFrameFormat.GetULSpace(); }, RES_UL_SPACE, {
+ AddItemToSet<std::shared_ptr<SvxULSpaceItem>>(aSet, [&rFrameFormat]() { return std::shared_ptr<SvxULSpaceItem>(static_cast<SvxULSpaceItem*>(rFrameFormat.GetULSpace().Clone())); }, RES_UL_SPACE, {
MID_UP_MARGIN|CONVERT_TWIPS,
MID_LO_MARGIN|CONVERT_TWIPS });
const::uno::Any* pSplit(nullptr);
@@ -3397,10 +3397,10 @@ SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::Any& aV
{
case FN_UNO_TABLE_CELL_BACKGROUND:
{
- SvxBrushItem aBrush( RES_BACKGROUND );
+ std::shared_ptr<SfxPoolItem> aBrush(std::make_shared<SvxBrushItem>(RES_BACKGROUND));
SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aBrush);
- static_cast<SfxPoolItem&>(aBrush).PutValue(aValue, pEntry->nMemberId);
- pDoc->SetBoxAttr(*m_pImpl->m_pTableCursor, aBrush);
+ aBrush->PutValue(aValue, pEntry->nMemberId);
+ pDoc->SetBoxAttr(*m_pImpl->m_pTableCursor, *aBrush);
}
break;
@@ -3507,9 +3507,9 @@ uno::Any SAL_CALL SwXCellRange::getPropertyValue(const OUString& rPropertyName)
{
case FN_UNO_TABLE_CELL_BACKGROUND:
{
- SvxBrushItem aBrush( RES_BACKGROUND );
+ std::shared_ptr<SfxPoolItem> aBrush(std::make_shared<SvxBrushItem>(RES_BACKGROUND));
if (SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aBrush))
- aBrush.QueryValue(aRet, pEntry->nMemberId);
+ aBrush->QueryValue(aRet, pEntry->nMemberId);
}
break;
@@ -3546,10 +3546,10 @@ uno::Any SAL_CALL SwXCellRange::getPropertyValue(const OUString& rPropertyName)
break;
case RES_VERT_ORIENT:
{
- SwFormatVertOrient aVertOrient;
+ std::shared_ptr<SfxPoolItem> aVertOrient;
if (SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aVertOrient))
{
- aVertOrient.QueryValue( aRet, pEntry->nMemberId );
+ aVertOrient->QueryValue( aRet, pEntry->nMemberId );
}
}
break;