summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2018-09-08 00:41:47 +0200
committerRegina Henschel <rb.henschel@t-online.de>2018-09-12 09:24:05 +0200
commitd52c8fd4cc025ca9da474a20aa0f5514032273e2 (patch)
tree33e628c6ef9c4bd707edbe360edac69fd5a76fb9 /svx
parent1b267db43b35cc0dcd6d50712efe52ed32fa6e7b (diff)
tdf#119392 write bitfield in <draw:layer-set> order
The view uses the SdrLayerIDSet bitfield in layer ID order. But file format knows no layer IDs and on loading the bitfield is interpreted in the layer order given by <draw:layer-set> element. Therefore reorder the bits on saving according <draw:layer-set>, which is order in SdrLayerAdmin. Change-Id: Id349dc7f42338e35ca8cc3b6409d061213b01691 Reviewed-on: https://gerrit.libreoffice.org/60178 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdlayer.cxx74
1 files changed, 47 insertions, 27 deletions
diff --git a/svx/source/svdraw/svdlayer.cxx b/svx/source/svdraw/svdlayer.cxx
index d17b61dbf1f0..b40f3fa0dc90 100644
--- a/svx/source/svdraw/svdlayer.cxx
+++ b/svx/source/svdraw/svdlayer.cxx
@@ -43,7 +43,7 @@ void SdrLayerIDSet::operator&=(const SdrLayerIDSet& r2ndSet)
}
}
-/** initialize this set with a uno sequence of sal_Int8
+/** initialize this set with a uno sequence of sal_Int8 (e.g. as stored in settings.xml)
*/
void SdrLayerIDSet::PutValue( const css::uno::Any & rAny )
{
@@ -67,32 +67,6 @@ void SdrLayerIDSet::PutValue( const css::uno::Any & rAny )
}
}
-/** returns a uno sequence of sal_Int8
-*/
-void SdrLayerIDSet::QueryValue( css::uno::Any & rAny ) const
-{
- sal_Int16 nNumBytesSet = 0;
- sal_Int16 nIndex;
- for( nIndex = 31; nIndex >= 00; nIndex-- )
- {
- if( 0 != aData[nIndex] )
- {
- nNumBytesSet = nIndex + 1;
- break;
- }
- }
-
- css::uno::Sequence< sal_Int8 > aSeq( nNumBytesSet );
-
- for( nIndex = 0; nIndex < nNumBytesSet; nIndex++ )
- {
- aSeq[nIndex] = static_cast<sal_Int8>(aData[nIndex]);
- }
-
- rAny <<= aSeq;
-}
-
-
SdrLayer::SdrLayer(SdrLayerID nNewID, const OUString& rNewName) :
maName(rNewName), pModel(nullptr), nType(0), nID(nNewID)
{
@@ -366,5 +340,51 @@ void SdrLayerAdmin::getLockedLayersODF( SdrLayerIDSet& rOutSet) const
}
}
+ // Generates a bitfield for settings.xml from the SdrLayerIDSet.
+ // Output is a uno sequence of BYTE (which is 'short' in API).
+void SdrLayerAdmin::QueryValue(const SdrLayerIDSet& rViewLayerSet, css::uno::Any& rAny)
+{
+ // tdf#119392 The SdrLayerIDSet in a view is ordered according LayerID, but in file
+ // the bitfield is interpreted in order of layers in <draw:layer-set>.
+ // First generate a new bitfield based on rViewLayerSet in the needed order.
+ sal_uInt8 aTmp[32]; // 256 bits in settings.xml makes byte 0 to 31
+ for (auto nIndex = 0; nIndex <32; nIndex++)
+ {
+ aTmp[nIndex] = 0;
+ }
+ sal_uInt8 nByteIndex = 0;
+ sal_uInt8 nBitpos = 0;
+ sal_uInt16 nLayerPos = 0; // Position of the layer in member aLayer and in <draw:layer-set> in file
+ for( SdrLayer* pCurrentLayer : aLayer )
+ {
+ SdrLayerID nCurrentID = pCurrentLayer->GetID();
+ if ( rViewLayerSet.IsSet(nCurrentID) )
+ {
+ nLayerPos = GetLayerPos(pCurrentLayer);
+ nByteIndex = nLayerPos / 8;
+ if (nByteIndex > 31)
+ continue; // skip position, if too large for bitfield
+ nBitpos = nLayerPos % 8;
+ aTmp[nByteIndex] |= (1 << nBitpos);
+ }
+ }
+
+ // Second transform the bitfield to byte sequence, same as in previous version of QueryValue
+ sal_uInt8 nNumBytesSet = 0;
+ for( auto nIndex = 31; nIndex >= 0; nIndex--)
+ {
+ if( 0 != aTmp[nIndex] )
+ {
+ nNumBytesSet = nIndex + 1;
+ break;
+ }
+ }
+ css::uno::Sequence< sal_Int8 > aSeq( nNumBytesSet );
+ for( auto nIndex = 0; nIndex < nNumBytesSet; nIndex++ )
+ {
+ aSeq[nIndex] = static_cast<sal_Int8>(aTmp[nIndex]);
+ }
+ rAny <<= aSeq;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */