summaryrefslogtreecommitdiffstats
path: root/oox/source/drawingml/diagram/diagramhelper.hxx
blob: 85ca4c45728c2ecd403e27e677a445570f0dc37a (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* -*- 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/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef INCLUDED_OOX_DRAWINGML_DIAGRAM_DIAGRAMHELPER_HXX
#define INCLUDED_OOX_DRAWINGML_DIAGRAM_DIAGRAMHELPER_HXX

#include <rtl/ustring.hxx>
#include <oox/drawingml/theme.hxx>
#include <oox/shape/ShapeFilterBase.hxx>
#include <svx/svdogrp.hxx>
#include <svx/diagram/IDiagramHelper.hxx>

namespace svx { namespace diagram {
    class DiagramDataState;
}}

namespace oox::drawingml {

class Diagram;

// Advanced DiagramHelper
//
// This helper tries to hold all necessary data to re-layout
// all XShapes/SdrObjects of an already imported Diagram. The
// Diagram holds the SmarArt model data before it gets layouted,
// while Theme holds the oox Fill/Line/Style definitions to
// apply.
// Re-Layouting (re-creating) is rather complex, for detailed
// information see ::reLayout implementation.
// This helper class may/should be extended to:
// - deliver representative data from the Diagram-Model
// - modify it eventually
// - im/export Diagram model to other representations
class AdvancedDiagramHelper final : public svx::diagram::IDiagramHelper
{
    const std::shared_ptr< Diagram >            mpDiagramPtr;
    std::shared_ptr<::oox::drawingml::Theme>    mpThemePtr;

    css::awt::Size maImportSize;

    bool hasDiagramData() const;

public:
    AdvancedDiagramHelper(
        const std::shared_ptr< Diagram >& rDiagramPtr,
        const std::shared_ptr<::oox::drawingml::Theme>& rTheme,
        css::awt::Size aImportSize);
    virtual ~AdvancedDiagramHelper();

    // re-create XShapes
    virtual void reLayout(SdrObjGroup& rTarget) override;

    // get text representation of data tree
    virtual OUString getString() const override;

    // get children of provided data node
    // use empty string for top-level nodes
    // returns vector of (id, text)
    virtual std::vector<std::pair<OUString, OUString>> getChildren(const OUString& rParentId) const override;

    // add/remove new top-level node to data model, returns its id
    virtual OUString addNode(const OUString& rText) override;
    virtual bool removeNode(const OUString& rNodeId) override;

    // Undo/Redo helpers to extract/restore Diagram-defining data
    virtual std::shared_ptr< svx::diagram::DiagramDataState > extractDiagramDataState() const override;
    virtual void applyDiagramDataState(const std::shared_ptr< svx::diagram::DiagramDataState >& rState) override;

    void doAnchor(SdrObjGroup& rTarget, ::oox::drawingml::Shape& rRootShape);
    std::shared_ptr< ::oox::drawingml::Theme > getOrCreateThemePtr(
        rtl::Reference< oox::shape::ShapeFilterBase>& rxFilter ) const;
};

}

#endif

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