1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include <WW8CpAndFc.hxx>
25 
26 #include <iterator>
27 #include <algorithm>
28 #include <string>
29 #include <map>
30 
31 namespace writerfilter {
32 namespace doctok
33 {
34 using namespace ::std;
35 
operator <(const Cp & rA,const Cp & rB)36 bool operator < (const Cp & rA, const Cp & rB)
37 {
38     return rA.nCp < rB.nCp;
39 }
40 
operator ==(const Cp & rA,const Cp & rB)41 bool operator == (const Cp & rA, const Cp & rB)
42 {
43     return rA.nCp == rB.nCp;
44 }
45 
toString() const46 string Cp::toString() const
47 {
48     char sBuffer[256];
49 
50     snprintf(sBuffer, 255, "%" SAL_PRIxUINT32 "", get());
51 
52     return string(sBuffer);
53 }
54 
operator <<(ostream & o,const Cp & rCp)55 ostream & operator << (ostream & o, const Cp & rCp)
56 {
57     return o << rCp.toString();
58 }
59 
operator <(const Fc & rA,const Fc & rB)60 bool operator < (const Fc & rA, const Fc & rB)
61 {
62     return rA.mnFc < rB.mnFc;
63 }
64 
operator ==(const Fc & rA,const Fc & rB)65 bool operator == (const Fc & rA, const Fc & rB)
66 {
67     return rA.mnFc == rB.mnFc;
68 }
69 
toString() const70 string Fc::toString() const
71 {
72     char sBuffer[256];
73 
74     snprintf(sBuffer, 255, "(%" SAL_PRIxUINT32 ", %s)", static_cast<sal_uInt32>(get()),
75              isComplex() ? "true" : "false");
76 
77     return string(sBuffer);
78 }
79 
operator <<(ostream & o,const Fc & rFc)80 ostream & operator << (ostream & o, const Fc & rFc)
81 {
82 
83     return o << rFc.toString();
84 }
85 
operator <(const CpAndFc & rA,const CpAndFc & rB)86 bool operator < (const CpAndFc & rA, const CpAndFc & rB)
87 {
88     bool bResult = false;
89 
90     if (rA.mCp < rB.mCp)
91         bResult = true;
92     else if (rA.mCp == rB.mCp && rA.mType < rB.mType)
93         bResult = true;
94 
95     return bResult;
96 }
97 
operator ==(const CpAndFc & rA,const CpAndFc & rB)98 bool operator == (const CpAndFc & rA, const CpAndFc & rB)
99 {
100     return rA.mCp == rB.mCp;
101 }
102 
operator <<(ostream & o,const CpAndFc & rCpAndFc)103 ostream & operator << (ostream & o, const CpAndFc & rCpAndFc)
104 {
105     return o << rCpAndFc.toString();
106 }
107 
operator <<(ostream & o,const CpAndFcs & rCpAndFcs)108 ostream & operator << (ostream & o, const CpAndFcs & rCpAndFcs)
109 {
110     copy(rCpAndFcs.begin(), rCpAndFcs.end(),
111          ostream_iterator<CpAndFc>(o, ", "));
112 
113     char sBuffer[256];
114 
115     snprintf(sBuffer, 255, "%" SAL_PRI_SIZET "u", rCpAndFcs.size());
116     o << sBuffer;
117 
118     return o;
119 }
120 
CpAndFc(const Cp & rCp,const Fc & rFc,PropertyType eType_)121 CpAndFc::CpAndFc(const Cp & rCp, const Fc & rFc, PropertyType eType_)
122 : mCp(rCp), mFc(rFc), mType(eType_)
123 {
124 }
125 
126 }}
127