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{
49public:
52
53public:
57 , m_origin()
58 , m_size()
59 , m_offset(0,0)
60 , m_propertyList() {}
62 virtual ~STOFFPosition();
64 void addTo(librevenge::RVNGPropertyList &propList) const
65 {
66 librevenge::RVNGPropertyList::Iter i(m_propertyList);
67 switch (m_anchorTo) {
68 case Cell:
69 propList.insert("text:anchor-type", "cell");
70 break;
71 case Char:
72 propList.insert("text:anchor-type", "char");
73 break;
74 case CharBaseLine:
75 propList.insert("text:anchor-type", "as-char");
76 break;
77 case Frame:
78 propList.insert("text:anchor-type", "frame");
79 break;
80 case Paragraph:
81 propList.insert("text:anchor-type", "paragraph");
82 break;
83 case Page:
84 propList.insert("text:anchor-type", "page");
85 break;
86 case Unknown:
87 default:
88 STOFF_DEBUG_MSG(("STOFFPosition::addTo: unknown anchor\n"));
89 break;
90 }
91 for (i.rewind(); i.next();) {
92 if (i.child()) {
93 STOFF_DEBUG_MSG(("STOFFPosition::addTo: find unexpected property child\n"));
94 propList.insert(i.key(), *i.child());
95 continue;
96 }
97 propList.insert(i.key(), i()->clone());
98 }
99 }
101 void setOrigin(STOFFVec2f const &origin)
102 {
103 m_origin=origin;
104 m_propertyList.insert("svg:x",double(origin[0]), librevenge::RVNG_POINT);
105 m_propertyList.insert("svg:y",double(origin[1]), librevenge::RVNG_POINT);
106 }
108 void setSize(STOFFVec2f const &size)
109 {
110 m_size=size;
111 if (size.x()>0)
112 m_propertyList.insert("svg:width",double(size.x()), librevenge::RVNG_POINT);
113 else if (size.x()<0)
114 m_propertyList.insert("fo:min-width",double(-size.x()), librevenge::RVNG_POINT);
115 if (size.y()>0)
116 m_propertyList.insert("svg:height",double(size.y()), librevenge::RVNG_POINT);
117 else if (size.y()<0)
118 m_propertyList.insert("fo:min-height",double(-size.y()), librevenge::RVNG_POINT);
119 }
121 void setAnchor(AnchorTo anchor)
122 {
123 m_anchorTo=anchor;
124 }
126 friend std::ostream &operator<<(std::ostream &o, STOFFPosition const &pos)
127 {
128 o << "prop=[" << pos.m_propertyList.getPropString().cstr() << "],";
129 return o;
130 }
132 bool operator==(STOFFPosition const &f) const
133 {
134 return m_anchorTo==f.m_anchorTo && m_origin==f.m_origin && m_size==f.m_size &&
135 m_offset==f.m_offset &&
136 m_propertyList.getPropString()==f.m_propertyList.getPropString();
137 }
139 bool operator!=(STOFFPosition const &f) const
140 {
141 return !operator==(f);
142 }
143
153 librevenge::RVNGPropertyList m_propertyList;
154};
155
156#endif
157// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
Class to define the position of an object (textbox, picture, ..) in the document.
Definition STOFFPosition.hxx:48
bool operator==(STOFFPosition const &f) const
basic operator==
Definition STOFFPosition.hxx:132
STOFFPosition()
constructor
Definition STOFFPosition.hxx:55
bool operator!=(STOFFPosition const &f) const
basic operator!=
Definition STOFFPosition.hxx:139
void setOrigin(STOFFVec2f const &origin)
utility function to set a origin in point
Definition STOFFPosition.hxx:101
librevenge::RVNGPropertyList m_propertyList
the property list
Definition STOFFPosition.hxx:153
void setSize(STOFFVec2f const &size)
utility function to set a size in point
Definition STOFFPosition.hxx:108
STOFFVec2f m_size
the size in point
Definition STOFFPosition.hxx:149
void addTo(librevenge::RVNGPropertyList &propList) const
add to the propList
Definition STOFFPosition.hxx:64
AnchorTo
a list of enum used to defined the anchor
Definition STOFFPosition.hxx:51
@ Unknown
Definition STOFFPosition.hxx:51
@ Frame
Definition STOFFPosition.hxx:51
@ CharBaseLine
Definition STOFFPosition.hxx:51
@ Cell
Definition STOFFPosition.hxx:51
@ Page
Definition STOFFPosition.hxx:51
@ Char
Definition STOFFPosition.hxx:51
@ Paragraph
Definition STOFFPosition.hxx:51
friend std::ostream & operator<<(std::ostream &o, STOFFPosition const &pos)
operator<<
Definition STOFFPosition.hxx:126
virtual ~STOFFPosition()
destructor
Definition STOFFPosition.cxx:36
AnchorTo m_anchorTo
anchor position
Definition STOFFPosition.hxx:145
STOFFVec2f m_offset
internal: an offset used to retrieve the local position in a DrawingLayer
Definition STOFFPosition.hxx:151
void setAnchor(AnchorTo anchor)
set the anchor
Definition STOFFPosition.hxx:121
STOFFVec2f m_origin
the origin in point
Definition STOFFPosition.hxx:147
T y() const
second element
Definition libstaroffice_internal.hxx:602
T x() const
first element
Definition libstaroffice_internal.hxx:597
#define STOFF_DEBUG_MSG(M)
Definition libstaroffice_internal.hxx:129

Generated on Mon Apr 22 2024 12:48:55 for libstaroffice by doxygen 1.10.0