summaryrefslogtreecommitdiff
path: root/sw/inc/textboxhelper.hxx
blob: 747e729762efe6a8f3959f0d85ee0cea93163334 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef INCLUDED_SW_INC_TEXTBOXHELPER_HXX
#define INCLUDED_SW_INC_TEXTBOXHELPER_HXX

#include <list>

#include <com/sun/star/uno/Any.h>
#include <com/sun/star/uno/Type.h>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>

class SdrPage;
class SwFrmFmt;
class SwDoc;
class Rectangle;

/**
 * A TextBox is a TextFrame, that is tied to a drawinglayer shape.
 *
 * This class provides helper methods to create, query and maintain such
 * TextBoxes.
 */
class SwTextBoxHelper
{
public:
    /// Create a TextBox for a shape.
    static void create(SwFrmFmt* pShape);
    /// Destroy a TextBox for a shape.
    static void destroy(SwFrmFmt* pShape);
    /// Get interface of a shape's TextBox, if there is any.
    static css::uno::Any queryInterface(SwFrmFmt* pShape, const css::uno::Type& rType);
    /// Sync property of TextBox with the one of the shape.
    static void syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, const OUString& rPropertyName, const css::uno::Any& rValue);
    /// If we have an associated TextFrame, then return that.
    static SwFrmFmt* findTextBox(SwFrmFmt* pShape);
    /// Return the textbox rectangle of a draw shape (absolute values, in twips).
    static Rectangle getTextRectangle(SwFrmFmt* pShape);

    /// Look up TextFrames in a document, which are in fact TextBoxes.
    static std::list<SwFrmFmt*> findTextBoxes(const SwDoc* pDoc);
    /// Count number of shapes in the document, excluding TextBoxes.
    static sal_Int32 getCount(SdrPage* pPage, std::list<SwFrmFmt*>& rTextBoxes);
    /// Get a shape by index, excluding TextBoxes.
    static css::uno::Any getByIndex(SdrPage* pPage, sal_Int32 nIndex, std::list<SwFrmFmt*>& rTextBoxes) throw(css::lang::IndexOutOfBoundsException);
};

#endif // INCLUDED_SW_INC_TEXTBOXHELPER_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */