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 <vbahelper/vbahelper.hxx>
21 #include <tools/diagnose_ex.h>
22 #include "vbatable.hxx"
23 #include <com/sun/star/table/XCellRange.hpp>
24 #include <com/sun/star/view/XSelectionSupplier.hpp>
25 #include <rtl/ustrbuf.hxx>
26 #include "wordvbahelper.hxx"
27 #include "vbatablehelper.hxx"
28 
29 using namespace ::ooo::vba;
30 using namespace ::com::sun::star;
31 
32 SwVbaColumn::SwVbaColumn( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nIndex ) :
33  SwVbaColumn_BASE( rParent, rContext ), mxTextTable( xTextTable ), mnIndex( nIndex )
34 {
35 }
36 
38 {
39 }
40 
41 sal_Int32 SAL_CALL
43 {
44  SwVbaTableHelper aTableHelper( mxTextTable );
45  return aTableHelper.GetColWidth( mnIndex );
46 }
47 
48 void SAL_CALL
49 SwVbaColumn::setWidth( sal_Int32 _width )
50 {
51 
52  SwVbaTableHelper aTableHelper( mxTextTable );
53  aTableHelper.SetColWidth( _width, mnIndex );
54 }
55 
56 void SAL_CALL
58 {
60 }
61 
62 void SwVbaColumn::SelectColumn( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nStartColumn, sal_Int32 nEndColumn )
63 {
64  OUString sStartCol = SwVbaTableHelper::getColumnStr( nStartColumn );
65  OUString aRangeName = sStartCol + OUString::number( 1 );
66  OUString sEndCol = SwVbaTableHelper::getColumnStr( nEndColumn );
67  sal_Int32 nRowCount = xTextTable->getRows()->getCount();
68  aRangeName += ":" + sEndCol + OUString::number(nRowCount);
69 
70  uno::Reference< table::XCellRange > xCellRange( xTextTable, uno::UNO_QUERY_THROW );
71  uno::Reference< table::XCellRange > xSelRange = xCellRange->getCellRangeByName( aRangeName );
72 
73  uno::Reference< view::XSelectionSupplier > xSelection( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
74  xSelection->select( uno::makeAny( xSelRange ) );
75 }
76 
77 OUString
79 {
80  return "SwVbaColumn";
81 }
82 
83 uno::Sequence< OUString >
85 {
86  static uno::Sequence< OUString > const aServiceNames
87  {
88  "ooo.vba.word.Column"
89  };
90  return aServiceNames;
91 }
92 
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::text::XTextTable > mxTextTable
Definition: vbacolumn.hxx:31
sal_Int32 const mnIndex
Definition: vbacolumn.hxx:32
virtual sal_Int32 SAL_CALL getWidth() override
Definition: vbacolumn.cxx:42
static sal_Int32 GetColWidth(SwTabCols &rCols, sal_Int32 nNum)
sal_uInt32 mnIndex
virtual OUString getServiceImplName() override
Definition: vbacolumn.cxx:78
virtual void SAL_CALL setWidth(sal_Int32 _width) override
Definition: vbacolumn.cxx:49
void SetColWidth(sal_Int32 _width, sal_Int32 nCol, sal_Int32 nRow=0, bool bCurRowOnly=false)
SwVbaColumn(const css::uno::Reference< ooo::vba::XHelperInterface > &rParent, const css::uno::Reference< css::uno::XComponentContext > &rContext, const css::uno::Reference< css::text::XTextTable > &xTextTable, sal_Int32 nIndex)
Definition: vbacolumn.cxx:32
static OUString getColumnStr(sal_Int32 nCol)
uno::Reference< frame::XModel > getCurrentWordDoc(const uno::Reference< uno::XComponentContext > &xContext)
css::uno::Reference< css::uno::XComponentContext > mxContext
virtual ~SwVbaColumn() override
Definition: vbacolumn.cxx:37
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:62
virtual css::uno::Sequence< OUString > getServiceNames() override
Definition: vbacolumn.cxx:84
virtual void SAL_CALL Select() override
Definition: vbacolumn.cxx:57