- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
41 #include "libstaroffice_internal.hxx"
42
47 class STOFFPosition
48 {
49 public:
51 enum AnchorTo { Char, CharBaseLine, Frame, Paragraph, Page, Unknown };
52
53 public:
55 STOFFPosition() : m_anchorTo(Unknown), m_propertyList() {}
57 virtual ~STOFFPosition() {}
59 void addTo(librevenge::RVNGPropertyList &propList) const
60 {
61 librevenge::RVNGPropertyList::Iter i(m_propertyList);
62 for (i.rewind(); i.next();) {
63 if (i.child()) {
64 STOFF_DEBUG_MSG(("STOFFPosition::addTo: find unexpected property child\n"));
65 propList.insert(i.key(), *i.child());
66 continue;
67 }
68 propList.insert(i.key(), i()->clone());
69 }
70 }
72 void setOrigin(STOFFVec2f const &origin, librevenge::RVNGUnit unit)
73 {
74 m_propertyList.insert("svg:x",origin[0], unit);
75 m_propertyList.insert("svg:y",origin[1], unit);
76 }
78 void setSize(STOFFVec2f const &size, librevenge::RVNGUnit unit)
79 {
80 if (size.x()>0)
81 m_propertyList.insert("svg:width",size.x(), unit);
82 else if (size.x()<0)
83 m_propertyList.insert("fo:min-width",-size.x(), unit);
84 if (size.y()>0)
85 m_propertyList.insert("svg:height",size.y(), unit);
86 else if (size.y()<0)
87 m_propertyList.insert("fo:min-height",-size.y(), unit);
88 }
90 friend std::ostream &operator<<(std::ostream &o, STOFFPosition const &pos)
91 {
92 o << "prop=[" << pos.m_propertyList.getPropString().cstr() << "],";
93 return o;
94 }
96 bool operator==(STOFFPosition const &f) const
97 {
98 return m_anchorTo==f.m_anchorTo && m_propertyList.getPropString()==f.m_propertyList.getPropString();
99 }
101 bool operator!=(STOFFPosition const &f) const
102 {
103 return !operator==(f);
104 }
105
107 AnchorTo m_anchorTo;
109 librevenge::RVNGPropertyList m_propertyList;
110 };
111
112 #endif
113 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
STOFFPosition::setSize
void setSize(STOFFVec2f const &size, librevenge::RVNGUnit unit)
utility function to set a size
Definition: STOFFPosition.hxx:78
STOFFPosition::Page
Definition: STOFFPosition.hxx:51
STOFFPosition::operator<<
friend std::ostream & operator<<(std::ostream &o, STOFFPosition const &pos)
operator<<
Definition: STOFFPosition.hxx:90
STOFFPosition::operator==
bool operator==(STOFFPosition const &f) const
basic operator==
Definition: STOFFPosition.hxx:96
STOFFVec2< float >
STOFFPosition::m_anchorTo
AnchorTo m_anchorTo
anchor position
Definition: STOFFPosition.hxx:107
STOFF_DEBUG_MSG
#define STOFF_DEBUG_MSG(M)
Definition: libstaroffice_internal.hxx:127
STOFFPosition::Frame
Definition: STOFFPosition.hxx:51
STOFFPosition::Char
Definition: STOFFPosition.hxx:51
STOFFPosition::Unknown
Definition: STOFFPosition.hxx:51
STOFFPosition::Paragraph
Definition: STOFFPosition.hxx:51
STOFFVec2::y
T y() const
second element
Definition: libstaroffice_internal.hxx:593
STOFFPosition::~STOFFPosition
virtual ~STOFFPosition()
destructor
Definition: STOFFPosition.hxx:57
STOFFVec2::x
T x() const
first element
Definition: libstaroffice_internal.hxx:588
STOFFPosition::CharBaseLine
Definition: STOFFPosition.hxx:51
STOFFPosition::AnchorTo
AnchorTo
a list of enum used to defined the anchor
Definition: STOFFPosition.hxx:51
libstaroffice_internal.hxx
STOFFPosition::operator!=
bool operator!=(STOFFPosition const &f) const
basic operator!=
Definition: STOFFPosition.hxx:101
STOFFPosition::setOrigin
void setOrigin(STOFFVec2f const &origin, librevenge::RVNGUnit unit)
utility function to set a origin
Definition: STOFFPosition.hxx:72
STOFFPosition::m_propertyList
librevenge::RVNGPropertyList m_propertyList
the property list
Definition: STOFFPosition.hxx:109
STOFFPosition::STOFFPosition
STOFFPosition()
constructor
Definition: STOFFPosition.hxx:55
STOFFPosition::addTo
void addTo(librevenge::RVNGPropertyList &propList) const
add to the propList
Definition: STOFFPosition.hxx:59
STOFFPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: STOFFPosition.hxx:47