2014-05-27 09:03:51 +02:00
|
|
|
/* -*- 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
|
|
|
|
|
2014-06-13 09:29:12 +02:00
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <vector>
|
2014-05-27 09:06:11 +02:00
|
|
|
|
2014-06-06 11:44:15 +02:00
|
|
|
#include <com/sun/star/drawing/XShape.hpp>
|
2014-05-27 09:03:51 +02:00
|
|
|
#include <com/sun/star/uno/Any.h>
|
|
|
|
#include <com/sun/star/uno/Type.h>
|
2014-05-27 09:06:29 +02:00
|
|
|
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
|
2014-05-27 09:03:51 +02:00
|
|
|
|
2014-06-06 11:44:15 +02:00
|
|
|
#include <swdllapi.h>
|
|
|
|
|
2014-05-27 09:06:11 +02:00
|
|
|
class SdrPage;
|
2014-11-20 16:44:21 +01:00
|
|
|
class SdrObject;
|
2014-06-19 17:10:59 +02:00
|
|
|
class SfxItemSet;
|
2015-05-20 13:05:49 +02:00
|
|
|
class SwFrameFormat;
|
|
|
|
class SwFrameFormats;
|
|
|
|
class SwFormatContent;
|
2014-05-27 09:06:11 +02:00
|
|
|
class SwDoc;
|
2014-05-28 15:35:33 +02:00
|
|
|
class Rectangle;
|
2014-06-13 09:29:12 +02:00
|
|
|
class _ZSortFly;
|
2014-10-31 16:31:11 +01:00
|
|
|
class SwNode;
|
2014-05-27 09:03:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A TextBox is a TextFrame, that is tied to a drawinglayer shape.
|
|
|
|
*
|
|
|
|
* This class provides helper methods to create, query and maintain such
|
|
|
|
* TextBoxes.
|
|
|
|
*/
|
2014-06-06 11:44:15 +02:00
|
|
|
class SW_DLLPUBLIC SwTextBoxHelper
|
2014-05-27 09:03:51 +02:00
|
|
|
{
|
|
|
|
public:
|
2014-06-13 09:29:12 +02:00
|
|
|
/// Maps a draw format to a fly format.
|
2015-05-20 13:05:49 +02:00
|
|
|
typedef std::map<const SwFrameFormat*, const SwFrameFormat*> SavedLink;
|
2014-06-13 09:29:12 +02:00
|
|
|
/// Maps a draw format to content.
|
2015-05-20 13:05:49 +02:00
|
|
|
typedef std::map<const SwFrameFormat*, SwFormatContent> SavedContent;
|
2014-05-27 09:03:51 +02:00
|
|
|
/// Create a TextBox for a shape.
|
2015-05-20 13:05:49 +02:00
|
|
|
static void create(SwFrameFormat* pShape);
|
2014-05-27 09:05:36 +02:00
|
|
|
/// Destroy a TextBox for a shape.
|
2015-05-20 13:05:49 +02:00
|
|
|
static void destroy(SwFrameFormat* pShape);
|
2014-05-27 09:05:55 +02:00
|
|
|
/// Get interface of a shape's TextBox, if there is any.
|
2015-05-20 13:05:49 +02:00
|
|
|
static css::uno::Any queryInterface(SwFrameFormat* pShape, const css::uno::Type& rType);
|
2014-05-30 17:42:22 +02:00
|
|
|
|
2014-05-27 09:03:51 +02:00
|
|
|
/// Sync property of TextBox with the one of the shape.
|
2015-05-20 13:05:49 +02:00
|
|
|
static void syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, const css::uno::Any& rValue);
|
2014-05-30 17:42:22 +02:00
|
|
|
/// Does the same, but works on properties which lack an sw-specific WID / MemberID.
|
2015-05-20 13:05:49 +02:00
|
|
|
static void syncProperty(SwFrameFormat* pShape, const OUString& rPropertyName, const css::uno::Any& rValue);
|
2014-06-13 19:37:37 +02:00
|
|
|
/// Get a property of the underlying TextFrame.
|
2015-05-20 13:05:49 +02:00
|
|
|
static void getProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, css::uno::Any& rValue);
|
2014-05-30 17:42:22 +02:00
|
|
|
|
2014-06-19 17:10:59 +02:00
|
|
|
/// Similar to syncProperty(), but used by the internal API (e.g. for UI purposes).
|
2015-11-25 06:03:10 -05:00
|
|
|
static void syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet& rSet);
|
2014-06-19 17:10:59 +02:00
|
|
|
|
2014-05-27 09:04:57 +02:00
|
|
|
/// If we have an associated TextFrame, then return that.
|
2015-05-20 13:05:49 +02:00
|
|
|
static SwFrameFormat* findTextBox(const SwFrameFormat* pShape);
|
2016-04-12 08:33:08 +02:00
|
|
|
static SwFrameFormat* findTextBox(const css::uno::Reference<css::drawing::XShape>& xShape);
|
2014-05-29 12:15:28 +02:00
|
|
|
/// Return the textbox rectangle of a draw shape (in twips).
|
2015-05-20 13:05:49 +02:00
|
|
|
static Rectangle getTextRectangle(SwFrameFormat* pShape, bool bAbsolute = true);
|
2014-05-27 09:06:11 +02:00
|
|
|
|
|
|
|
/// Look up TextFrames in a document, which are in fact TextBoxes.
|
2015-05-20 13:05:49 +02:00
|
|
|
static std::set<const SwFrameFormat*> findTextBoxes(const SwDoc* pDoc);
|
2014-10-31 16:31:11 +01:00
|
|
|
/**
|
|
|
|
* Look up TextFrames in a document, which are in fact TextBoxes.
|
|
|
|
*
|
2015-11-25 06:03:10 -05:00
|
|
|
* If rNode has a matching SwContentFrame, then only TextBoxes of rNode are
|
2014-10-31 16:31:11 +01:00
|
|
|
* returned.
|
|
|
|
*/
|
2015-05-20 13:05:49 +02:00
|
|
|
static std::set<const SwFrameFormat*> findTextBoxes(const SwNode& rNode);
|
2014-11-28 12:34:40 +01:00
|
|
|
/// Is pObject a textbox of a drawinglayer shape?
|
|
|
|
static bool isTextBox(const SdrObject* pObject);
|
2014-06-24 17:11:25 +02:00
|
|
|
/// Build a textbox -> shape format map.
|
2015-05-20 13:05:49 +02:00
|
|
|
static std::map<SwFrameFormat*, SwFrameFormat*> findShapes(const SwDoc* pDoc);
|
2014-05-27 09:06:11 +02:00
|
|
|
/// Count number of shapes in the document, excluding TextBoxes.
|
2015-05-20 13:05:49 +02:00
|
|
|
static sal_Int32 getCount(SdrPage* pPage, std::set<const SwFrameFormat*>& rTextBoxes);
|
2014-05-27 09:06:29 +02:00
|
|
|
/// Get a shape by index, excluding TextBoxes.
|
2015-05-20 13:05:49 +02:00
|
|
|
static css::uno::Any getByIndex(SdrPage* pPage, sal_Int32 nIndex, std::set<const SwFrameFormat*>& rTextBoxes) throw(css::lang::IndexOutOfBoundsException);
|
2014-11-20 16:44:21 +01:00
|
|
|
/// Get the order of the shape, excluding TextBoxes.
|
2015-05-20 13:05:49 +02:00
|
|
|
static sal_Int32 getOrdNum(const SdrObject* pObject, std::set<const SwFrameFormat*>& rTextBoxes);
|
2016-04-01 14:44:09 +02:00
|
|
|
/// If pTextBox is a textbox, then set rWrapThrough to the surround of its shape.
|
|
|
|
static void getShapeWrapThrough(const SwFrameFormat* pTextBox, bool& rWrapThrough);
|
2014-06-13 09:29:12 +02:00
|
|
|
|
|
|
|
/// Saves the current shape -> textbox links in a map, so they can be restored later.
|
2015-05-20 13:05:49 +02:00
|
|
|
static void saveLinks(const SwFrameFormats& rFormats, std::map<const SwFrameFormat*, const SwFrameFormat*>& rLinks);
|
2014-06-13 09:29:12 +02:00
|
|
|
/// Reset the shape -> textbox link on the shape, and save it to the map, so it can be restored later.
|
2015-05-20 13:05:49 +02:00
|
|
|
static void resetLink(SwFrameFormat* pShape, std::map<const SwFrameFormat*, SwFormatContent>& rOldContent);
|
2014-06-13 09:29:12 +02:00
|
|
|
/// Undo the effect of saveLinks() + individual resetLink() calls.
|
2015-05-20 13:05:49 +02:00
|
|
|
static void restoreLinks(std::set<_ZSortFly>& rOld, std::vector<SwFrameFormat*>& rNew, SavedLink& rSavedLinks, SavedContent& rResetContent);
|
2014-05-27 09:03:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDED_SW_INC_TEXTBOXHELPER_HXX
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|