STOFFPosition.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2 
3 /* libstaroffice
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33 
34 #ifndef STOFF_POSITION_H
35 #define STOFF_POSITION_H
36 
37 #include <ostream>
38 
39 #include <librevenge/librevenge.h>
40 
42 
48 {
49 public:
52 
53 public:
57  , m_propertyList() {}
59  virtual ~STOFFPosition();
61  void addTo(librevenge::RVNGPropertyList &propList) const
62  {
63  librevenge::RVNGPropertyList::Iter i(m_propertyList);
64  switch (m_anchorTo) {
65  case Cell:
66  propList.insert("text:anchor-type", "cell");
67  break;
68  case Char:
69  propList.insert("text:anchor-type", "char");
70  break;
71  case CharBaseLine:
72  propList.insert("text:anchor-type", "as-char");
73  break;
74  case Frame:
75  propList.insert("text:anchor-type", "frame");
76  break;
77  case Paragraph:
78  propList.insert("text:anchor-type", "paragraph");
79  break;
80  case Page:
81  propList.insert("text:anchor-type", "page");
82  break;
83  case Unknown:
84  default:
85  STOFF_DEBUG_MSG(("STOFFPosition::addTo: unknown anchor\n"));
86  break;
87  }
88  for (i.rewind(); i.next();) {
89  if (i.child()) {
90  STOFF_DEBUG_MSG(("STOFFPosition::addTo: find unexpected property child\n"));
91  propList.insert(i.key(), *i.child());
92  continue;
93  }
94  propList.insert(i.key(), i()->clone());
95  }
96  }
98  void setOrigin(STOFFVec2f const &origin, librevenge::RVNGUnit unit)
99  {
100  m_propertyList.insert("svg:x",double(origin[0]), unit);
101  m_propertyList.insert("svg:y",double(origin[1]), unit);
102  }
104  void setSize(STOFFVec2f const &size, librevenge::RVNGUnit unit)
105  {
106  if (size.x()>0)
107  m_propertyList.insert("svg:width",double(size.x()), unit);
108  else if (size.x()<0)
109  m_propertyList.insert("fo:min-width",double(-size.x()), unit);
110  if (size.y()>0)
111  m_propertyList.insert("svg:height",double(size.y()), unit);
112  else if (size.y()<0)
113  m_propertyList.insert("fo:min-height",double(-size.y()), unit);
114  }
116  void setAnchor(AnchorTo anchor)
117  {
118  m_anchorTo=anchor;
119  }
121  friend std::ostream &operator<<(std::ostream &o, STOFFPosition const &pos)
122  {
123  o << "prop=[" << pos.m_propertyList.getPropString().cstr() << "],";
124  return o;
125  }
127  bool operator==(STOFFPosition const &f) const
128  {
129  return m_anchorTo==f.m_anchorTo && m_propertyList.getPropString()==f.m_propertyList.getPropString();
130  }
132  bool operator!=(STOFFPosition const &f) const
133  {
134  return !operator==(f);
135  }
136 
140  librevenge::RVNGPropertyList m_propertyList;
141 };
142 
143 #endif
144 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
T x() const
first element
Definition: libstaroffice_internal.hxx:592
void setSize(STOFFVec2f const &size, librevenge::RVNGUnit unit)
utility function to set a size
Definition: STOFFPosition.hxx:104
Definition: STOFFPosition.hxx:51
friend std::ostream & operator<<(std::ostream &o, STOFFPosition const &pos)
operator<<
Definition: STOFFPosition.hxx:121
bool operator!=(STOFFPosition const &f) const
basic operator!=
Definition: STOFFPosition.hxx:132
AnchorTo m_anchorTo
anchor position
Definition: STOFFPosition.hxx:138
void addTo(librevenge::RVNGPropertyList &propList) const
add to the propList
Definition: STOFFPosition.hxx:61
#define STOFF_DEBUG_MSG(M)
Definition: libstaroffice_internal.hxx:129
Definition: STOFFPosition.hxx:51
Definition: STOFFPosition.hxx:51
Definition: STOFFPosition.hxx:51
virtual ~STOFFPosition()
destructor
Definition: STOFFPosition.cxx:36
Definition: STOFFPosition.hxx:51
Definition: STOFFPosition.hxx:51
AnchorTo
a list of enum used to defined the anchor
Definition: STOFFPosition.hxx:51
void setAnchor(AnchorTo anchor)
set the anchor
Definition: STOFFPosition.hxx:116
T y() const
second element
Definition: libstaroffice_internal.hxx:597
void setOrigin(STOFFVec2f const &origin, librevenge::RVNGUnit unit)
utility function to set a origin
Definition: STOFFPosition.hxx:98
librevenge::RVNGPropertyList m_propertyList
the property list
Definition: STOFFPosition.hxx:140
STOFFPosition()
constructor
Definition: STOFFPosition.hxx:55
bool operator==(STOFFPosition const &f) const
basic operator==
Definition: STOFFPosition.hxx:127
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: STOFFPosition.hxx:47
Definition: STOFFPosition.hxx:51

Generated on Mon May 7 2018 12:25:56 for libstaroffice by doxygen 1.8.14