LibreOffice Module lotuswordpro (master) 1
xfdrawpath.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*************************************************************************
3 *
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
6 *
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
9 *
10 * Sun Microsystems Inc., October, 2000
11 *
12 * GNU Lesser General Public License Version 2.1
13 * =============================================
14 * Copyright 2000 by Sun Microsystems, Inc.
15 * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 *
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License version 2.1, as published by the Free Software Foundation.
20 *
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
25 *
26 * You should have received a copy of the GNU Lesser General Public
27 * License along with this library; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 *
31 *
32 * Sun Industry Standards Source License Version 1.1
33 * =================================================
34 * The contents of this file are subject to the Sun Industry Standards
35 * Source License Version 1.1 (the "License"); You may not use this file
36 * except in compliance with the License. You may obtain a copy of the
37 * License at http://www.openoffice.org/license.html.
38 *
39 * Software provided under this License is provided on an "AS IS" basis,
40 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 * See the License for the specific provisions governing your rights and
44 * obligations concerning the Software.
45 *
46 * The Initial Developer of the Original Code is: IBM Corporation
47 *
48 * Copyright: 2008 by IBM Corporation
49 *
50 * All Rights Reserved.
51 *
52 * Contributor(s): _______________________________________
53 *
54 *
55 ************************************************************************/
56/*************************************************************************
57 * @file
58 * Draw path object.
59 ************************************************************************/
62#include <rtl/ustrbuf.hxx>
63
65{
66}
67
69{
70 assert(!m_strCommand.isEmpty());
71 OUStringBuffer str(m_strCommand);
72
73 for (auto const& point : m_aPoints)
74 {
75 str.append( OUString::number(point.GetX()*1000) + " " + OUString::number(point.GetY()*1000) + " ");
76 }
77 str.stripEnd(' ');
78 return str.makeStringAndClear();
79}
80
82{
83}
84
86{
87 XFSvgPathEntry entry;
88
89 entry.SetCommand("M");
90 entry.AddPoint(pt);
91 m_aPaths.push_back(entry);
92}
93
95{
96 XFSvgPathEntry entry;
97
98 entry.SetCommand("L");
99 entry.AddPoint(pt);
100 m_aPaths.push_back(entry);
101}
102
104{
105 XFSvgPathEntry entry;
106
107 entry.SetCommand("C");
108 entry.AddPoint(ctrl1);
109 entry.AddPoint(ctrl2);
110 entry.AddPoint(dest);
111
112 m_aPaths.push_back(entry);
113}
114
116{
117 XFSvgPathEntry entry;
118
119 entry.SetCommand("Z");
120
121 m_aPaths.push_back(entry);
122}
123
125{
126 IXFAttrList *pAttrList = pStrm->GetAttrList();
127
128 pAttrList->Clear();
129 //view-box:
130 XFRect rect = m_aRect;
131
132 OUString strViewBox = "0 0 " +
133 OUString::number(rect.GetWidth()*1000) + " " +
134 OUString::number(rect.GetHeight()*1000);
135 pAttrList->AddAttribute( "svg:viewBox", strViewBox);
136
137 //points
138 OUStringBuffer strPath;
139 for (auto & path : m_aPaths)
140 {
141 strPath.append(path.ToString());
142 }
143 if (!strPath.isEmpty())
144 strPath.setLength(strPath.getLength()-1);
145 pAttrList->AddAttribute( "svg:d", strPath.makeStringAndClear());
146
147 SetPosition(rect);
148 XFDrawObject::ToXml(pStrm);
149
150 pStrm->StartElement( "draw:path" );
151 ContentToXml(pStrm);
152 pStrm->EndElement( "draw:path" );
153}
154
155/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Attribute list interface for sax writer.
Definition: ixfattrlist.hxx:72
virtual void Clear()=0
@descr: Clear all the attributes in the attribute list.
virtual void AddAttribute(const OUString &name, const OUString &value)=0
@descr: Add an attribute to the attribute list.
Stream wrapper for sax writer.
Definition: ixfstream.hxx:72
virtual IXFAttrList * GetAttrList()=0
@descr return the Attribute list interface.
virtual void StartElement(const OUString &oustr)=0
@descr Wrap XDocumentHandler::startElement()
virtual void EndElement(const OUString &oustr)=0
@descr Wrap XDocumentHandler::endElement()
virtual void ToXml(IXFStream *pStrm) override
@descr serialize.
Definition: xfdrawobj.cxx:75
void ContentToXml(IXFStream *pStrm)
Definition: xfdrawobj.cxx:70
void ClosePath()
@descr Close path command.
Definition: xfdrawpath.cxx:115
void LineTo(XFPoint pt)
@descr Line command.
Definition: xfdrawpath.cxx:94
virtual void ToXml(IXFStream *pStrm) override
@descr serialize.
Definition: xfdrawpath.cxx:124
void CurveTo(XFPoint dest, XFPoint ctrl1, XFPoint ctrl2)
@descr Curve command.
Definition: xfdrawpath.cxx:103
void MoveTo(XFPoint pt)
@descr Move command.
Definition: xfdrawpath.cxx:85
std::vector< XFSvgPathEntry > m_aPaths
Definition: xfdrawpath.hxx:128
XFRect m_aRect
Definition: xfframe.hxx:180
void SetPosition(double x, double y, double width, double height)
@descr Set frame position.
Definition: xfframe.hxx:227
double GetHeight() const
Definition: xfrect.hxx:115
double GetWidth() const
Definition: xfrect.hxx:105
SVG path segment wrapper.
Definition: xfdrawpath.hxx:71
std::vector< XFPoint > m_aPoints
Definition: xfdrawpath.hxx:92
void AddPoint(const XFPoint &pt)
@descr Set svg path point.
Definition: xfdrawpath.hxx:84
void SetCommand(const OUString &cmd)
@descr Set svg path command,L for line,M for move,...
Definition: xfdrawpath.hxx:131
OUString ToString()
Definition: xfdrawpath.cxx:68
OUString m_strCommand
Definition: xfdrawpath.hxx:91
def point()