/* -*- 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 .
*/
/* * XXX: BIG RED NOTICE! Changes MUST be binary file format compatible and MUST * be synchronized with Writer's SwTableAutoFmtTbl sw/source/core/doc/tblafmt.cxx
*/
// from SO5 on // in following versions the value of the IDs must be higher const sal_uInt16 AUTOFORMAT_ID_504 = 9801; const sal_uInt16 AUTOFORMAT_DATA_ID_504 = 9802;
const sal_uInt16 AUTOFORMAT_DATA_ID_552 = 9902;
// --- from 680/dr25 on: store strings as UTF-8 const sal_uInt16 AUTOFORMAT_ID_680DR25 = 10021;
// --- 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;
// current version const sal_uInt16 AUTOFORMAT_ID = AUTOFORMAT_ID_31005; const sal_uInt16 AUTOFORMAT_DATA_ID = AUTOFORMAT_DATA_ID_31005;
namespace
{ /// Read an AutoFormatSwBlob from stream.
SvStream& operator>>(SvStream &stream, AutoFormatSwBlob &blob)
{
blob.Reset();
const sal_uInt64 currentPosition = stream.Tell(); const sal_uInt64 blobSize = endOfBlob - currentPosition; // A zero-size indicates an empty blob. This happens when Calc creates a new autoformat, // since it (naturally) doesn't have any writer-specific data to write. if (blobSize)
{
blob.pData.reset(new sal_uInt8[blobSize]);
blob.size = static_cast<std::size_t>(blobSize);
stream.ReadBytes(blob.pData.get(), blob.size);
}
return stream;
}
/// Write an AutoFormatSwBlob to stream.
SvStream& WriteAutoFormatSwBlob(SvStream &stream, const AutoFormatSwBlob &blob)
{ const sal_uInt64 endOfBlob = stream.Tell() + sizeof(sal_uInt64) + blob.size;
stream.WriteUInt64( endOfBlob ); if (blob.size)
stream.WriteBytes(blob.pData.get(), blob.size);
const SfxPoolItem* ScAutoFormatData::GetItem( sal_uInt16 nIndex, sal_uInt16 nWhich ) const
{ const ScAutoFormatDataField& rField = GetField( nIndex ); switch( nWhich )
{ case ATTR_FONT: return &rField.GetFont(); case ATTR_FONT_HEIGHT: return &rField.GetHeight(); case ATTR_FONT_WEIGHT: return &rField.GetWeight(); case ATTR_FONT_POSTURE: return &rField.GetPosture(); case ATTR_CJK_FONT: return &rField.GetCJKFont(); case ATTR_CJK_FONT_HEIGHT: return &rField.GetCJKHeight(); case ATTR_CJK_FONT_WEIGHT: return &rField.GetCJKWeight(); case ATTR_CJK_FONT_POSTURE: return &rField.GetCJKPosture(); case ATTR_CTL_FONT: return &rField.GetCTLFont(); case ATTR_CTL_FONT_HEIGHT: return &rField.GetCTLHeight(); case ATTR_CTL_FONT_WEIGHT: return &rField.GetCTLWeight(); case ATTR_CTL_FONT_POSTURE: return &rField.GetCTLPosture(); case ATTR_FONT_UNDERLINE: return &rField.GetUnderline(); case ATTR_FONT_OVERLINE: return &rField.GetOverline(); case ATTR_FONT_CROSSEDOUT: return &rField.GetCrossedOut(); case ATTR_FONT_CONTOUR: return &rField.GetContour(); case ATTR_FONT_SHADOWED: return &rField.GetShadowed(); case ATTR_FONT_COLOR: return &rField.GetColor(); case ATTR_BORDER: return &rField.GetBox(); case ATTR_BORDER_TLBR: return &rField.GetTLBR(); case ATTR_BORDER_BLTR: return &rField.GetBLTR(); case ATTR_BACKGROUND: return &rField.GetBackground(); case ATTR_HOR_JUSTIFY: return &rField.GetHorJustify(); case ATTR_VER_JUSTIFY: return &rField.GetVerJustify(); case ATTR_STACKED: return &rField.GetStacked(); case ATTR_MARGIN: return &rField.GetMargin(); case ATTR_LINEBREAK: return &rField.GetLinebreak(); case ATTR_ROTATE_VALUE: return &rField.GetRotateAngle(); case ATTR_ROTATE_MODE: return &rField.GetRotateMode();
} return nullptr;
}
void ScAutoFormatData::PutItem( sal_uInt16 nIndex, const SfxPoolItem& rItem )
{
ScAutoFormatDataField& rField = GetField( nIndex ); switch( rItem.Which() )
{ case ATTR_FONT: rField.SetFont( rItem.StaticWhichCast(ATTR_FONT) ); break; case ATTR_FONT_HEIGHT: rField.SetHeight( rItem.StaticWhichCast(ATTR_FONT_HEIGHT) ); break; case ATTR_FONT_WEIGHT: rField.SetWeight( rItem.StaticWhichCast(ATTR_FONT_WEIGHT) ); break; case ATTR_FONT_POSTURE: rField.SetPosture( rItem.StaticWhichCast(ATTR_FONT_POSTURE) ); break; case ATTR_CJK_FONT: rField.SetCJKFont( rItem.StaticWhichCast(ATTR_CJK_FONT) ); break; case ATTR_CJK_FONT_HEIGHT: rField.SetCJKHeight( rItem.StaticWhichCast(ATTR_CJK_FONT_HEIGHT) ); break; case ATTR_CJK_FONT_WEIGHT: rField.SetCJKWeight( rItem.StaticWhichCast(ATTR_CJK_FONT_WEIGHT) ); break; case ATTR_CJK_FONT_POSTURE: rField.SetCJKPosture( rItem.StaticWhichCast(ATTR_CJK_FONT_POSTURE) ); break; case ATTR_CTL_FONT: rField.SetCTLFont( rItem.StaticWhichCast(ATTR_CTL_FONT) ); break; case ATTR_CTL_FONT_HEIGHT: rField.SetCTLHeight( rItem.StaticWhichCast(ATTR_CTL_FONT_HEIGHT) ); break; case ATTR_CTL_FONT_WEIGHT: rField.SetCTLWeight( rItem.StaticWhichCast(ATTR_CTL_FONT_WEIGHT) ); break; case ATTR_CTL_FONT_POSTURE: rField.SetCTLPosture( rItem.StaticWhichCast(ATTR_CTL_FONT_POSTURE) ); break; case ATTR_FONT_UNDERLINE: rField.SetUnderline( rItem.StaticWhichCast(ATTR_FONT_UNDERLINE) ); break; case ATTR_FONT_OVERLINE: rField.SetOverline( rItem.StaticWhichCast(ATTR_FONT_OVERLINE) ); break; case ATTR_FONT_CROSSEDOUT: rField.SetCrossedOut( rItem.StaticWhichCast(ATTR_FONT_CROSSEDOUT) ); break; case ATTR_FONT_CONTOUR: rField.SetContour( rItem.StaticWhichCast(ATTR_FONT_CONTOUR) ); break; case ATTR_FONT_SHADOWED: rField.SetShadowed( rItem.StaticWhichCast(ATTR_FONT_SHADOWED) ); break; case ATTR_FONT_COLOR: rField.SetColor( rItem.StaticWhichCast(ATTR_FONT_COLOR) ); break; case ATTR_BORDER: rField.SetBox( rItem.StaticWhichCast(ATTR_BORDER) ); break; case ATTR_BORDER_TLBR: rField.SetTLBR( rItem.StaticWhichCast(ATTR_BORDER_TLBR) ); break; case ATTR_BORDER_BLTR: rField.SetBLTR( rItem.StaticWhichCast(ATTR_BORDER_BLTR) ); break; case ATTR_BACKGROUND: rField.SetBackground( rItem.StaticWhichCast(ATTR_BACKGROUND) ); break; case ATTR_HOR_JUSTIFY: rField.SetHorJustify( rItem.StaticWhichCast(ATTR_HOR_JUSTIFY) ); break; case ATTR_VER_JUSTIFY: rField.SetVerJustify( rItem.StaticWhichCast(ATTR_VER_JUSTIFY) ); break; case ATTR_STACKED: rField.SetStacked( rItem.StaticWhichCast(ATTR_STACKED) ); break; case ATTR_MARGIN: rField.SetMargin( rItem.StaticWhichCast(ATTR_MARGIN) ); break; case ATTR_LINEBREAK: rField.SetLinebreak( rItem.StaticWhichCast(ATTR_LINEBREAK) ); break; case ATTR_ROTATE_VALUE: rField.SetRotateAngle( rItem.StaticWhichCast(ATTR_ROTATE_VALUE) ); break; case ATTR_ROTATE_MODE: rField.SetRotateMode( rItem.StaticWhichCast(ATTR_ROTATE_MODE) ); break;
}
}
for (sal_uInt16 i=0; i<16; i++)
{
pData->PutItem( i, aBox );
pData->PutItem( i, aFontItem );
pData->PutItem( i, aCJKFontItem );
pData->PutItem( i, aCTLFontItem );
aHeight.SetWhich( ATTR_FONT_HEIGHT );
pData->PutItem( i, aHeight );
aHeight.SetWhich( ATTR_CJK_FONT_HEIGHT );
pData->PutItem( i, aHeight );
aHeight.SetWhich( ATTR_CTL_FONT_HEIGHT );
pData->PutItem( i, aHeight ); if (i<4) // top: white on blue
{
pData->PutItem( i, aWhiteText );
pData->PutItem( i, aBlueBack );
} elseif ( i%4 == 0 ) // left: white on gray70
{
pData->PutItem( i, aWhiteText );
pData->PutItem( i, aGray70Back );
} elseif ( i%4 == 3 || i >= 12 ) // right and bottom: black on gray20
{
pData->PutItem( i, aBlackText );
pData->PutItem( i, aGray20Back );
} else// center: black on white
{
pData->PutItem( i, aBlackText );
pData->PutItem( i, aWhiteBack );
}
}
// there has to at least be a sal_uInt16 header const size_t nMaxRecords = rStream.remainingSize() / sizeof(sal_uInt16); if (nCnt > nMaxRecords)
{
SAL_WARN("sc", "Parsing error: " << nMaxRecords << " max possible entries, but " << nCnt << " claimed, truncating");
nCnt = nMaxRecords;
}
// Attention: A common header has to be saved
rStream.WriteUInt16( AUTOFORMAT_ID )
.WriteUChar( 2 ) // Number of chars of the header including this
.WriteUChar( ::GetSOStoreTextEncoding(
osl_getThreadTextEncoding() ) );
m_aVersions.Write(rStream, fileVersion);
bRet &= (rStream.GetError() == ERRCODE_NONE);
rStream.WriteUInt16( m_Data.size() - 1 );
bRet &= (rStream.GetError() == ERRCODE_NONE);
MapType::iterator it = m_Data.begin(), itEnd = m_Data.end(); if (it != itEnd)
{ for (++it; bRet && it != itEnd; ++it) // Skip the first item.
{
bRet &= it->second->Save(rStream, fileVersion);
}
}
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.