LibreOffice Module sw (master) 1
vbacolumn.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#include "vbacolumn.hxx"
20#include <utility>
22#include <com/sun/star/frame/XModel.hpp>
23#include <com/sun/star/table/XCellRange.hpp>
24#include <com/sun/star/view/XSelectionSupplier.hpp>
25#include "vbatablehelper.hxx"
26
27using namespace ::ooo::vba;
28using namespace ::com::sun::star;
29
30SwVbaColumn::SwVbaColumn( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, uno::Reference< text::XTextTable > xTextTable, sal_Int32 nIndex ) :
31 SwVbaColumn_BASE( rParent, rContext ), mxTextTable(std::move( xTextTable )), mnIndex( nIndex )
32{
33}
34
36{
37}
38
39sal_Int32 SAL_CALL
41{
42 SwVbaTableHelper aTableHelper( mxTextTable );
43 return aTableHelper.GetColWidth( mnIndex );
44}
45
46void SAL_CALL
47SwVbaColumn::setWidth( sal_Int32 _width )
48{
49
50 SwVbaTableHelper aTableHelper( mxTextTable );
51 aTableHelper.SetColWidth( _width, mnIndex );
52}
53
54void SAL_CALL
56{
58}
59
60void SwVbaColumn::SelectColumn( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nStartColumn, sal_Int32 nEndColumn )
61{
62 OUString sStartCol = SwVbaTableHelper::getColumnStr( nStartColumn );
63 OUString aRangeName = sStartCol + OUString::number( 1 );
64 OUString sEndCol = SwVbaTableHelper::getColumnStr( nEndColumn );
65 sal_Int32 nRowCount = xTextTable->getRows()->getCount();
66 aRangeName += ":" + sEndCol + OUString::number(nRowCount);
67
68 uno::Reference< table::XCellRange > xCellRange( xTextTable, uno::UNO_QUERY_THROW );
69 uno::Reference< table::XCellRange > xSelRange = xCellRange->getCellRangeByName( aRangeName );
70
71 uno::Reference< view::XSelectionSupplier > xSelection( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
72 xSelection->select( uno::Any( xSelRange ) );
73}
74
75OUString
77{
78 return "SwVbaColumn";
79}
80
81uno::Sequence< OUString >
83{
84 static uno::Sequence< OUString > const aServiceNames
85 {
86 "ooo.vba.word.Column"
87 };
88 return aServiceNames;
89}
90
91/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::uno::XComponentContext > mxContext
virtual void SAL_CALL Select() override
Definition: vbacolumn.cxx:55
virtual void SAL_CALL setWidth(sal_Int32 _width) override
Definition: vbacolumn.cxx:47
virtual css::uno::Sequence< OUString > getServiceNames() override
Definition: vbacolumn.cxx:82
static void SelectColumn(const css::uno::Reference< css::frame::XModel > &xModel, const css::uno::Reference< css::text::XTextTable > &xTextTable, sal_Int32 nStartColumn, sal_Int32 nEndColumn)
Definition: vbacolumn.cxx:60
sal_Int32 mnIndex
Definition: vbacolumn.hxx:32
virtual sal_Int32 SAL_CALL getWidth() override
Definition: vbacolumn.cxx:40
virtual ~SwVbaColumn() override
Definition: vbacolumn.cxx:35
SwVbaColumn(const css::uno::Reference< ooo::vba::XHelperInterface > &rParent, const css::uno::Reference< css::uno::XComponentContext > &rContext, css::uno::Reference< css::text::XTextTable > xTextTable, sal_Int32 nIndex)
Definition: vbacolumn.cxx:30
css::uno::Reference< css::text::XTextTable > mxTextTable
Definition: vbacolumn.hxx:31
virtual OUString getServiceImplName() override
Definition: vbacolumn.cxx:76
void SetColWidth(sal_Int32 _width, sal_Int32 nCol, sal_Int32 nRow=0, bool bCurRowOnly=false)
static OUString getColumnStr(sal_Int32 nCol)
static sal_Int32 GetColWidth(SwTabCols &rCols, sal_Int32 nNum)
Sequence< OUString > aServiceNames
sal_Int32 nIndex
VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentWordDoc(const css::uno::Reference< css::uno::XComponentContext > &xContext)
Reference< XModel > xModel
sal_uInt32 mnIndex