Update ooo320-m1
[ooovba.git] / writerfilter / source / doctok / WW8CpAndFc.cxx
blob772f593033a875c3d045135e1e1abb8361952604
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WW8CpAndFc.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <WW8CpAndFc.hxx>
33 #include <iterator>
34 #include <algorithm>
35 #include <string>
36 #include <map>
38 namespace writerfilter {
39 namespace doctok
41 using namespace ::std;
43 bool operator < (const Cp & rA, const Cp & rB)
45 return rA.nCp < rB.nCp;
48 bool operator == (const Cp & rA, const Cp & rB)
50 return rA.nCp == rB.nCp;
53 string Cp::toString() const
55 char sBuffer[256];
57 snprintf(sBuffer, 255, "%" SAL_PRIxUINT32 "", get());
59 return string(sBuffer);
62 ostream & operator << (ostream & o, const Cp & rCp)
64 return o << rCp.toString();
67 bool operator < (const Fc & rA, const Fc & rB)
69 return rA.mnFc < rB.mnFc;
72 bool operator == (const Fc & rA, const Fc & rB)
74 return rA.mnFc == rB.mnFc;
77 string Fc::toString() const
79 char sBuffer[256];
81 snprintf(sBuffer, 255, "(%" SAL_PRIxUINT32 ", %s)", static_cast<sal_uInt32>(get()),
82 isComplex() ? "true" : "false");
84 return string(sBuffer);
87 ostream & operator << (ostream & o, const Fc & rFc)
90 return o << rFc.toString();
93 bool operator < (const CpAndFc & rA, const CpAndFc & rB)
95 bool bResult = false;
97 if (rA.mCp < rB.mCp)
98 bResult = true;
99 else if (rA.mCp == rB.mCp && rA.mType < rB.mType)
100 bResult = true;
102 return bResult;
105 bool operator == (const CpAndFc & rA, const CpAndFc & rB)
107 return rA.mCp == rB.mCp;
110 ostream & operator << (ostream & o, const CpAndFc & rCpAndFc)
112 return o << rCpAndFc.toString();
115 ostream & operator << (ostream & o, const CpAndFcs & rCpAndFcs)
117 copy(rCpAndFcs.begin(), rCpAndFcs.end(),
118 ostream_iterator<CpAndFc>(o, ", "));
120 char sBuffer[256];
122 snprintf(sBuffer, 255, "%" SAL_PRI_SIZET "u", rCpAndFcs.size());
123 o << sBuffer;
125 return o;
128 CpAndFc::CpAndFc(const Cp & rCp, const Fc & rFc, PropertyType eType_)
129 : mCp(rCp), mFc(rFc), mType(eType_)