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 virtual ~STOFFPosition();
59 void addTo(librevenge::RVNGPropertyList &propList) const
60 {
61 librevenge::RVNGPropertyList::Iter i(m_propertyList);
62 switch (m_anchorTo) {
63 case Cell:
64 propList.insert("text:anchor-type", "cell");
65 break;
66 case Char:
67 propList.insert("text:anchor-type", "char");
68 break;
69 case CharBaseLine:
70 propList.insert("text:anchor-type", "as-char");
71 break;
72 case Frame:
73 propList.insert("text:anchor-type", "frame");
74 break;
75 case Paragraph:
76 propList.insert("text:anchor-type", "paragraph");
77 break;
78 case Page:
79 propList.insert("text:anchor-type", "page");
80 break;
81 case Unknown:
82 default:
83 STOFF_DEBUG_MSG(("STOFFPosition::addTo: unknown anchor\n"));
84 break;
85 }
86 for (i.rewind(); i.next();) {
87 if (i.child()) {
88 STOFF_DEBUG_MSG(("STOFFPosition::addTo: find unexpected property child\n"));
89 propList.insert(i.key(), *i.child());
90 continue;
91 }
92 propList.insert(i.key(), i()->clone());
93 }
94 }
96 void setOrigin(STOFFVec2f const &origin, librevenge::RVNGUnit unit)
97 {
98 m_propertyList.insert("svg:x",double(origin[0]), unit);
99 m_propertyList.insert("svg:y",double(origin[1]), unit);
100 }
102 void setSize(STOFFVec2f const &size, librevenge::RVNGUnit unit)
103 {
104 if (size.x()>0)
105 m_propertyList.insert("svg:width",double(size.x()), unit);
106 else if (size.x()<0)
107 m_propertyList.insert("fo:min-width",double(-size.x()), unit);
108 if (size.y()>0)
109 m_propertyList.insert("svg:height",double(size.y()), unit);
110 else if (size.y()<0)
111 m_propertyList.insert("fo:min-height",double(-size.y()), unit);
112 }
114 void setAnchor(AnchorTo anchor)
115 {
116 m_anchorTo=anchor;
117 }
119 friend std::ostream &operator<<(std::ostream &o, STOFFPosition const &pos)
120 {
121 o << "prop=[" << pos.m_propertyList.getPropString().cstr() << "],";
122 return o;
123 }
125 bool operator==(STOFFPosition const &f) const
126 {
127 return m_anchorTo==f.m_anchorTo && m_propertyList.getPropString()==f.m_propertyList.getPropString();
128 }
130 bool operator!=(STOFFPosition const &f) const
131 {
132 return !operator==(f);
133 }
134
138 librevenge::RVNGPropertyList m_propertyList;
139};
140
141#endif
142// 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:125
STOFFPosition()
constructor
Definition: STOFFPosition.hxx:55
bool operator!=(STOFFPosition const &f) const
basic operator!=
Definition: STOFFPosition.hxx:130
librevenge::RVNGPropertyList m_propertyList
the property list
Definition: STOFFPosition.hxx:138
void addTo(librevenge::RVNGPropertyList &propList) const
add to the propList
Definition: STOFFPosition.hxx:59
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:119
void setSize(STOFFVec2f const &size, librevenge::RVNGUnit unit)
utility function to set a size
Definition: STOFFPosition.hxx:102
virtual ~STOFFPosition()
destructor
Definition: STOFFPosition.cxx:36
AnchorTo m_anchorTo
anchor position
Definition: STOFFPosition.hxx:136
void setAnchor(AnchorTo anchor)
set the anchor
Definition: STOFFPosition.hxx:114
void setOrigin(STOFFVec2f const &origin, librevenge::RVNGUnit unit)
utility function to set a origin
Definition: STOFFPosition.hxx:96
T y() const
second element
Definition: libstaroffice_internal.hxx:587
T x() const
first element
Definition: libstaroffice_internal.hxx:582
#define STOFF_DEBUG_MSG(M)
Definition: libstaroffice_internal.hxx:127

Generated on Fri Sep 30 2022 11:47:05 for libstaroffice by doxygen 1.9.5