bump product version to 6.4.0.3
[LibreOffice.git] / editeng / source / items / legacyitem.cxx
blobf3a0ba2f6d0f04748ea1f3b8dd76b2cfbe8088ae
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <editeng/legacyitem.hxx>
21 #include <unotools/fontdefs.hxx>
22 #include <tools/tenccvt.hxx>
23 #include <tools/stream.hxx>
24 #include <comphelper/fileformat.h>
25 #include <vcl/graph.hxx>
26 #include <vcl/GraphicObject.hxx>
27 #include <osl/diagnose.h>
28 #include <tools/urlobj.hxx>
29 #include <editeng/fontitem.hxx>
30 #include <editeng/fhgtitem.hxx>
31 #include <editeng/wghtitem.hxx>
32 #include <editeng/postitem.hxx>
33 #include <editeng/udlnitem.hxx>
34 #include <editeng/crossedoutitem.hxx>
35 #include <editeng/colritem.hxx>
36 #include <editeng/boxitem.hxx>
37 #include <editeng/borderline.hxx>
38 #include <editeng/lineitem.hxx>
39 #include <editeng/brushitem.hxx>
40 #include <editeng/editerr.hxx>
41 #include <editeng/adjustitem.hxx>
42 #include <editeng/justifyitem.hxx>
43 #include <editeng/frmdiritem.hxx>
44 #include <editeng/formatbreakitem.hxx>
45 #include <editeng/keepitem.hxx>
46 #include <editeng/shaditem.hxx>
47 #include <tools/GenericTypeSerializer.hxx>
50 void Create_legacy_direct_set(SvxFontHeightItem& rItem, sal_uInt32 nH, sal_uInt16 nP, MapUnit eP)
52 rItem.legacy_direct_set(nH, nP, eP);
55 namespace legacy
57 namespace SvxFont
59 sal_uInt16 GetVersion(sal_uInt16)
61 return 0;
64 void Create(SvxFontItem& rItem, SvStream& rStrm, sal_uInt16)
66 sal_uInt8 _eFamily, eFontPitch, eFontTextEncoding;
67 OUString aName, aStyle;
68 rStrm.ReadUChar( _eFamily );
69 rStrm.ReadUChar( eFontPitch );
70 rStrm.ReadUChar( eFontTextEncoding );
72 // UNICODE: rStrm >> aName;
73 aName = rStrm.ReadUniOrByteString(rStrm.GetStreamCharSet());
75 // UNICODE: rStrm >> aStyle;
76 aStyle = rStrm.ReadUniOrByteString(rStrm.GetStreamCharSet());
78 // Set the "correct" textencoding
79 eFontTextEncoding = static_cast<sal_uInt8>(GetSOLoadTextEncoding( eFontTextEncoding ));
81 // at some point, the StarBats changes from ANSI font to SYMBOL font
82 if ( RTL_TEXTENCODING_SYMBOL != eFontTextEncoding && aName == "StarBats" )
83 eFontTextEncoding = RTL_TEXTENCODING_SYMBOL;
85 // Check if we have stored unicode
86 sal_uInt64 const nStreamPos = rStrm.Tell();
87 // #define STORE_UNICODE_MAGIC_MARKER 0xFE331188
88 sal_uInt32 nMagic = 0xFE331188;
89 rStrm.ReadUInt32( nMagic );
90 if ( nMagic == 0xFE331188 )
92 aName = rStrm.ReadUniOrByteString( RTL_TEXTENCODING_UNICODE );
93 aStyle = rStrm.ReadUniOrByteString( RTL_TEXTENCODING_UNICODE );
95 else
97 rStrm.Seek( nStreamPos );
100 rItem.SetFamilyName(aName);
101 rItem.SetStyleName(aStyle);
102 rItem.SetFamily(static_cast<FontFamily>(_eFamily));
103 rItem.SetPitch(static_cast<FontPitch>(eFontPitch));
104 rItem.SetCharSet(static_cast<rtl_TextEncoding>(eFontTextEncoding));
107 SvStream& Store(const SvxFontItem& rItem, SvStream& rStrm, sal_uInt16)
109 const bool bToBats(IsStarSymbol(rItem.GetFamilyName()));
111 rStrm.WriteUChar(rItem.GetFamily()).WriteUChar(rItem.GetPitch()).WriteUChar(bToBats ?
112 RTL_TEXTENCODING_SYMBOL :
113 GetSOStoreTextEncoding(rItem.GetCharSet()));
115 const OUString aStoreFamilyName(bToBats ? "StarBats" : rItem.GetFamilyName());
117 rStrm.WriteUniOrByteString(aStoreFamilyName, rStrm.GetStreamCharSet());
118 rStrm.WriteUniOrByteString(rItem.GetStyleName(), rStrm.GetStreamCharSet());
120 return rStrm;
124 namespace SvxFontHeight
126 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
128 return (nFileFormatVersion <= SOFFICE_FILEFORMAT_40)
129 ? FONTHEIGHT_16_VERSION
130 : FONTHEIGHT_UNIT_VERSION;
133 void Create(SvxFontHeightItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
135 sal_uInt16 nsize, nprop = 0;
136 MapUnit nPropUnit = MapUnit::MapRelative;
138 rStrm.ReadUInt16( nsize );
140 if( FONTHEIGHT_16_VERSION <= nItemVersion )
141 rStrm.ReadUInt16( nprop );
142 else
144 sal_uInt8 nP;
145 rStrm .ReadUChar( nP );
146 nprop = static_cast<sal_uInt16>(nP);
149 if( FONTHEIGHT_UNIT_VERSION <= nItemVersion )
151 sal_uInt16 nTmp;
152 rStrm.ReadUInt16( nTmp );
153 nPropUnit = static_cast<MapUnit>(nTmp);
156 Create_legacy_direct_set(rItem, nsize, nprop, nPropUnit);
159 SvStream& Store(const SvxFontHeightItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
161 rStrm.WriteUInt16( rItem.GetHeight() );
163 if( FONTHEIGHT_UNIT_VERSION <= nItemVersion )
164 rStrm.WriteUInt16( rItem.GetProp() ).WriteUInt16( static_cast<sal_uInt16>(rItem.GetPropUnit()) );
165 else
167 // When exporting to the old versions the relative information is lost
168 // when there is no percentage
169 sal_uInt16 _nProp = rItem.GetProp();
170 if( MapUnit::MapRelative != rItem.GetPropUnit() )
171 _nProp = 100;
172 rStrm.WriteUInt16( _nProp );
174 return rStrm;
178 namespace SvxWeight
180 sal_uInt16 GetVersion(sal_uInt16)
182 return 0;
185 void Create(SvxWeightItem& rItem, SvStream& rStrm, sal_uInt16)
187 sal_uInt8 nWeight(0);
188 rStrm.ReadUChar(nWeight);
189 rItem.SetValue(static_cast<FontWeight>(nWeight));
192 SvStream& Store(const SvxWeightItem& rItem, SvStream& rStrm, sal_uInt16)
194 rStrm.WriteUChar(rItem.GetValue());
195 return rStrm;
199 namespace SvxPosture
201 sal_uInt16 GetVersion(sal_uInt16)
203 return 0;
206 void Create(SvxPostureItem& rItem, SvStream& rStrm, sal_uInt16)
208 sal_uInt8 nPosture(0);
209 rStrm.ReadUChar(nPosture);
210 rItem.SetValue(static_cast<FontItalic>(nPosture));
213 SvStream& Store(const SvxPostureItem& rItem, SvStream& rStrm, sal_uInt16)
215 rStrm.WriteUChar( rItem.GetValue() );
216 return rStrm;
220 namespace SvxTextLine // SvxUnderlineItem, SvxOverlineItem -> SvxTextLineItem
222 sal_uInt16 GetVersion(sal_uInt16)
224 return 0;
227 void Create(SvxTextLineItem& rItem, SvStream& rStrm, sal_uInt16)
229 sal_uInt8 nState(0);
230 rStrm.ReadUChar(nState);
231 rItem.SetValue(static_cast<FontLineStyle>(nState));
232 // GetColor() is *not* saved/loaded ?!?
235 SvStream& Store(const SvxTextLineItem& rItem, SvStream& rStrm, sal_uInt16)
237 rStrm.WriteUChar(rItem.GetValue());
238 // GetColor() is *not* saved/loaded ?!?
239 return rStrm;
243 namespace SvxCrossedOut
245 sal_uInt16 GetVersion(sal_uInt16)
247 return 0;
250 void Create(SvxCrossedOutItem& rItem, SvStream& rStrm, sal_uInt16)
252 sal_uInt8 eCross(0);
253 rStrm.ReadUChar(eCross);
254 rItem.SetValue(static_cast<FontStrikeout>(eCross));
257 SvStream& Store(const SvxCrossedOutItem& rItem, SvStream& rStrm, sal_uInt16)
259 rStrm.WriteUChar(rItem.GetValue());
260 return rStrm;
264 namespace SvxColor
266 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
268 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFileFormatVersion ||
269 SOFFICE_FILEFORMAT_40==nFileFormatVersion ||
270 SOFFICE_FILEFORMAT_50==nFileFormatVersion,
271 "SvxColorItem: Is there a new file format? ");
272 return SOFFICE_FILEFORMAT_50 >= nFileFormatVersion ? VERSION_USEAUTOCOLOR : 0;
275 void Create(SvxColorItem& rItem, SvStream& rStrm, sal_uInt16)
277 Color aColor(COL_AUTO);
278 tools::GenericTypeSerializer aSerializer(rStrm);
279 aSerializer.readColor(aColor);
280 rItem.SetValue(aColor);
283 SvStream& Store(const SvxColorItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
285 tools::GenericTypeSerializer aSerializer(rStrm);
286 if( VERSION_USEAUTOCOLOR == nItemVersion && COL_AUTO == rItem.GetValue() )
287 aSerializer.writeColor(COL_BLACK);
288 else
289 aSerializer.writeColor(rItem.GetValue());
290 return rStrm;
294 namespace SvxBox
296 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
298 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFileFormatVersion ||
299 SOFFICE_FILEFORMAT_40==nFileFormatVersion ||
300 SOFFICE_FILEFORMAT_50==nFileFormatVersion,
301 "SvxBoxItem: Is there a new file format?" );
302 return SOFFICE_FILEFORMAT_31==nFileFormatVersion ||
303 SOFFICE_FILEFORMAT_40==nFileFormatVersion ? 0 : BOX_BORDER_STYLE_VERSION;
306 /// Item version for saved border lines. The old version saves the line without style information.
307 const int BORDER_LINE_OLD_VERSION = 0;
308 /// Item version for saved border lies. The new version includes line style.
309 const int BORDER_LINE_WITH_STYLE_VERSION = 1;
311 /// Creates a border line from a stream.
312 static ::editeng::SvxBorderLine CreateBorderLine(SvStream &stream, sal_uInt16 version)
314 sal_uInt16 nOutline, nInline, nDistance;
315 sal_uInt16 nStyle = css::table::BorderLineStyle::NONE;
316 Color aColor;
317 tools::GenericTypeSerializer aSerializer(stream);
318 aSerializer.readColor(aColor);
319 stream.ReadUInt16( nOutline ).ReadUInt16( nInline ).ReadUInt16( nDistance );
321 if (version >= BORDER_LINE_WITH_STYLE_VERSION)
322 stream.ReadUInt16( nStyle );
324 ::editeng::SvxBorderLine border(&aColor);
325 border.GuessLinesWidths(static_cast<SvxBorderLineStyle>(nStyle), nOutline, nInline, nDistance);
326 return border;
329 /// Retrieves a BORDER_LINE_* version from a BOX_BORDER_* version.
330 static sal_uInt16 BorderLineVersionFromBoxVersion(sal_uInt16 boxVersion)
332 return (boxVersion >= BOX_BORDER_STYLE_VERSION)? BORDER_LINE_WITH_STYLE_VERSION : BORDER_LINE_OLD_VERSION;
335 void Create(SvxBoxItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
337 sal_uInt16 nDistance(0);
338 rStrm.ReadUInt16( nDistance );
339 SvxBoxItemLine aLineMap[4] = { SvxBoxItemLine::TOP, SvxBoxItemLine::LEFT,
340 SvxBoxItemLine::RIGHT, SvxBoxItemLine::BOTTOM };
341 sal_Int8 cLine(0);
343 while (rStrm.good())
345 rStrm.ReadSChar( cLine );
347 if( cLine > 3 )
348 break;
350 ::editeng::SvxBorderLine aBorder = CreateBorderLine(rStrm, BorderLineVersionFromBoxVersion(nItemVersion));
351 rItem.SetLine( &aBorder, aLineMap[cLine] );
354 if( nItemVersion >= BOX_4DISTS_VERSION && (cLine&0x10) != 0 )
356 for(const SvxBoxItemLine & i : aLineMap)
358 sal_uInt16 nDist;
359 rStrm.ReadUInt16( nDist );
360 rItem.SetDistance( nDist, i );
363 else
365 rItem.SetAllDistances(nDistance);
369 /// Store a border line to a stream.
370 static SvStream& StoreBorderLine(SvStream &stream, const ::editeng::SvxBorderLine &l, sal_uInt16 version)
372 tools::GenericTypeSerializer aSerializer(stream);
373 aSerializer.writeColor(l.GetColor());
375 stream.WriteUInt16( l.GetOutWidth() )
376 .WriteUInt16( l.GetInWidth() )
377 .WriteUInt16( l.GetDistance() );
379 if (version >= BORDER_LINE_WITH_STYLE_VERSION)
380 stream.WriteUInt16( static_cast<sal_uInt16>(l.GetBorderLineStyle()) );
382 return stream;
385 SvStream& Store(const SvxBoxItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
387 rStrm.WriteUInt16( rItem.GetSmallestDistance() );
388 const ::editeng::SvxBorderLine* pLine[ 4 ]; // top, left, right, bottom
389 pLine[ 0 ] = rItem.GetTop();
390 pLine[ 1 ] = rItem.GetLeft();
391 pLine[ 2 ] = rItem.GetRight();
392 pLine[ 3 ] = rItem.GetBottom();
394 for( int i = 0; i < 4; i++ )
396 const ::editeng::SvxBorderLine* l = pLine[ i ];
397 if( l )
399 rStrm.WriteSChar(i);
400 StoreBorderLine(rStrm, *l, BorderLineVersionFromBoxVersion(nItemVersion));
403 sal_Int8 cLine = 4;
404 const sal_uInt16 nTopDist(rItem.GetDistance(SvxBoxItemLine::TOP));
405 const sal_uInt16 nLeftDist(rItem.GetDistance(SvxBoxItemLine::LEFT));
406 const sal_uInt16 nRightDist(rItem.GetDistance(SvxBoxItemLine::RIGHT));
407 const sal_uInt16 nBottomDist(rItem.GetDistance(SvxBoxItemLine::BOTTOM));
409 if( nItemVersion >= BOX_4DISTS_VERSION &&
410 !(nTopDist == nLeftDist &&
411 nTopDist == nRightDist &&
412 nTopDist == nBottomDist) )
414 cLine |= 0x10;
417 rStrm.WriteSChar( cLine );
419 if( nItemVersion >= BOX_4DISTS_VERSION && (cLine & 0x10) != 0 )
421 rStrm.WriteUInt16( nTopDist )
422 .WriteUInt16( nLeftDist )
423 .WriteUInt16( nRightDist )
424 .WriteUInt16( nBottomDist );
427 return rStrm;
431 namespace SvxLine
433 sal_uInt16 GetVersion(sal_uInt16)
435 return 0;
438 void Create(SvxLineItem& rItem, SvStream& rStrm, sal_uInt16)
440 short nOutline, nInline, nDistance;
441 Color aColor;
443 tools::GenericTypeSerializer aSerializer(rStrm);
444 aSerializer.readColor(aColor);
445 rStrm.ReadInt16( nOutline ).ReadInt16( nInline ).ReadInt16( nDistance );
446 if( nOutline )
448 ::editeng::SvxBorderLine aLine( &aColor );
449 aLine.GuessLinesWidths(SvxBorderLineStyle::NONE, nOutline, nInline, nDistance);
450 rItem.SetLine( &aLine );
454 SvStream& Store(const SvxLineItem& rItem, SvStream& rStrm, sal_uInt16)
456 const ::editeng::SvxBorderLine* pLine(rItem.GetLine());
458 if(nullptr != pLine)
460 tools::GenericTypeSerializer aSerializer(rStrm);
461 aSerializer.writeColor(pLine->GetColor());
462 rStrm.WriteInt16( pLine->GetOutWidth() )
463 .WriteInt16( pLine->GetInWidth() )
464 .WriteInt16( pLine->GetDistance() );
466 else
468 tools::GenericTypeSerializer aSerializer(rStrm);
469 aSerializer.writeColor(Color());
470 rStrm.WriteInt16( 0 ).WriteInt16( 0 ).WriteInt16( 0 );
473 return rStrm;
477 namespace SvxBrush
479 sal_uInt16 GetVersion(sal_uInt16)
481 return BRUSH_GRAPHIC_VERSION;
484 const sal_uInt16 LOAD_GRAPHIC = (sal_uInt16(0x0001));
485 const sal_uInt16 LOAD_LINK = (sal_uInt16(0x0002));
486 const sal_uInt16 LOAD_FILTER = (sal_uInt16(0x0004));
488 void Create(SvxBrushItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
490 bool bTrans;
491 Color aTempColor;
492 Color aTempFillColor;
493 sal_Int8 nStyle;
495 rStrm.ReadCharAsBool( bTrans );
496 tools::GenericTypeSerializer aSerializer(rStrm);
497 aSerializer.readColor(aTempColor);
498 aSerializer.readColor(aTempFillColor);
499 rStrm.ReadSChar( nStyle );
501 switch ( nStyle )
503 case 8: // BRUSH_25:
505 sal_uInt32 nRed = aTempColor.GetRed();
506 sal_uInt32 nGreen = aTempColor.GetGreen();
507 sal_uInt32 nBlue = aTempColor.GetBlue();
508 nRed += static_cast<sal_uInt32>(aTempFillColor.GetRed())*2;
509 nGreen += static_cast<sal_uInt32>(aTempFillColor.GetGreen())*2;
510 nBlue += static_cast<sal_uInt32>(aTempFillColor.GetBlue())*2;
511 rItem.SetColor(Color( static_cast<sal_Int8>(nRed/3), static_cast<sal_Int8>(nGreen/3), static_cast<sal_Int8>(nBlue/3) ));
513 break;
515 case 9: // BRUSH_50:
517 sal_uInt32 nRed = aTempColor.GetRed();
518 sal_uInt32 nGreen = aTempColor.GetGreen();
519 sal_uInt32 nBlue = aTempColor.GetBlue();
520 nRed += static_cast<sal_uInt32>(aTempFillColor.GetRed());
521 nGreen += static_cast<sal_uInt32>(aTempFillColor.GetGreen());
522 nBlue += static_cast<sal_uInt32>(aTempFillColor.GetBlue());
523 rItem.SetColor(Color( static_cast<sal_Int8>(nRed/2), static_cast<sal_Int8>(nGreen/2), static_cast<sal_Int8>(nBlue/2) ));
525 break;
527 case 10: // BRUSH_75:
529 sal_uInt32 nRed = aTempColor.GetRed()*2;
530 sal_uInt32 nGreen = aTempColor.GetGreen()*2;
531 sal_uInt32 nBlue = aTempColor.GetBlue()*2;
532 nRed += static_cast<sal_uInt32>(aTempFillColor.GetRed());
533 nGreen += static_cast<sal_uInt32>(aTempFillColor.GetGreen());
534 nBlue += static_cast<sal_uInt32>(aTempFillColor.GetBlue());
535 rItem.SetColor(Color( static_cast<sal_Int8>(nRed/3), static_cast<sal_Int8>(nGreen/3), static_cast<sal_Int8>(nBlue/3) ));
537 break;
539 case 0: // BRUSH_NULL:
540 rItem.SetColor(COL_TRANSPARENT);
541 break;
543 default:
544 rItem.SetColor(aTempColor);
547 if ( nItemVersion >= BRUSH_GRAPHIC_VERSION )
549 sal_uInt16 nDoLoad = 0;
550 sal_Int8 nPos;
552 rStrm.ReadUInt16( nDoLoad );
554 if ( nDoLoad & LOAD_GRAPHIC )
556 Graphic aGraphic;
558 ReadGraphic( rStrm, aGraphic );
559 rItem.SetGraphicObject(GraphicObject(aGraphic));
561 if( SVSTREAM_FILEFORMAT_ERROR == rStrm.GetError() )
563 rStrm.ResetError();
564 rStrm.SetError( ERRCODE_SVX_GRAPHIC_WRONG_FILEFORMAT.MakeWarning() );
568 if ( nDoLoad & LOAD_LINK )
570 // UNICODE: rStrm >> aRel;
571 OUString aRel = rStrm.ReadUniOrByteString(rStrm.GetStreamCharSet());
573 // TODO/MBA: how can we get a BaseURL here?!
574 OSL_FAIL("No BaseURL!");
575 OUString aAbs = INetURLObject::GetAbsURL( "", aRel );
576 DBG_ASSERT( !aAbs.isEmpty(), "Invalid URL!" );
577 rItem.SetGraphicLink(aAbs);
580 if ( nDoLoad & LOAD_FILTER )
582 // UNICODE: rStrm >> maStrFilter;
583 rItem.SetGraphicFilter(rStrm.ReadUniOrByteString(rStrm.GetStreamCharSet()));
586 rStrm.ReadSChar( nPos );
588 rItem.SetGraphicPos(static_cast<SvxGraphicPosition>(nPos));
592 SvStream& Store(const SvxBrushItem& rItem, SvStream& rStrm, sal_uInt16)
594 rStrm.WriteBool( false );
595 tools::GenericTypeSerializer aSerializer(rStrm);
596 aSerializer.writeColor(rItem.GetColor());
597 aSerializer.writeColor(rItem.GetColor());
598 rStrm.WriteSChar( rItem.GetColor().GetTransparency() > 0 ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID
600 sal_uInt16 nDoLoad = 0;
601 const GraphicObject* pGraphicObject(rItem.GetGraphicObject());
603 if (nullptr != pGraphicObject && rItem.GetGraphicLink().isEmpty())
604 nDoLoad |= LOAD_GRAPHIC;
605 if ( !rItem.GetGraphicLink().isEmpty() )
606 nDoLoad |= LOAD_LINK;
607 if ( !rItem.GetGraphicFilter().isEmpty() )
608 nDoLoad |= LOAD_FILTER;
609 rStrm.WriteUInt16( nDoLoad );
611 if (nullptr != pGraphicObject && rItem.GetGraphicLink().isEmpty())
612 WriteGraphic(rStrm, pGraphicObject->GetGraphic());
613 if ( !rItem.GetGraphicLink().isEmpty() )
615 OSL_FAIL("No BaseURL!");
616 // TODO/MBA: how to get a BaseURL?!
617 OUString aRel = INetURLObject::GetRelURL( "", rItem.GetGraphicLink() );
618 // UNICODE: rStrm << aRel;
619 rStrm.WriteUniOrByteString(aRel, rStrm.GetStreamCharSet());
621 if ( !rItem.GetGraphicFilter().isEmpty() )
623 // UNICODE: rStrm << rItem.GetGraphicFilter();
624 rStrm.WriteUniOrByteString(rItem.GetGraphicFilter(), rStrm.GetStreamCharSet());
626 rStrm.WriteSChar( rItem.GetGraphicPos() );
627 return rStrm;
631 namespace SvxAdjust
633 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
635 return (nFileFormatVersion == SOFFICE_FILEFORMAT_31)
636 ? 0 : ADJUST_LASTBLOCK_VERSION;
639 void Create(SvxAdjustItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
641 char eAdjustment;
642 rStrm.ReadChar(eAdjustment);
643 rItem.SetAdjust(static_cast<::SvxAdjust>(eAdjustment));
645 if( nItemVersion >= ADJUST_LASTBLOCK_VERSION )
647 sal_Int8 nFlags;
648 rStrm.ReadSChar( nFlags );
649 rItem.SetAsFlags(nFlags);
653 SvStream& Store(const SvxAdjustItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
655 rStrm.WriteChar( static_cast<char>(rItem.GetAdjust()) );
656 if ( nItemVersion >= ADJUST_LASTBLOCK_VERSION )
658 const sal_Int8 nFlags(rItem.GetAsFlags());
659 rStrm.WriteSChar( nFlags );
661 return rStrm;
665 namespace SvxHorJustify
667 sal_uInt16 GetVersion(sal_uInt16)
669 return 0;
672 void Create(SvxHorJustifyItem& rItem, SvStream& rStrm, sal_uInt16)
674 sal_uInt16 nVal(0);
675 rStrm.ReadUInt16( nVal );
676 rItem.SetValue(static_cast<::SvxCellHorJustify>(nVal));
679 SvStream& Store(const SvxHorJustifyItem& rItem, SvStream& rStrm, sal_uInt16)
681 rStrm.WriteUInt16( static_cast<sal_uInt16>(rItem.GetValue()) );
682 return rStrm;
686 namespace SvxVerJustify
688 sal_uInt16 GetVersion(sal_uInt16)
690 return 0;
693 void Create(SvxVerJustifyItem& rItem, SvStream& rStrm, sal_uInt16)
695 sal_uInt16 nVal(0);
696 rStrm.ReadUInt16( nVal );
697 rItem.SetValue(static_cast<::SvxCellVerJustify>(nVal));
700 SvStream& Store(const SvxVerJustifyItem& rItem, SvStream& rStrm, sal_uInt16)
702 rStrm.WriteUInt16( static_cast<sal_uInt16>(rItem.GetValue()) );
703 return rStrm;
707 namespace SvxFrameDirection
709 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
711 return SOFFICE_FILEFORMAT_50 > nFileFormatVersion ? USHRT_MAX : 0;
714 void Create(SvxFrameDirectionItem& rItem, SvStream& rStrm, sal_uInt16)
716 sal_uInt16 nVal(0);
717 rStrm.ReadUInt16( nVal );
718 rItem.SetValue(static_cast<::SvxFrameDirection>(nVal));
721 SvStream& Store(const SvxFrameDirectionItem& rItem, SvStream& rStrm, sal_uInt16)
723 rStrm.WriteUInt16( static_cast<sal_uInt16>(rItem.GetValue()) );
724 return rStrm;
728 namespace SvxFormatBreak
730 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
732 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFileFormatVersion ||
733 SOFFICE_FILEFORMAT_40==nFileFormatVersion ||
734 SOFFICE_FILEFORMAT_50==nFileFormatVersion,
735 "SvxFormatBreakItem: Is there a new file format? ");
736 return SOFFICE_FILEFORMAT_31==nFileFormatVersion ||
737 SOFFICE_FILEFORMAT_40==nFileFormatVersion ? 0 : FMTBREAK_NOAUTO;
740 void Create(SvxFormatBreakItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
742 sal_Int8 eBreak, bDummy;
743 rStrm.ReadSChar( eBreak );
744 if( FMTBREAK_NOAUTO > nItemVersion )
745 rStrm.ReadSChar( bDummy );
746 rItem.SetValue(static_cast<::SvxBreak>(eBreak));
749 SvStream& Store(const SvxFormatBreakItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
751 rStrm.WriteSChar( rItem.GetEnumValue() );
752 if( FMTBREAK_NOAUTO > nItemVersion )
753 rStrm.WriteSChar( 0x01 );
754 return rStrm;
758 namespace SvxFormatKeep
760 sal_uInt16 GetVersion(sal_uInt16)
762 return 0;
765 void Create(SvxFormatKeepItem& rItem, SvStream& rStrm, sal_uInt16)
767 // derived from SfxBoolItem, but that uses
768 // rStream.ReadCharAsBool( tmp );
769 sal_Int8 bIsKeep;
770 rStrm.ReadSChar( bIsKeep );
771 rItem.SetValue(static_cast<bool>(bIsKeep));
774 SvStream& Store(const SvxFormatKeepItem& rItem, SvStream& rStrm, sal_uInt16)
776 // derived from SfxBoolItem, but that uses
777 // rStream.WriteBool( m_bValue ); // not bool for serialization!
778 rStrm.WriteSChar( static_cast<sal_Int8>(rItem.GetValue()) );
779 return rStrm;
783 namespace SvxShadow
785 sal_uInt16 GetVersion(sal_uInt16)
787 return 0;
790 void Create(SvxShadowItem& rItem, SvStream& rStrm, sal_uInt16)
792 sal_Int8 cLoc;
793 sal_uInt16 _nWidth;
794 bool bTrans;
795 Color aColor;
796 Color aFillColor;
797 sal_Int8 nStyle;
798 rStrm.ReadSChar( cLoc ).ReadUInt16( _nWidth ).ReadCharAsBool( bTrans );
799 tools::GenericTypeSerializer aSerializer(rStrm);
800 aSerializer.readColor(aColor);
801 aSerializer.readColor(aFillColor);
802 rStrm.ReadSChar(nStyle);
803 aColor.SetTransparency(bTrans ? 0xff : 0);
805 rItem.SetLocation(static_cast<SvxShadowLocation>(cLoc));
806 rItem.SetWidth(_nWidth);
807 rItem.SetColor(aColor);
810 SvStream& Store(const SvxShadowItem& rItem, SvStream& rStrm, sal_uInt16)
812 rStrm.WriteSChar( static_cast<sal_uInt8>(rItem.GetLocation()) )
813 .WriteUInt16( rItem.GetWidth() )
814 .WriteBool( rItem.GetColor().GetTransparency() > 0 );
815 tools::GenericTypeSerializer aSerializer(rStrm);
816 aSerializer.writeColor(rItem.GetColor());
817 aSerializer.writeColor(rItem.GetColor());
818 rStrm.WriteSChar( rItem.GetColor().GetTransparency() > 0 ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID
819 return rStrm;
824 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */