/* -*- 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 .
*/
/** 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 )
{
css::uno::Sequence< sal_Int8 > aSeq; if( !(rAny >>= aSeq) ) return;
// 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
sal_uInt16 nLayerIndex = 0; for( constauto& pCurrentLayer : maLayers )
{
SdrLayerID nCurrentID = pCurrentLayer->GetID(); if ( rViewLayerSet.IsSet(nCurrentID) )
{
nLayerPos = nLayerIndex;
nByteIndex = nLayerPos / 8; if (nByteIndex > 31) continue; // skip position, if too large for bitfield
nBitpos = nLayerPos % 8;
aTmp[nByteIndex] |= (1 << nBitpos);
}
++nLayerIndex;
}
// 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 );
std::transform(aTmp, aTmp + nNumBytesSet, aSeq.getArray(),
[](const sal_uInt8 b) { returnstatic_cast<sal_Int8>(b); });
rAny <<= aSeq;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.