Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef STOFF_POSITION_H
00035 #define STOFF_POSITION_H
00036
00037 #include <ostream>
00038
00039 #include <librevenge/librevenge.h>
00040
00041 #include "libstaroffice_internal.hxx"
00042
00047 class STOFFPosition
00048 {
00049 public:
00051 enum AnchorTo { Cell, Char, CharBaseLine, Frame, Paragraph, Page, Unknown };
00052
00053 public:
00055 STOFFPosition() : m_anchorTo(Unknown), m_propertyList() {}
00057 virtual ~STOFFPosition();
00059 void addTo(librevenge::RVNGPropertyList &propList) const
00060 {
00061 librevenge::RVNGPropertyList::Iter i(m_propertyList);
00062 switch (m_anchorTo) {
00063 case Cell:
00064 propList.insert("text:anchor-type", "cell");
00065 break;
00066 case Char:
00067 propList.insert("text:anchor-type", "char");
00068 break;
00069 case CharBaseLine:
00070 propList.insert("text:anchor-type", "as-char");
00071 break;
00072 case Frame:
00073 propList.insert("text:anchor-type", "frame");
00074 break;
00075 case Paragraph:
00076 propList.insert("text:anchor-type", "paragraph");
00077 break;
00078 case Page:
00079 propList.insert("text:anchor-type", "page");
00080 break;
00081 case Unknown:
00082 default:
00083 STOFF_DEBUG_MSG(("STOFFPosition::addTo: unknown anchor\n"));
00084 break;
00085 }
00086 for (i.rewind(); i.next();) {
00087 if (i.child()) {
00088 STOFF_DEBUG_MSG(("STOFFPosition::addTo: find unexpected property child\n"));
00089 propList.insert(i.key(), *i.child());
00090 continue;
00091 }
00092 propList.insert(i.key(), i()->clone());
00093 }
00094 }
00096 void setOrigin(STOFFVec2f const &origin, librevenge::RVNGUnit unit)
00097 {
00098 m_propertyList.insert("svg:x",double(origin[0]), unit);
00099 m_propertyList.insert("svg:y",double(origin[1]), unit);
00100 }
00102 void setSize(STOFFVec2f const &size, librevenge::RVNGUnit unit)
00103 {
00104 if (size.x()>0)
00105 m_propertyList.insert("svg:width",double(size.x()), unit);
00106 else if (size.x()<0)
00107 m_propertyList.insert("fo:min-width",double(-size.x()), unit);
00108 if (size.y()>0)
00109 m_propertyList.insert("svg:height",double(size.y()), unit);
00110 else if (size.y()<0)
00111 m_propertyList.insert("fo:min-height",double(-size.y()), unit);
00112 }
00114 void setAnchor(AnchorTo anchor)
00115 {
00116 m_anchorTo=anchor;
00117 }
00119 friend std::ostream &operator<<(std::ostream &o, STOFFPosition const &pos)
00120 {
00121 o << "prop=[" << pos.m_propertyList.getPropString().cstr() << "],";
00122 return o;
00123 }
00125 bool operator==(STOFFPosition const &f) const
00126 {
00127 return m_anchorTo==f.m_anchorTo && m_propertyList.getPropString()==f.m_propertyList.getPropString();
00128 }
00130 bool operator!=(STOFFPosition const &f) const
00131 {
00132 return !operator==(f);
00133 }
00134
00136 AnchorTo m_anchorTo;
00138 librevenge::RVNGPropertyList m_propertyList;
00139 };
00140
00141 #endif
00142