LibreOffice Module lotuswordpro (master) 1
xfframe.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 * Frame whose anchor is not page.
59 ************************************************************************/
60#include <xfilter/xfglobal.hxx>
62#include <xfilter/xfframe.hxx>
63
64#define ZINDEX_MIN 0
65
67 : XFFrame::XFFrame(false)
68{}
69
70XFFrame::XFFrame(bool isTextBox)
71 : m_eAnchor(enumXFAnchorPara)
72 , m_nAnchorPage(0)
73 , m_strName(XFGlobal::GenFrameName()) // give it a default name
74 , m_nZIndex(ZINDEX_MIN)
75 , m_fMinHeight(0)
77 , m_nFrameFlag(0)
78 , m_isTextBox(isTextBox)
79{}
80
82{
83}
84
85void XFFrame::Add(XFContent *pContent)
86{
87 if (!pContent)
88 return;
90 if( pContent->GetContentType() == enumXFContentFrame )
91 {
92 XFFrame *pFrame = static_cast<XFFrame*>(pContent);
93 if( pFrame )
94 {
95 pFrame->SetZIndex(pFrame->m_nZIndex + 1);
96 }
97 }
98
99}
100
101void XFFrame::SetZIndex(sal_uInt32 zIndex)
102{
103 if( zIndex == m_nZIndex )
104 return;
105 m_nZIndex = zIndex;
106 AdjustZIndex();
107}
108
110{
111 return m_eType;
112}
113
115{
116 return enumXFContentFrame;
117}
118
120{
121 StartFrame(pStrm);
122
124
125 EndFrame(pStrm);
126}
127
129{
130 IXFAttrList *pAttrList = pStrm->GetAttrList();
131
132 if( !GetStyleName().isEmpty() )
133 pAttrList->AddAttribute( "draw:style-name", GetStyleName() );
134
135 assert(!m_strName.isEmpty() && "name should not be null.");
136 if( !m_strName.isEmpty() && !m_isTextBox)
137 pAttrList->AddAttribute( "draw:name", m_strName );
138 //anchor type:
139 switch( m_eAnchor )
140 {
141 case enumXFAnchorPara:
142 pAttrList->AddAttribute( "text:anchor-type", "paragraph" );
143 break;
144 case enumXFAnchorPage:
145 pAttrList->AddAttribute( "text:anchor-type", "page" );
146 pAttrList->AddAttribute( "text:anchor-page-number", OUString::number(m_nAnchorPage) );
147 break;
148 case enumXFAnchorChar:
149 pAttrList->AddAttribute( "text:anchor-type", "char" );
150 break;
152 pAttrList->AddAttribute( "text:anchor-type", "as-char" );
153 break;
155 pAttrList->AddAttribute( "text:anchor-type", "frame" );
156 break;
157 default:
158 break;
159 }
160 pAttrList->AddAttribute( "svg:x", OUString::number(m_aRect.GetX()) + "cm" );
161 pAttrList->AddAttribute( "svg:y", OUString::number(m_aRect.GetY()) + "cm" );
162 pAttrList->AddAttribute( "svg:width", OUString::number(m_aRect.GetWidth()) + "cm" );
164 {
165 pAttrList->AddAttribute( "fo:min-height", OUString::number(m_fMinHeight) + "cm" );
167 pAttrList->AddAttribute( "fo:max-height", OUString::number(0) + "cm" );
168 }
169 else
170 pAttrList->AddAttribute( "svg:height", OUString::number(m_aRect.GetHeight()) + "cm" );
171
172 pAttrList->AddAttribute( "draw:z-index", OUString::number(m_nZIndex) );
173
174 if( !m_strNextLink.isEmpty() )
175 pAttrList->AddAttribute( "draw:chain-next-name", m_strNextLink );
176
177 pStrm->StartElement( "draw:text-box" );
178}
179
181{
182 pStrm->EndElement( "draw:text-box" );
183}
184
186{
187 for( int i=0; i<GetCount(); i++ )
188 {
190 if( pContent.is() )
191 {
192 if( pContent->GetContentType() == enumXFContentFrame )
193 {
194 XFFrame *pFrame = static_cast<XFFrame*>(pContent.get());
195 pFrame->m_nZIndex = m_nZIndex + 1;
196 pFrame->AdjustZIndex();
197 }
198 }
199 }
200}
201
202/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Attribute list interface for sax writer.
Definition: ixfattrlist.hxx:72
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 Output to OOo model or local file.
virtual void Add(XFContent *pContent)
@descr Add content.
int GetCount() const
@descr return the number of contents in the container.
rtl::Reference< XFContent > GetContent(sal_uInt32 index) const
@descr get content by index.
@descr Base class for all content object.
Definition: xfcontent.hxx:80
const OUString & GetStyleName() const
: return the style name.
Definition: xfcontent.hxx:95
virtual enumXFContent GetContentType()
: return the content type.
Definition: xfcontent.hxx:85
Base class for all frame object,include drawing,image,text-box.
Definition: xfframe.hxx:79
enumXFAnchor m_eAnchor
Definition: xfframe.hxx:176
virtual enumXFContent GetContentType() override
@descr Get content type, enumXFContentFrame.
Definition: xfframe.cxx:114
virtual ~XFFrame() override
Definition: xfframe.cxx:81
static void EndFrame(IXFStream *pStrm)
Definition: xfframe.cxx:180
enumXFFrameType GetFrameType() const
@descr Get the frame type.
Definition: xfframe.cxx:109
void AdjustZIndex()
Definition: xfframe.cxx:185
enumXFFrameType m_eType
Definition: xfframe.hxx:183
XFRect m_aRect
Definition: xfframe.hxx:180
bool m_isTextBox
Definition: xfframe.hxx:185
double m_fMinHeight
Definition: xfframe.hxx:181
void StartFrame(IXFStream *pStrm)
Definition: xfframe.cxx:128
sal_Int32 m_nAnchorPage
Definition: xfframe.hxx:177
void SetZIndex(sal_uInt32 zIndex)
@descr Set z-index of the frame.
Definition: xfframe.cxx:101
OUString m_strNextLink
Definition: xfframe.hxx:182
OUString m_strName
Definition: xfframe.hxx:178
virtual void Add(XFContent *pContent) override
@descr override the add function to adjust z-index.
Definition: xfframe.cxx:85
virtual void ToXml(IXFStream *pStrm) override
@descr serialize.
Definition: xfframe.cxx:119
XFFrame()
Definition: xfframe.cxx:66
sal_uInt32 m_nZIndex
Definition: xfframe.hxx:179
sal_uInt32 m_nFrameFlag
Definition: xfframe.hxx:184
Global object, it manages all global variables for the full filter.
Definition: xfglobal.hxx:82
double GetHeight() const
Definition: xfrect.hxx:115
double GetX() const
Definition: xfrect.hxx:85
double GetWidth() const
Definition: xfrect.hxx:105
double GetY() const
Definition: xfrect.hxx:95
const EnumerationType m_eType
int i
enumXFContent
Definition: xfdefs.hxx:64
@ enumXFContentFrame
Definition: xfdefs.hxx:75
enumXFFrameType
Definition: xfdefs.hxx:107
@ enumXFFrameTextbox
Definition: xfdefs.hxx:111
@ enumXFAnchorAsChar
Definition: xfdefs.hxx:261
@ enumXFAnchorChar
Definition: xfdefs.hxx:260
@ enumXFAnchorPara
Definition: xfdefs.hxx:258
@ enumXFAnchorPage
Definition: xfdefs.hxx:259
@ enumXFAnchorFrame
Definition: xfdefs.hxx:262
#define ZINDEX_MIN
Definition: xfframe.cxx:64
#define XFFRAME_FLAG_MINHEIGHT
Definition: xfframe.hxx:69
#define XFFRAME_FLAG_MAXHEIGHT
Definition: xfframe.hxx:70