LibreOffice Module comphelper (master)  1
basicio.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <comphelper/basicio.hxx>
21 #include <com/sun/star/awt/FontDescriptor.hpp>
22 
23 namespace comphelper
24 {
25 
26 
27 const css::uno::Reference<css::io::XObjectOutputStream>& operator << (
28  const css::uno::Reference<css::io::XObjectOutputStream>& _rxOutStream,
29  const css::awt::FontDescriptor& _rFont)
30 {
31  _rxOutStream->writeUTF( _rFont.Name );
32  _rxOutStream->writeShort( _rFont.Height );
33  _rxOutStream->writeShort( _rFont.Width );
34  _rxOutStream->writeUTF( _rFont.StyleName );
35  _rxOutStream->writeShort( _rFont.Family );
36  _rxOutStream->writeShort( _rFont.CharSet );
37  _rxOutStream->writeShort( _rFont.Pitch );
38  _rxOutStream->writeDouble( _rFont.CharacterWidth );
39  _rxOutStream->writeDouble( _rFont.Weight );
40  _rxOutStream->writeShort( static_cast< sal_Int16 >(_rFont.Slant) );
41  _rxOutStream->writeShort( _rFont.Underline );
42  _rxOutStream->writeShort( _rFont.Strikeout );
43  _rxOutStream->writeDouble( _rFont.Orientation );
44  _rxOutStream->writeBoolean( _rFont.Kerning );
45  _rxOutStream->writeBoolean( _rFont.WordLineMode );
46  _rxOutStream->writeShort( _rFont.Type );
47  return _rxOutStream;
48 }
49 
50 // FontDescriptor
51 
52 const css::uno::Reference<css::io::XObjectInputStream>& operator >> (
53  const css::uno::Reference<css::io::XObjectInputStream>& _rxInStream,
54  css::awt::FontDescriptor& _rFont)
55 {
56  // writing the FontDescriptor
57  _rFont.Name = _rxInStream->readUTF();
58  _rFont.Height = _rxInStream->readShort();
59  _rFont.Width = _rxInStream->readShort();
60  _rFont.StyleName = _rxInStream->readUTF();
61  _rFont.Family = _rxInStream->readShort();
62  _rFont.CharSet = _rxInStream->readShort();
63  _rFont.Pitch = _rxInStream->readShort();
64  _rFont.CharacterWidth = static_cast< float >(_rxInStream->readDouble());
65  _rFont.Weight = static_cast< float >(_rxInStream->readDouble());
66  _rFont.Slant = static_cast<css::awt::FontSlant>(_rxInStream->readShort());
67  _rFont.Underline = _rxInStream->readShort();
68  _rFont.Strikeout = _rxInStream->readShort();
69  _rFont.Orientation = static_cast< float >(_rxInStream->readDouble());
70  _rFont.Kerning = _rxInStream->readBoolean() != 0;
71  _rFont.WordLineMode = _rxInStream->readBoolean() != 0;
72  _rFont.Type = _rxInStream->readShort();
73  return _rxInStream;
74 }
75 
76 
77 const css::uno::Reference<css::io::XObjectInputStream>& operator >> (const css::uno::Reference<css::io::XObjectInputStream>& _rxInStream, bool& _rVal)
78 {
79  _rVal = _rxInStream->readBoolean();
80  return _rxInStream;
81 }
82 
83 
84 const css::uno::Reference<css::io::XObjectOutputStream>& operator << (const css::uno::Reference<css::io::XObjectOutputStream>& _rxOutStream, bool _bVal)
85 {
86  _rxOutStream->writeBoolean(_bVal);
87  return _rxOutStream;
88 }
89 
90 
91 const css::uno::Reference<css::io::XObjectInputStream>& operator >> (const css::uno::Reference<css::io::XObjectInputStream>& _rxInStream, OUString& rStr)
92 {
93  rStr = _rxInStream->readUTF();
94  return _rxInStream;
95 }
96 
97 
98 const css::uno::Reference<css::io::XObjectOutputStream>& operator << (const css::uno::Reference<css::io::XObjectOutputStream>& _rxOutStream, const OUString& rStr)
99 {
100  _rxOutStream->writeUTF(rStr);
101  return _rxOutStream;
102 }
103 
104 
105 const css::uno::Reference<css::io::XObjectInputStream>& operator >> (const css::uno::Reference<css::io::XObjectInputStream>& _rxInStream, sal_Int16& _rValue)
106 {
107  _rValue = _rxInStream->readShort();
108  return _rxInStream;
109 }
110 
111 
112 const css::uno::Reference<css::io::XObjectOutputStream>& operator << (const css::uno::Reference<css::io::XObjectOutputStream>& _rxOutStream, sal_Int16 _nValue)
113 {
114  _rxOutStream->writeShort(_nValue);
115  return _rxOutStream;
116 }
117 
118 
119 const css::uno::Reference<css::io::XObjectInputStream>& operator >> (const css::uno::Reference<css::io::XObjectInputStream>& _rxInStream, sal_uInt16& _rValue)
120 {
121  _rValue = _rxInStream->readShort();
122  return _rxInStream;
123 }
124 
125 
126 const css::uno::Reference<css::io::XObjectOutputStream>& operator << (const css::uno::Reference<css::io::XObjectOutputStream>& _rxOutStream, sal_uInt16 _nValue)
127 {
128  _rxOutStream->writeShort(_nValue);
129  return _rxOutStream;
130 }
131 
132 
133 const css::uno::Reference<css::io::XObjectInputStream>& operator >> (const css::uno::Reference<css::io::XObjectInputStream>& _rxInStream, sal_uInt32& _rValue)
134 {
135  _rValue = _rxInStream->readLong();
136  return _rxInStream;
137 }
138 
139 
140 const css::uno::Reference<css::io::XObjectOutputStream>& operator << (const css::uno::Reference<css::io::XObjectOutputStream>& _rxOutStream, sal_uInt32 _nValue)
141 {
142  _rxOutStream->writeLong(_nValue);
143  return _rxOutStream;
144 }
145 
146 
147 const css::uno::Reference<css::io::XObjectInputStream>& operator >> (const css::uno::Reference<css::io::XObjectInputStream>& _rxInStream, sal_Int32& _rValue)
148 {
149  _rValue = _rxInStream->readLong();
150  return _rxInStream;
151 }
152 
153 
154 const css::uno::Reference<css::io::XObjectOutputStream>& operator << (const css::uno::Reference<css::io::XObjectOutputStream>& _rxOutStream, sal_Int32 _nValue)
155 {
156  _rxOutStream->writeLong(_nValue);
157  return _rxOutStream;
158 }
159 
160 
161 } // namespace comphelper
162 
163 
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const css::uno::Reference< css::io::XObjectOutputStream > & operator<<(const css::uno::Reference< css::io::XObjectOutputStream > &_rxOutStream, const css::awt::FontDescriptor &_rFont)
Definition: basicio.cxx:27
const css::uno::Reference< css::io::XObjectInputStream > & operator>>(const css::uno::Reference< css::io::XObjectInputStream > &_rxInStream, css::awt::FontDescriptor &_rFont)
Definition: basicio.cxx:52