summaryrefslogtreecommitdiffstats
path: root/svx/source/sidebar/area/AreaPropertyPanel.cxx
blob: f71754888d19a093a1748bbc5baa3723314cc674 (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* -*- 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 .
 */

#include "AreaPropertyPanel.hxx"
#include <svx/svxids.hrc>
#include <svx/xfltrit.hxx>
#include <svx/xflftrit.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/bindings.hxx>


using namespace css;
using namespace css::uno;

namespace svx::sidebar {

AreaPropertyPanel::AreaPropertyPanel(
    vcl::Window* pParent,
    const css::uno::Reference<css::frame::XFrame>& rxFrame,
    SfxBindings* pBindings)
    : AreaPropertyPanelBase(pParent, rxFrame),
      maStyleControl(SID_ATTR_FILL_STYLE, *pBindings, *this),
      maColorControl(SID_ATTR_FILL_COLOR, *pBindings, *this),
      maGradientControl(SID_ATTR_FILL_GRADIENT, *pBindings, *this),
      maHatchControl(SID_ATTR_FILL_HATCH, *pBindings, *this),
      maBitmapControl(SID_ATTR_FILL_BITMAP, *pBindings, *this),
      maGradientListControl(SID_GRADIENT_LIST, *pBindings, *this),
      maHatchListControl(SID_HATCH_LIST, *pBindings, *this),
      maBitmapListControl(SID_BITMAP_LIST, *pBindings, *this),
      maPatternListControl(SID_PATTERN_LIST, *pBindings, *this),
      maFillTransparenceController(SID_ATTR_FILL_TRANSPARENCE, *pBindings, *this),
      maFillFloatTransparenceController(SID_ATTR_FILL_FLOATTRANSPARENCE, *pBindings, *this),
      mpBindings(pBindings)
{
}

AreaPropertyPanel::~AreaPropertyPanel()
{
    disposeOnce();
}

void AreaPropertyPanel::dispose()
{
    maStyleControl.dispose();
    maColorControl.dispose();
    maGradientControl.dispose();
    maHatchControl.dispose();
    maBitmapControl.dispose();
    maGradientListControl.dispose();
    maHatchListControl.dispose();
    maBitmapListControl.dispose();
    maPatternListControl.dispose();
    maFillTransparenceController.dispose();
    maFillFloatTransparenceController.dispose();

    AreaPropertyPanelBase::dispose();
}

VclPtr<vcl::Window> AreaPropertyPanel::Create (
    vcl::Window* pParent,
    const css::uno::Reference<css::frame::XFrame>& rxFrame,
    SfxBindings* pBindings)
{
    if (pParent == nullptr)
        throw lang::IllegalArgumentException("no parent Window given to AreaPropertyPanel::Create", nullptr, 0);
    if ( ! rxFrame.is())
        throw lang::IllegalArgumentException("no XFrame given to AreaPropertyPanel::Create", nullptr, 1);
    if (pBindings == nullptr)
        throw lang::IllegalArgumentException("no SfxBindings given to AreaPropertyPanel::Create", nullptr, 2);

    return VclPtr<AreaPropertyPanel>::Create(
                pParent,
                rxFrame,
                pBindings);
}

void AreaPropertyPanel::setFillTransparence(const XFillTransparenceItem& rItem)
{
    GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_FILL_TRANSPARENCE,
            SfxCallMode::RECORD, { &rItem });
}

void AreaPropertyPanel::setFillFloatTransparence(const XFillFloatTransparenceItem& rItem)
{
    GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_FILL_FLOATTRANSPARENCE,
            SfxCallMode::RECORD, { &rItem });
}

void AreaPropertyPanel::setFillStyle(const XFillStyleItem& rItem)
{
    GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_FILL_STYLE,
            SfxCallMode::RECORD, { &rItem });
}

void AreaPropertyPanel::setFillStyleAndColor(const XFillStyleItem* pStyleItem,
        const XFillColorItem& rColorItem)
{
    GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_FILL_COLOR,
        SfxCallMode::RECORD, pStyleItem
            ? std::initializer_list<SfxPoolItem const*>{ &rColorItem, pStyleItem }
            : std::initializer_list<SfxPoolItem const*>{ &rColorItem });
}

void AreaPropertyPanel::setFillStyleAndGradient(const XFillStyleItem* pStyleItem,
        const XFillGradientItem& rGradientItem)
{
    GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_FILL_GRADIENT,
        SfxCallMode::RECORD, pStyleItem
            ? std::initializer_list<SfxPoolItem const*>{ &rGradientItem, pStyleItem }
            : std::initializer_list<SfxPoolItem const*>{ &rGradientItem });
}

void AreaPropertyPanel::setFillStyleAndHatch(const XFillStyleItem* pStyleItem,
        const XFillHatchItem& rHatchItem)
{
    GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_FILL_HATCH,
        SfxCallMode::RECORD, pStyleItem
            ? std::initializer_list<SfxPoolItem const*>{ &rHatchItem, pStyleItem }
            : std::initializer_list<SfxPoolItem const*>{ &rHatchItem });
}

void AreaPropertyPanel::setFillStyleAndBitmap(const XFillStyleItem* pStyleItem,
        const XFillBitmapItem& rBitmapItem)
{
    GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_FILL_BITMAP,
        SfxCallMode::RECORD, pStyleItem
            ? std::initializer_list<SfxPoolItem const*>{ &rBitmapItem, pStyleItem }
            : std::initializer_list<SfxPoolItem const*>{ &rBitmapItem });
}

} // end of namespace svx::sidebar

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